I'm trying to connect to a bluetooth device on embedded linux.
# Automatically bind the device at startup
# Bluetooth address of the device
# RFCOMM channel for the connection
# Description of the connection
comment "Example Bluetooth device";
hci0: Type: BR/EDR Bus: USB
BD Address: 00:15:83:44:39:E2 ACL MTU: 384:8 SCO MTU: 64:8
UP RUNNING PSCAN
RX bytes:28633 acl:0 sco:0 events:204 errors:0
TX bytes:899 acl:0 sco:0 commands:60 errors:0
Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x59 0x83
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
Name: 'Bluetooth2.1+EDR CLASS1'
Service Classes: Unspecified
Device Class: Miscellaneous,
HCI Version: 2.1 (0x4) Revision: 0x149c
LMP Version: 2.1 (0x4) Subversion: 0x149c
Manufacturer: Cambridge Silicon Radio (10)
# rfcomm connect 0
Can't connect RFCOMM socket: Operation now in progress
# hcitool cc 00:07:80:5A:48:93
Can't create connection: Connection timed out
# l2ping 00:07:80:5A:48:93
Can't connect: Invalid exchange
It turns out the target device was requesting authentication from my i.MX25 board.
Usually, PIN code handling is done by using bluetooth-agent.
But this agent wasn't actually installed on the board (I thought it was...), so I had to manually provide the requested PIN code.
This is how I did it :
00:15:83:44:39:E2 is local device bluetooth address.
00:07:80:5A:48:93 is target device bluetooth address.
045678 is target device PIN code.
l2ping works :
# l2ping 00:07:80:5A:48:93 Ping: 00:07:80:5A:48:93 from 00:15:83:44:39:E2 (data size 44) ... 4 bytes from 00:07:80:5A:48:93 id 0 time 13.14ms 4 bytes from 00:07:80:5A:48:93 id 1 time 26.34ms
rfcomm connect works :
# rfcomm connect 0 Connected /dev/rfcomm0 to 00:07:80:5A:48:93 on channel 1 Press CTRL-C for hangup
Today I tried l2ping on that target device again, as previously described. For some reason, it would throw me a "Permission denied" error.
This is what I figured out as a workaround :