I use 2 usb bluetooth dongle : Inateck BTA-CSR4B5 FR that work well with raspberryPi/raspbian

Install packages

To make it work i have to install some packages

aptitude install bluetooth
aptitude install libbluetooth-dev

Then first try, i put rfcomm_server.c and rfcomm_client.c on my raspberrypi, update the mac dress of the server rpi on client.c ... compile them with gcc ofcomm_server.c -lbluetooth -o server ... then start the test ... that failed ... No route to host or Host down

Change Mac Address of the dongle

I first realize that my 2 dongles have both the same mac address : 00:1A:7D:DA:71:13

root@absimiliard:~# hciconfig
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 00:1A:7D:DA:71:13  ACL MTU: 310:10  SCO MTU: 64:8
        UP RUNNING PSCAN ISCAN 
        RX bytes:44145 acl:674 sco:0 events:1518 errors:0
        TX bytes:26392 acl:694 sco:0 commands:382 errors:0

So i have to change one mac, to do so I found a soft : bdaddr that I have to build :

wget -U "Mozilla" http://www.petrilopia.net/wordpress/wp-content/uploads/bdaddrtar.bz2
mv bdaddrtar.bz2 bdaddr.tar.bz2 
tar xvjf bdaddr.tar.bz2
cd bdaddr/
make
./bdaddr 00:1A:7D:DA:71:14

Then unplug and replug the dongle.

So now I retry my sample program ... but it still doesn't work ... Host down/Connection refused

Can't connect RFCOMM socket: Connection refused

Discovery

Perhaps no necessary, but I find the way to allow one device detect the other one. On server rpi:

hciconfig hci0 piscan

On client side:

root@rpib:~# hcitool scan
Scanning ...
        00:1A:7D:DA:71:14       absimiliard-0

Pairing the device

On client side :

bluez-simple-agent hci0 00:1A:7D:DA:71:14
bluez-test-device trusted 00:1A:7D:DA:71:14 yes

But in first try ... it doesn't work ... I find a clue __on a website ... to make it work I have to edit the /usr/bin/bluez-simple-agent file and replace line 92 KeyboardDisplay with DisplayYesNo

On server side:

bluez-test-device trusted 00:1A:7D:DA:71:13 yes

An now the sample works ... I will be able to start my tests :D

To make sample works after a reboot I saw that on server I have to allow page scan :

hciconfig hci0 pscan