Rasperry pi bluetooth keyboard: Difference between revisions
No edit summary |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== | == Hardware setup == | ||
---- | |||
This howto was tested on 2012-09-18-wheezy-raspbian.img with a Sitecom CN500 dongle and a Motorola keyboard kit. | |||
---- | |||
Attach the bluetooth dongle to the Raspberry. Leave the keyboard powered off for now. | |||
== Install the needed software == | == 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 | Check for bluetooth dongles | ||
# hcitool dev | root@raspberrypi:/home/pi# hcitool dev | ||
Devices: | Devices: | ||
'''hci0''' 00:10:60:A3:5A:AA | '''hci0''' 00:10:60:A3:5A:AA | ||
Scan for devices | Your bluetooth dongle should be visible. Otherwise you should check the driver or the [[RPi_VerifiedPeripherals|USB Bluetooth adapters]] page. | ||
# hcitool scan | |||
== scan and pair == | |||
Turn on the device in pairing mode<br> | |||
Scan for devices, you should remember the bluetooth address | |||
root@raspberrypi:/home/pi# hcitool scan | |||
Scanning ... | Scanning ... | ||
'''00:0F:F6:82:D1:BB''' Motorola Bluetooth Wireless Keyboard | '''00:0F:F6:82:D1:BB''' Motorola Bluetooth Wireless Keyboard | ||
Now pair the keyboard with the pin. | Now pair the keyboard with the pin. This example uses pin 0000. | ||
echo | 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 | |||
# | <pre> | ||
ID_VENDOR 22B8 | ID_VENDOR 22B8 | ||
ID_MODEL 093D | ID_MODEL 093D | ||
</pre> | |||
ACTION=="add", ENV{ID_VENDOR}=="'''22b8'''", ENV{ID_MODEL}=="'''093d'''" RUN+="/ | 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. The method 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}} | |||
[[Category:RaspberryPi]] |
Latest revision as of 20:03, 18 January 2013
Hardware setup
This howto was tested on 2012-09-18-wheezy-raspbian.img with a Sitecom CN500 dongle and a Motorola keyboard kit.
Attach the bluetooth dongle to the Raspberry. Leave the keyboard powered off for now.
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
Turn on the device in pairing mode
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. This example uses pin 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. The method 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