Rasperry pi bluetooth keyboard

From Appelwiki
Revision as of 12:01, 6 October 2012 by Arco (talk | contribs)

My setup

I wanted to use a Motorola bluetooth keyboard/mouse set on the Raspberry. Because a lot of older information is available I tried to merge all information into a new howto

Install the needed software

$ sudo -s
# apt-get install bluez  python-dbus python-gobject  

scan and pair

Check for bluetooth dongles

# hcitool dev
Devices:
       hci0    00:10:60:A3:5A:AA

Scan for devices

# hcitool scan
Scanning ...
       00:0F:F6:82:D1:BB       Motorola Bluetooth Wireless Keyboard

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

echo "0000"|bluez-simple-agent hci0 00:0F:F6:82:D1:BB

To test the keyboard, manually connect it.

hidd --connect 00:0F:F6:82:D1:BB

Check the keyboard on the console.

Autoconnect

Now to make it connect after every reboot.

# cd /sys/class/bluetooth
# ls
   hci0  hci0:41
# cd hci0\:41
# ls
  0005:22B8:093D.0002  device    input1  subsystem  uevent
  address              features  power   type

In the above directory the identifier contains the vendor and model. The 0005 is the bluetooth class. ID_VENDOR 22B8 ID_MODEL 093D In case of multiple devices you can check the address file. On newer bluetooth implementations the udev system is used to connect hid devices. Append the following line to the (non-existing) file /lib/udev/rules.d/62-bluez-hid2hci.rules

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

I don't know why a trusts file is needed. In several other examples it's used and without it sometimes failed.

#hcitool dev
 Devices:
       hci0    00:10:60:A3:5A:AA

edit /var/lib/bluetooth/"00:10:60:A3:5A:AA"/trusts

00:0F:F6:82:D1:BB [all]

after a reboot the keyboard should connect. I have to tap a key on mine to make it connect. Connection takes a few seconds.

Debugging

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

# apt-get install bluez-hcidump

Mouse =

The mouse uses the same procedure as the keyboard. Only the vendor/model changes.

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

to test the mouse on the console you can use the dreaded gpm

 # apt-get install gpm