title: Send data from android bluetooth to PC with bluecove
body: <p>I'm trying to send data from android (using API from its SDK) to a PC using Bluecove on windows, being this last one  the server.</p>
  
  <p>I can get the android to connect to the server but when I write to the socket's output stream, nothing happens on server. I have the onPut method overriden but it is never called.</p>
  
  <p>Code follows bellow, if anyone could help me I would be very appreciated :</p>
  
  <p>Android</p>
  
  <pre><code>public class BluetoothWorker {
  
  private static UUID generalUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
  
  private static BluetoothSocket socket;
  
  
  private static BluetoothSocket getBluetoothSocket(){
  
      BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
      mBluetoothAdapter.cancelDiscovery();
      Set&lt;BluetoothDevice&gt; pairedDevices = mBluetoothAdapter.getBondedDevices();
      // If there are paired devices
      if (pairedDevices.size() &gt; 0) {
          // Loop through paired devices
          for (BluetoothDevice device : pairedDevices) {
              // Add the name and address to an array adapter to show in a ListView
              if(device.getName().equalsIgnoreCase(("MIGUEL-PC"))){
                  try {
                      return device.createRfcommSocketToServiceRecord(generalUuid);
                  } catch (IOException e) {
                      return null;
                  }
              }
          }
      }
      return null;
  }
  
  public static boolean sendData(String status){
  
          socket = getBluetoothSocket();
          try {
              socket.connect();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              socket = null;
          }
  
      if(socket != null){
          try {       
  
              socket.getOutputStream().write(status.getBytes());
              socket.getOutputStream().flush();
              socket.close();
              return true;
          } catch (IOException e) {
              socket = null;
              return false;
          }
      }else{
          return false;
      }
  }
  }
  </code></pre>
  
  <p>PC code</p>
  
  <pre><code>public class AISHIntegrationBTBridge {
  
  static final String serverUUID = "0000110100001000800000805F9B34FB";
  
  public static void main(String[] args) throws IOException {
  
      LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
  
      SessionNotifier serverConnection = (SessionNotifier) Connector.open("btgoep://localhost:"
              + serverUUID + ";name=ObexExample");
  
      int count = 0;
      while(count &lt; 2) {
          RequestHandler handler = new RequestHandler();
          serverConnection.acceptAndOpen(handler);
  
          System.out.println("Received OBEX connection " + (++count));
      }
  }
  
  private static class RequestHandler extends ServerRequestHandler {
  
      public int onPut(Operation op) {
          try {
              HeaderSet hs = op.getReceivedHeaders();
              String name = (String) hs.getHeader(HeaderSet.NAME);
              if (name != null) {
                  System.out.println("put name:" + name);
              }
  
              InputStream is = op.openInputStream();
  
              StringBuffer buf = new StringBuffer();
              int data;
              while ((data = is.read()) != -1) {
                  buf.append((char) data);
              }
  
              System.out.println("got:" + buf.toString());
  
              op.close();
              return ResponseCodes.OBEX_HTTP_OK;
          } catch (IOException e) {
              e.printStackTrace();
              return ResponseCodes.OBEX_HTTP_UNAVAILABLE;
          }
      }
  }
  }
  </code></pre>