BlueZ on i.MX25 : Can't connect RFCOMM socket: Operation now in progress

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 :

  • edit /etc/bluetooth/rfcomm.conf, like I previously did
  • "Up" the local bt adapter : hciconfig 0 up
  • Enable page & inquiry scanning : hciconfig 0 piscan (I'm not sure about this one)
  • Disable simple pairing : hciconfig 0 sspmode 0
  • Edit (or create) /usr/var/lib/bluetooth/00:15:83:44:39:E2/pincodes
  • In "pincodes" files, add line (no quotes) : "00:07:80:5A:48:93 045678"
  • Manually start bluetooth daemon : bluetoothd

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

Update 06.15.2015

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 :

  • Save /usr/var/lib/bluetooth/00:15:83:44:39:E2/pincodes somewhere else
  • Remove everything under /usr/var/lib/bluetooth/00:15:83:44:39:E2
  • Reboot
  • Put your saved pincodes file back under /usr/var/lib/bluetooth/00:15:83:44:39:E2
  • Retry pinging as previously described