title: Bluetooth SPP between Android and other device, UUID and PIN questions
body: <p>I'm trying to implement an Android application to receive data from a medical device but <strong>I can't get through the discovery process and get the phone and the device paired or connected to each other.</strong></p>
  
  <p><strong>Describing the medical device:</strong> 
  The device is using Service Discovery Protocol (SDP) and Serial Port Profile (SPP).
  It starts an inquiry procedure to discover (up to 10) surrounding access points with matched COD Filter and Service Name. Then it sequentially establishes a connection (using Page Procedure) with the access point by checking the PIN. Once the PIN is matched, the data is uploaded. Upon uploading data the device waits for an acknowledge. The decice is the master and initiates the communication.</p>
  
  <p>I have no control of the medical device. All I can do is to start it and await the procedure described above (after a measurement).</p>
  
  <p><strong>The Android application:</strong>
  I've started out from the <a href="http://developer.android.com/resources/samples/BluetoothChat/index.html" rel="noreferrer">Bluetooth Chat Example</a> on the developer pages. So far I've replaced the UUID with the <code>00001101-0000-1000-8000-00805f9b34fb</code> to use SPP and set the Service Name to the appropriate name. I can confirm this seems correct through inspection of the service from a computer. Since the medical device is the one that inquirys and initiates the communication my service is using a <code>BluetoothServerSocket</code> and the <code>accept()</code> method to start listening for it. </p>
  
  <ol>
  <li><p>In the developer pages I've read that UUID must match between the applications trying to communicate. Since I can't set any UUID for the medical device I'm wondering if this is going to be a problem or if it is enough that the medical device is using the SP Profile?</p></li>
  <li><p>If the Service Name and UUID are correct and the medical device would actually try to connect to my Bluetooth service which is listening for connections, would the Android system prompt me to input the PIN manually to be able to pair the devices (since the medical device has a pre-set PIN)?</p></li>
  <li><p>I haven't found anything in the Android SDK API that lets me set a PIN for my Bluetooth service (in case this is where it fails), is this possible?</p></li>
  </ol>
  
  <p>I've read that normally the PIN is generated by the system nowadays and a user confirmation is the only thing needed. I guess not in my system, since the device is a bit older.   </p>
  
  <p>I would be greatful if you would like to share some knowledge, hints, guesses of anything related to what I've described above!</p>
  
  <p>Thanks in advance,
  Fredrik</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>Now I've got the device paired with a <em>bluegiga</em> box and they communicate correctly. Now I'm searching for the criterias to fulfil for the blood pressure device to connect to my phone. I can inspect, from a Linux computer (<code>sdptool search SP</code> in a terminal), the Bluetooth service provided by the <em>bluegiga</em> and compare this to the Bluetooth service I provide on the Android. These values are what I get:</p>
  
  <blockquote>
    <p>~$ sdptool search SP</p>
    
    <p>Inquiring ...</p>
    
    <p>Searching for SP on 8C:71:F8:E5:XX:XX . . .</p>
    
    <p>Service Name: 1808130054</p>
    
    <p>Service RecHandle: 0x10003</p>
    
    <p>Service Class ID List:</p>
    
    <p>UUID 128: 00001101-0000-1000-8000-00805f9b34fb</p>
    
    <p>Protocol Descriptor List:</p>
    
    <p>"L2CAP" (0x0100)</p>
    
    <p>"RFCOMM" (0x0003)</p>
    
    <p>Channel: 13</p>
    
    <p>´</p>
    
    <p>Seaching for SP on 00:07:80:88:XX:XX . . .</p>
    
    <p>Service Name: 1808130054</p>
    
    <p>Service Description: 1808130054</p>
    
    <p>Service RecHandle: 0x10005</p>
    
    <p>Service Class ID List:</p>
    
    <p>"Serial Port" (0x1101)</p>
    
    <p>Protocol Descriptor List:</p>
    
    <p>"L2CAP" (0x0100)</p>
    
    <p>"RFCOMM" (0x0003)</p>
    
    <p>Channel: 12</p>
    
    <p>Language Base Attr List:</p>
    
    <p>code_ISO639: 0x656e</p>
    
    <p>enconding: 0x6a</p>
    
    <p>base_offset: 0x100</p>
  </blockquote>
  
  <p>The first device found is the phone (mac=8C:71...Google Nexus S) and the second (mac=00:07...) is the <em>bluegiga</em>. I notice that there is no Service Description on the Android device. I think the most important difference is in the Service Class ID List. UUID 128 on the Android but a totally different format describing this on the <em>bluegiga</em>.</p>
  
  <ol>
  <li><p>Is it possible to implement using Service Class IDs with other format than UUID on Android?</p></li>
  <li><p>Can you manipulate the Service Record registered in the service discovery DB?</p></li>
  <li><p>Would it be possible to somehow implement towards the BlueZ directly, using native development c/c++? </p></li>
  </ol>
  
  <p>/Fredrik</p>