5

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.

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:

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

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.

This is my /etc/bluetooth/rfcomm.conf file:

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";
}

And running "rfcomm bind 0" does successfully create a device at /dev/rfcomm0:

rfcomm0: 00:0D:18:A0:4E:35 channel 16 clean 

However, trying to read from /dev/rfcomm0, gives me this:

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$ 

And thereafter, rfcomm returns this:

ubuntu@ubuntu-armhf:/etc/bluetooth$ rfcomm
rfcomm0: 00:0D:18:A0:4E:35 channel 16 closed 

I think I am using the correct channel (16) based on the result of "sdptool records"

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

Any help would be greatly appreciated, because I'm pretty well out of ideas at this point.

Refs:

tomgersic
  • 401
  • 6
  • 12
  • Regarding error found as "Creating device failed: org.bluez.Error.AlreadyExists: Already Exists", its because device is already created, try with these dbus commands to remove that device 1. dbus-send --system --type=method_call --print-reply --dest=org.bluez "/org/bluez/bluetooth_PID/hci0"org.bluez.Adapter.GetProperties 2. dbus-send --system --type=method_call --print-reply --dest=org.bluez "/org/bluez/3858/hci0" org.bluez.Adapter.RemoveDevice objpath:"/org/bluez/3858/hci0/dev_00_0D_18_A0_4E_35" , after this try pairing again with agent utility . – ashish Oct 10 '13 at 08:57

2 Answers2

4

Remove the paired device from bluetooth settings and add it again

Uri Agassi
  • 36,848
  • 14
  • 76
  • 93
Joseph Thomas
  • 484
  • 1
  • 5
  • 11
1

I know this is a little bit late but since I got here may be there is some other people struggling with it so I will post what worked for me, using what I suppose is the same device (OBDII ELM327 Blue Connector).

[USING BBB WITH DEBIAN WHEEZY]

  1. I have the following rfcomm.conf file under /etc/bluetooth/
rfcomm0 {
    bind yes;
    device AA:BB:CC:DD:EE:FF; # Remote device's MAC
    channel 16;
    comment "OBDII";
}
  1. # rfcomm connect rfcomm0

Each time the BBB is connected to a device, it seems it saves its configuration under /var/lib/bluetooth/XX:XX:XX:XX:XX:XX (MAC Address of the Bluetooth dongle gotten with hcitool dev)

  1. What Im doing to make sure it gets connected next time, I'm deleting all of the contents of the /var/lib/bluetooth/XX:XX:XX:XX:XX:XX folder with a cron job at boot, adding the following line to cron, using "crontrab -e" command on console

$ @reboot rm /var/lib/bluetooth/*

So each time it boots up again, I'm able to re-establish the connection using Linux commands when necesary.

I know this is little bit tricky and I don't know how good or bad is removing the bluetooth folder but it works for me, if you have any other comment or suggestion please let me know.

Matthieu
  • 2,736
  • 4
  • 57
  • 87
Master
  • 11
  • 1