出自flip the world 檢視Bluetooth keyboard auto connect的原始碼 頁面討論 閱讀檢視原始碼檢視歷史 ←Bluetooth keyboard auto connect 您沒有權限執行編輯此頁面,由於以下原因: 您請求的操作只有這個群組的使用者能使用:使用者 您可以檢視並複製此頁面的原始碼。 Pairing a '''Bluetooth keyboard''' to a Raspberry Pi and having systemd reconnect it automatically at boot. == Find keyboard & device MAC == <pre> #hcitool scan Scanning ... 23:E4:87:4C:B3:A1 Wireless Keyboard # hcitool dev Devices: hci0 06:05:04:03:02:01 </pre> == Paring == <pre> #bluez-simple-agent hci0 23:E4:87:4C:B3:A1 If everything goes well, you will be prompted to type a passkey with your keyboard: DisplayPasskey (/org/bluez/14656/hci0/dev_23_E4_87_4C_B3_A1, 936319) Your passkey is the number at the end of the line. Don’t forget to press ‘Enter’ after typing the passcode! Now your device is paired with the Raspberry Pi. </pre> == Trusting & Connecting == <pre> The final stage is making sure that the raspberry will automatically connect to the keyboard when it is turned on. This is called ‘trusting’ and is invoked by this command: #bluez-test-device trusted 23:E4:87:4C:B3:A1 yes After trusing it, all you need to do is connect to it: #bluez-test-input connect 23:E4:87:4C:B3:A1 yes </pre> == Automative connecting with systemd == === /etc/btkbd.conf === <pre> # Config file for btkbd.service # change when required (e.g. keyboard hardware changes, more hci devices are connected) BTKBDMAC = 6C:5D:63:22:0B:05 HCIDEVICE = 00:1A:7D:DA:71:13 </pre> === /etc/systemd/system/btkbd.service === <pre> [Unit] Description=systemd Unit to automatically start a Bluetooth keyboard Documentation=https://wiki.archlinux.org/index.php/Bluetooth_Keyboard Requires=dbus-org.bluez.service After=dbus-bluez.org.service ConditionPathExists=/etc/btkbd.conf ConditionPathExists=/usr/bin/hcitool ConditionPathExists=/usr/sbin/hciconfig [Service] Type=oneshot EnvironmentFile=/etc/btkbd.conf ExecStart=-/usr/sbin/hciconfig ${HCIDEVICE} up # ignore errors on connect, spurious problems with bt? so start next command with - ExecStart=-/usr/bin/hcitool cc ${BTKBDMAC} </pre> == Reference == *[https://wiki.archlinux.org/index.php/bluetooth_keyboard Bluetooth keyboard] *[http://www.correlatedcontent.com/blog/bluetooth-keyboard-on-the-raspberry-pi/ Bluetooth Keyboard on the Raspberry Pi] [[Category:Projects]] 返回到「Bluetooth keyboard auto connect」。