のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

Raspberry pi Bluetooth Keyboard

Raspberry Piへつなげるために、Bluetoothは以下のものを買った。
Elecom BlueTooth(LBT-UAN04C2)

Elecom Bluetooth Keyboard(TK-FBP043BK)

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get install bluetooth
pi@raspberrypi ~ $ sudo apt-get install bluez-utils
pi@raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0411:01ee BUFFALO INC. (formerly MelCo., Inc.) WLI-UC-GNM2 Wireless LAN Adapter [Ralink RT3070]
Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 008: ID 413c:2105 Dell Computer Corp. Model L100 Keyboard
Bus 001 Device 007: ID 413c:3016 Dell Computer Corp. Optical 5-Button Wheel Mouse
pi@raspberrypi ~ $ sudo hciconfig hci0 down
pi@raspberrypi ~ $ hciconfig
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 00:09:DD:40:E5:80  ACL MTU: 310:10  SCO MTU: 64:8
        DOWN                      <====DOWN
        RX bytes:12430 acl:0 sco:0 events:181 errors:0
        TX bytes:1549 acl:0 sco:0 commands:94 errors:0

pi@raspberrypi ~ $ sudo hciconfig hci0 up
pi@raspberrypi ~ $ hciconfig
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 00:09:DD:40:E5:80  ACL MTU: 310:10  SCO MTU: 64:8
        UP RUNNING PSCAN                                 <====UP
        RX bytes:13332 acl:0 sco:0 events:223 errors:0
        TX bytes:2253 acl:0 sco:0 commands:136 errors:0

Raspberry Pi で Bluetooth 設定

=======================================
Creating device failed: org.bluez.Error.AuthenticationRejected: Authentication Rejected

pi@raspberrypi ~ $ sudo bluez-simple-agent hci0 00:18:A3:06:EA:24
Creating device failed: org.bluez.Error.AuthenticationRejected: Authentication Rejected

pi@raspberrypi ~ $ sudo vi /usr/bin/bluez-simple-agent

        #capability = "KeyboardDisplay"
        capability = "DisplayYesNo"

capability = "DisplayYesNo"

capability = "DisplayYesNo"

=======================================
dbus.exceptions.DBusException: org.bluez.Error.Failed: Host is down (112)

Bluetooth Keyboard

pi@raspberrypi ~ $ sudo bluez-test-device trusted 00:18:A3:06:EA:24 yes

pi@raspberrypi ~ $ sudo bluez-test-input connect 00:18:A3:06:EA:24
Traceback (most recent call last):
  File "/usr/bin/bluez-test-input", line 40, in <module>
    input.Connect()
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.bluez.Error.Failed: Host is down (112) <===
pi@raspberrypi ~ $

調べていたら、いつの間にか、Already Connectedになった。

pi@raspberrypi ~ $ sudo bluez-test-input connect 00:18:A3:06:EA:24
Traceback (most recent call last):
  File "/usr/bin/bluez-test-input", line 40, in <module>
    input.Connect()
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.bluez.Error.AlreadyConnected: Already Connected <===
pi@raspberrypi ~ $

Bluetooth KeyboardでRaspberry Piに入力できるようになった。