:::: MENU ::::

Manually pair bluetooth devices on Linux via CLI (NFC workaround)

Today my new Thinkpad bluetooth keyboard arrived. It’s beautiful; I’m thrilled. It’s such a better companion for my XPS 15 9530 laptop than my old Penclick K2 the two don’t even compare.

Thinkpad bluetooth keyboard

Lenovo ThinkPad Compact Bluetooth Keyboard with TrackPoint

NFC comes built in to the new keyboard,  but unfortunately Gnu/Linux doesn’t support NFC well yet. Although NFC support is built in to the Linux Kernel, neither Gnome nor KDE have any support for it, and the number of NFC enabled apps in my Fedora 20 repository is princely zero. NFC won’t help me out pairing my device, so we need to do it the old fashioned way instead.

Unfortunately, it seems that my shiny NFC chip gets in the way of bluetooth pairing. Gnome network manager (using gnome-bluetooth) fails to connect to the device for an unstated reason. Rather than debug network manager (not fun in my experience), I decided to pair the device manually for more verbose output and another shot at success.

Since the release of Bluez 5 – the “Official Linux Bluetooth protocol stack” – command line Bluetooth interaction has become far more pleasant (and more colourful). Bluez 5 comes with a new command line client built in, superseeding the old collection of separate scripts called “simple-agent”. Here’s how to use it to pair your Bluetooth device, avoiding pitfalls of the network manager GUI.

Start the Bluez command line client:
bluetoothctl

list available devices (you can also search for new ones separately):
devices

Note the MAC address of the devices that you wish to pair. E.g.:
90:7F:61:11:0E:52

Pair with the device:
pair 90:7F:61:11:0E:52

Trust the device (skip the laborious code entering step for keyboards):
trust 90:7F:61:11:0E:52

Finally, connect the device:
connect 90:7F:61:11:0E:52

Try out the connectivity – it should now work. In my case the keyboard is tapping away as I write this text. Good luck!


9 Comments

So, what do you think ?