Wednesday, April 13, 2011

bluetooth-keyboard with bluez 4.91

I've searched a lot and found nothing on this topic. Last year, i managed to get the keyboard connected, but it always lost keypresses or, even worse, key-releases, making the whole thing unusable.

Today, jhe in #bluez-users helped me to get it working:

he: first, forget about hidd. (its an old, unused daemon)

he: ensure that bluetoothd has loaded its input plugin
(this should happen as long as you don't have "input"
in the DisablePlugins value in /etc/bluetooth/main.conf

he: once you've done the above, pairing and connecting
your keyboard is just two command line commands (one for
pairing and another for connecting)

he: to pair: "bluez-simple-agent hci0 <keyboard address>"
(the script is called test/simple-agent in the bluez
source tree)

he: to connect: "bluez-test-input connect <keyboard
address>" (test/test-input in the source tree) and you
should of course follow your keyboards instructions on
how to make it pairable & connectable and how/when to
enter the PIN on it

he: once you've got all that successfully done you can
do one more optional step to make sure the keyboard can
reconnect to your PC without the need of explicitly
authorizing the connect request from some GUI: "bluez-
test-device trusted yes"



me: why is the "test" in those names?

he: test is in those names since they are considered
test scripts for bluez



me: so, my distribution just needs to make sure that
bluetoothd will be started on bootup, right?

he: yes



me: oh, because bluez is supposed to be used by some gui, ok

he: bluez comes neither with an official GUI client nor
with an official CLI client. So there's really no "supposed"
as far as bluez is concerned



me: gentoo's bluetooth start-script only calls "udevadm
trigger --subsystem-match=bluetooth --action=add". Do you
now how that starts bluetoothd?

he: not for sure, but I can guess: it tells udev to start
bluetoothd when it detects a hardware device that matches
subsystem=bluetooth



me: ok, sounds good. But there is no "bluetoothd" anywhere
in /etc/udev/rules.d/*.

he: I'm not familiar with the gentoo system configuration
so you'll have to figure this part out by yourself

And using those commands, I actually got it to work. Wheeeee!