Difference between revisions of "Bluetooth keyboard"

From ArchWiki
Jump to: navigation, search
m (stub)
(Bluetooth Keyboard at Startup: 2nd appearance error, removed)
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
[[ru:Bluetooth Keyboard]]
 
[[ru:Bluetooth Keyboard]]
 
{{Stub|Unfinished, missing references.}}
 
{{Stub|Unfinished, missing references.}}
 +
 +
== Bluetooth Keyboard Pairing Process ==
 +
 
This article describes how to set up a Bluetooth HID keyboard with Arch Linux, bluez version 5.
 
This article describes how to set up a Bluetooth HID keyboard with Arch Linux, bluez version 5.
  
Start bluetooth service and do
 
  $ bluetoothctl -a
 
  # pair <XX:XX:XX:XX:XX:XX>
 
  # trust <XX:XX:XX:XX:XX:XX>
 
  # connect <XX:XX:XX:XX:XX:XX>
 
  
device should be added as /dev/input/event* and your Xorg should add it automatically if you did not disable such feature.
 
  
== Bluetooth Keyboard at Startup ==
+
Make sure the local BT controller (e.g. a BT dongle the built in BT radio) is recognized:
 +
{{bc|# lsusb
 +
Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
 +
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
 +
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter / SMSC9512/9514 Hub
 +
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 +
}}
 +
 
 +
The above output is from a Raspberry-Pi revision 'B' with archlinux-arm and a Keysonic BT Dongle.
 +
 
 +
Start bluetooth service (as root):
 +
{{bc|# systemctl start bluetooth}}
 +
 
 +
If you are sure you want to have Bluetooth available after every booth automatically, permanently enable the service (as root):
 +
{{bc|# systemctl enable bluetooth}}
 +
 
 +
Two items worth remembering:
 +
* BT devices (keyboard) and controllers (dongle) need to be paired once
 +
* The BT controller needs to be powered up after every boot
 +
 
 +
'''Pairing''' is a one time process, required only once. There are BT keyboards sold with a BT dongle which come already paired, but that's not certain.  We will use the '''bluetoothctl''' command from bluez5 to pair our dongle and the keyboard.
 +
 
 +
'''Power up''' can also be done with '''bluetoothctl''', or with '''hciconfig''' which is more suitable for scripting. See below.
 +
 
 +
 
 +
We will use '''bluetoothctl''' for the pairing process:
 +
 
 +
{{bc|# bluetoothctl -a}}
 +
puts you at the '''[bluetooth]#''' prompt. If you are on a colour console: the word 'bluetooth' is in the default colour as long as no devices are available, and blue as soon as required devices and/or controllers have been found.
 +
 
 +
While in '''bluetoothctl''' power up the controller:
 +
{{bc|[...]# power on
 +
Changing power on succeeded
 +
[CHG] Controller 00:15:83:12:30:16 Powered: yes
 +
[...]#
 +
}}
 +
 
 +
Next, tell bluetoothctl to look only for keyboards, and make that the default agent:
 +
{{bc|[...]# agent KeyboardOnly
 +
Agent registered
 +
[...]# default-agent
 +
Default agent request successful
 +
[...]#
 +
}}
 +
 
 +
Next, put your controller (the local dongle) in 'pairable' mode:
 +
{{bc|[...]# pairable on
 +
Changing pairable on succeeded
 +
[...]#
 +
}}
 +
 
 +
Next, put your keyboard in an active mode, where it is 'discoverable', i.e. pairable. Some keyboards have a special button for this on the underside, or require a special key combination to be pressed. See the documentation of your keyboard. Please note that this 'discoverability' of a device is time limited, some devices are only visible 30 seconds, other for 2 minutes. YMMV.
 +
 
 +
Next, let the controller scan the BT frequencies for a suitable device:
 +
{{bc|[...]# scan on
 +
Discovery started
 +
[CHG] Controller 00:15:83:12:30:16 Discovering: yes
 +
[...]#
 +
}}
 +
 
 +
After a few seconds the adress of the keyboard should be listed as found. This line will repeat over and over, but won't stop you from entering new commands.
 +
 
 +
Next, actually do the pairing. The address used is the BT-MAC address of the keyboard:
 +
{{bc|[...]# pair 01:02:03:04:05:06
 +
Pairing successful
 +
[...]#
 +
}}
 +
 
 +
Next, make this a trusted device (the author does not know the effects of this command, but it seems to be required):
 +
{{bc|[...]# trust 01:02:03:04:05:06
 +
Trusted
 +
[...]#
 +
}}
 +
 
 +
Next and finally connect to the device (keyboard):
 +
{{bc|[...]# connect 01:02:03:04:05:06
 +
Connection successful
 +
[...]#
 +
}}
 +
 
 +
'''Done.'''
 +
 
 +
Now the external device (i.e. keyboard) and the USB BT dongle are paired permanently, until you break the pairing manually. This does not mean that the keyboard will connect automatically to your BT device. This needs to be done after startup of your computer.
 +
 
 +
== Enable Bluetooth Keyboard at Startup ==
 +
 
 +
Although the device and the controller are now paired, you need to connect them every time the computer starts.
 +
 
 +
First the device (i.e. BT Dongle) needs to be powered up. This is done with the '''hciconfig''' utility. We assume that you have only one BT device connected, and this one has the symbolic name '''hci0'''.
 +
{{bc| # hciconfig hci0 up}}
 +
 
 +
Next, make the connection, now using the '''hcitool''' utility. Make sure that the keyboard is powered up and connectable, i.e. not in a power saving sleep state.
 +
{{bc| # hcitool cc 01:02:03:04:05:06}}
 +
 
 +
Your BT keyboard should be useable now. Nex twe will discuss how to automate this with '''systemd'''.
 +
 
 +
 
 +
== Automatic start of a BT Keyboard ==
  
 
TBD
 
TBD
 +
 +
 +
 +
 +
 +
== Xorg ==
 +
Device should be added as /dev/input/event* and your Xorg should add it automatically if you did not disable such feature.

Revision as of 23:53, 1 December 2013

Tango-document-new.pngThis article is a stub.Tango-document-new.png

Notes: Unfinished, missing references. (Discuss in Talk:Bluetooth keyboard#)

Bluetooth Keyboard Pairing Process

This article describes how to set up a Bluetooth HID keyboard with Arch Linux, bluez version 5.


Make sure the local BT controller (e.g. a BT dongle the built in BT radio) is recognized:

# lsusb
Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter / SMSC9512/9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The above output is from a Raspberry-Pi revision 'B' with archlinux-arm and a Keysonic BT Dongle.

Start bluetooth service (as root):

# systemctl start bluetooth

If you are sure you want to have Bluetooth available after every booth automatically, permanently enable the service (as root):

# systemctl enable bluetooth

Two items worth remembering:

  • BT devices (keyboard) and controllers (dongle) need to be paired once
  • The BT controller needs to be powered up after every boot

Pairing is a one time process, required only once. There are BT keyboards sold with a BT dongle which come already paired, but that's not certain. We will use the bluetoothctl command from bluez5 to pair our dongle and the keyboard.

Power up can also be done with bluetoothctl, or with hciconfig which is more suitable for scripting. See below.


We will use bluetoothctl for the pairing process:

# bluetoothctl -a

puts you at the [bluetooth]# prompt. If you are on a colour console: the word 'bluetooth' is in the default colour as long as no devices are available, and blue as soon as required devices and/or controllers have been found.

While in bluetoothctl power up the controller:

[...]# power on
Changing power on succeeded
[CHG] Controller 00:15:83:12:30:16 Powered: yes
[...]#

Next, tell bluetoothctl to look only for keyboards, and make that the default agent:

[...]# agent KeyboardOnly
Agent registered
[...]# default-agent
Default agent request successful
[...]# 

Next, put your controller (the local dongle) in 'pairable' mode:

[...]# pairable on
Changing pairable on succeeded
[...]# 

Next, put your keyboard in an active mode, where it is 'discoverable', i.e. pairable. Some keyboards have a special button for this on the underside, or require a special key combination to be pressed. See the documentation of your keyboard. Please note that this 'discoverability' of a device is time limited, some devices are only visible 30 seconds, other for 2 minutes. YMMV.

Next, let the controller scan the BT frequencies for a suitable device:

[...]# scan on
Discovery started
[CHG] Controller 00:15:83:12:30:16 Discovering: yes
[...]# 

After a few seconds the adress of the keyboard should be listed as found. This line will repeat over and over, but won't stop you from entering new commands.

Next, actually do the pairing. The address used is the BT-MAC address of the keyboard:

[...]# pair 01:02:03:04:05:06
Pairing successful
[...]# 

Next, make this a trusted device (the author does not know the effects of this command, but it seems to be required):

[...]# trust 01:02:03:04:05:06
Trusted 
[...]# 

Next and finally connect to the device (keyboard):

[...]# connect 01:02:03:04:05:06
Connection successful
[...]# 

Done.

Now the external device (i.e. keyboard) and the USB BT dongle are paired permanently, until you break the pairing manually. This does not mean that the keyboard will connect automatically to your BT device. This needs to be done after startup of your computer.

Enable Bluetooth Keyboard at Startup

Although the device and the controller are now paired, you need to connect them every time the computer starts.

First the device (i.e. BT Dongle) needs to be powered up. This is done with the hciconfig utility. We assume that you have only one BT device connected, and this one has the symbolic name hci0.

 # hciconfig hci0 up

Next, make the connection, now using the hcitool utility. Make sure that the keyboard is powered up and connectable, i.e. not in a power saving sleep state.

 # hcitool cc 01:02:03:04:05:06

Your BT keyboard should be useable now. Nex twe will discuss how to automate this with systemd.


Automatic start of a BT Keyboard

TBD



Xorg

Device should be added as /dev/input/event* and your Xorg should add it automatically if you did not disable such feature.