Rasperry pi bluetooth keyboard

From Appelwiki
Revision as of 19:41, 9 October 2012 by Arco (talk | contribs)

Hardware setup


I verified this setup on 2012-09-18-wheezy-raspbian.img with a Sitecom CN500 dongle and a Motorola keyboard kit.


Install the needed software

Please note that the bluez-compat was not used in this howto.

pi@raspberrypi ~ $ sudo -s
root@raspberrypi:/home/pi# apt-get install bluez python-gobject

check hardware

Check for bluetooth dongles

root@raspberrypi:/home/pi# hcitool dev
Devices:
       hci0    00:10:60:A3:5A:AA

Your bluetooth dongle should be visible. Otherwise you should check the driver or the USB Bluetooth adapters page.

scan and pair

Scan for devices, you should remember the bluetooth address

root@raspberrypi:/home/pi# hcitool scan
Scanning ...
       00:0F:F6:82:D1:BB       Motorola Bluetooth Wireless Keyboard

Now pair the keyboard with the pin. for example 0000.

root@raspberrypi:/home/pi# echo 0000|bluez-simple-agent hci0 00:0F:F6:82:D1:BB
RequestPinCode (/org/bluez/3964/hci0/dev_00_0F_F6_82_D1_BB)
Enter PIN Code: Release
New device (/org/bluez/3964/hci0/dev_00_0F_F6_82_D1_BB)

Trust the device

The Raspberry should trust the keyboard so it connects after every reboot.

root@raspberrypi:/home/pi# bluez-test-device trusted 00:0F:F6:82:D1:BB yes

Test the device as an input

root@raspberrypi:/home/pi# bluez-test-input connect 00:0F:F6:82:D1:BB

After a reboot the keyboard should still connect. It's possibe a keystroke is needed to connect. Connection can take a few seconds.

root@raspberrypi:/home/pi# hcitool con
Connections:
       < ACL 00:0F:F6:82:D1:BB handle 41 state 1 lm MASTER AUTH ENCRYPT

Debugging

If the device isn't working the debugging tool hcidump can help.

# apt-get install bluez-hcidump

If the connection is ok but the device does not respond as an input you can check the real vendor and model:

root@raspberrypi:/home/pi# ls /sys/class/bluetooth/hci0\:*/
0005:22B8:093D.0004  address  device  features  input3  power  subsystem  type  uevent
ID_VENDOR 22B8
ID_MODEL  093D

To add an unknown device to udev edit the (non-existing) file /lib/udev/rules.d/62-bluez-hid2hci.rules and append the following line. logitech-hid can also be dell or csr

ACTION=="add", ENV{ID_VENDOR}=="22b8", ENV{ID_MODEL}=="093d" RUN+="/lib/udev/hid2hci --method logitech-hid -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"


Mouse

The mouse uses the same procedure as the keyboard. Only the bluetooth address changes. To test the mouse on the console you can use the dreaded gpm

 # apt-get install gpm


Template:Raspberry Pi