Wikula » hwBluetooth
Bluetooth
Since the update from bluez to 4.40 bluetooth configuration has changed a lot and is now even worse - but not broken as you can read in some threads.
This page will explain how to do it the right way (and expects you have bluez >= 4.40-2)
You have to adjust your bluetooth device in all examples if it is not !hci0 (get the name with hcitool dev).
1) Get the bluetooth address of your remote device
Make sure your remote device is recoverable and run:hcitool scan
Example:
hcitool scan
Scanning ...
00:07:61:A7:56:4B Bluetooth Laser Travel Mouse
Bluetooth address here is 00:07:61:A7:56:4B
2) Pair with your remote device
/usr/share/doc/bluez/examples/simple-agent hci0 <bluetooth address>
You have to enter the correct pin here and remember the path thats printed.
Example:
/usr/share/doc/bluez/examples/simple-agent hci0 00:07:61:A7:56:4B RequestPinCode (/org/bluez/3070/hci0/dev_00_07_61_A7_56_4B) Enter PIN Code: 0000 Release New device (/org/bluez/3070/hci0/dev_00_07_61_A7_56_4B)
Path here is /org/bluez/3070/!hci0/dev_00_07_61_A7_56_4B
To remove a pairing just run the following command:
/usr/share/doc/bluez/examples/simple-agent hci0 <bluetooth address> remove
If your device is already paired you get the device path with the following command:
/usr/share/doc/bluez/examples/test-device list
3) Make the remote device trusted
/usr/share/doc/bluez/examples/test-device trusted <mouse address> yes
Example:
/usr/share/doc/bluez/examples/test-device trusted 00:07:61:A7:56:4B yes
The command above should return nothing, you can check the status with the following command:
/usr/share/doc/bluez/examples/test-device trusted 00:07:61:A7:56:4B
1 means true, 0 false.
4) Connect the remote device
This is different for every device family, the following command connects an input device (eg mouse):dbus-send --system --dest=org.bluez --print-reply <path> org.bluez.Input.Connect
For a audio device the command would be:
dbus-send --system --dest=org.bluez --print-reply <path> org.bluez.Audio.Connect
but test-audio is needed to pair correctly which is not available in Debian right now (June 09).
Example:
dbus-send --system --dest=org.bluez --print-reply /org/bluez/3070/hci0/dev_00_07_61_A7_56_4B org.bluez.Input.Connect method return sender=:1.1 -> dest=:1.80 reply_serial=2
Now your device should work.
Summery
After a reboot your device should work automatically or you just have to run step 4) above.Things will get easier as soon as frontends and GUIs are ready to use this new API, till then its a bit console hacking ;)
Good information (API, scripts) can be found here: /usr/share/doc/bluez/
Please edit this article if you managed to get another device family working then input devices (or if you found an error of course ;-) )
/hathe

