title: Having difficulty pairing with a bluetooth OBDII device on Ubuntu
body: <p>I'm attempting to pair with a automotive OBDII bluetooth device from a Beaglebone Black running Ubuntu Linux, and not having a ton of luck.</p>
  
  <p>I was able, initially to set up hci0 using bluez-simple-agent, although it never asked me for a PIN. The PIN for this device is supposed to be "1234". Now, when I run bluez-simple-agent, I get this:</p>
  
  <pre><code>ubuntu@ubuntu-armhf:/etc/bluetooth$ sudo bluez-simple-agent hci0 00:0D:18:A0:4E:35
  Creating device failed: org.bluez.Error.AlreadyExists: Already Exists
  </code></pre>
  
  <p>Which would be fine if it was working, but when I try to bind using rfcomm, I repeatedly get either "Can't connect RFCOMM socket: Invalid exchange" (first time after restarting the device) and then "Can't connect RFCOMM socket: Connection refused" every time thereafter.</p>
  
  <p>This is my /etc/bluetooth/rfcomm.conf file:</p>
  
  <pre><code>rfcomm0 {
      # Automatically bind the device at startup
      bind no;
  
      # Bluetooth address of the device
      device 00:0D:18:A0:4E:35;
  
      # RFCOMM channel for the connection
      channel 16;
  
      # Description of the connection
      comment "OBDII";
  }
  </code></pre>
  
  <p>And running "rfcomm bind 0" does successfully create a device at /dev/rfcomm0:</p>
  
  <pre><code>rfcomm0: 00:0D:18:A0:4E:35 channel 16 clean 
  </code></pre>
  
  <p>However, trying to read from /dev/rfcomm0, gives me this:</p>
  
  <pre><code>ubuntu@ubuntu-armhf:/etc/bluetooth$ sudo cat /dev/rfcomm0
  cat: /dev/rfcomm0: Invalid exchange
  ubuntu@ubuntu-armhf:/etc/bluetooth$ sudo cat /dev/rfcomm0
  cat: /dev/rfcomm0: Connection refused
  ubuntu@ubuntu-armhf:/etc/bluetooth$ 
  </code></pre>
  
  <p>And thereafter, rfcomm returns this:</p>
  
  <pre><code>ubuntu@ubuntu-armhf:/etc/bluetooth$ rfcomm
  rfcomm0: 00:0D:18:A0:4E:35 channel 16 closed 
  </code></pre>
  
  <p>I think I am using the correct channel (16) based on the result of "sdptool records"</p>
  
  <pre><code>ubuntu@ubuntu-armhf:/etc/bluetooth$ sudo sdptool records 00:0D:18:A0:4E:35 
  ...
  Protocol Descriptor List:
    "L2CAP" (0x0100)
    "RFCOMM" (0x0003)
      Channel: 16
  Profile Descriptor List:
    "Serial Port" (0x1101)
      Version: 0x0100
  </code></pre>
  
  <p>Any help would be greatly appreciated, because I'm pretty well out of ideas at this point.</p>
  
  <p>Refs:</p>
  
  <ul>
  <li><a href="http://manpages.ubuntu.com/manpages/lucid/man1/rfcomm.1.html" rel="noreferrer">rfcomm</a></li>
  <li><a href="http://wiki.openmoko.org/wiki/Manually_using_Bluetooth" rel="noreferrer">Manually Using Bluetooth</a> RFCOMM</li>
  <li><a href="http://www.thinkwiki.org/wiki/How_to_setup_Bluetooth" rel="noreferrer">How to Set Up Bluetooth</a> Serial connection over Bluetooth</li>
  <li><a href="http://www.bafxpro.com/pic18f2480-bluetooth-obdii-automotive-diagnostic-scanner-for-android/" rel="noreferrer">The device</a></li>
  </ul>