Consistency: fix external-link syntax, heading case and wikilink form |
Consistency: Related projects list, heading levels, fill empty sections |
||
| 第29行: | 第29行: | ||
== Automative connecting with systemd == | == Automative connecting with systemd == | ||
=== /etc/btkbd.conf === | |||
<pre> | <pre> | ||
# Config file for btkbd.service | # Config file for btkbd.service | ||
| 第37行: | 第37行: | ||
</pre> | </pre> | ||
=== /etc/systemd/system/btkbd.service === | |||
<pre> | <pre> | ||
[Unit] | [Unit] | ||
2026年8月23日 (日) 16:50的版本
Find keyboard & device MAC
#hcitool scan
Scanning ...
23:E4:87:4C:B3:A1 Wireless Keyboard
# hcitool dev
Devices:
hci0 06:05:04:03:02:01
Paring
#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.
Trusting & Connecting
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
Automative connecting with systemd
/etc/btkbd.conf
# 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
/etc/systemd/system/btkbd.service
[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}