35

I have a Bluetooth ThinkPad 2 Tablet keyboard that I want to pair with my Ubuntu Touch Aquaris E4.5. Due to GUI limitations, I want to try to do this in the terminal. I'm hoping that the process'll be similar to that on Ubuntu Desktop.

On Ubuntu Desktop 15.10, when pairing the keyboard, the following message is presented in a GUI dialog:

Please enter the following PIN on "ThinkPad keyboard" and press "Enter" on the keyboard:
<6-digit number>

Entering the 6-digit PIN on the Bluetooth keyboard and pressing Enter completes the pairing of the keyboard and it works fine. When I try to pair the keyboard on Ubuntu Touch, no GUI dialog is presented displaying the code that is to be entered on the Bluetooth keyboard. So, I want to try to pair the keyboard in the terminal.

I have tried the following:

phablet@ubuntu-phablet:~$ hcitool scan
Scanning ...
        AB:CD:EF:GH:IJ:KL       ThinkPad Keyboard
phablet@ubuntu-phablet:~$ bluez-simple-agent AB:CD:EF:GH:IJ:KL
RequestPinCode (/org/bluez/863/hci0/dev_AB_CD_EF_GH_IJ_KL)
Enter PIN Code: 0000
Release
Creating device failed: org.bluez.Error.ConnectionAttemptFailed: Page Timeout
phablet@ubuntu-phablet:~$

What could I try next?

2 Answers 2

49

You can try running bluetoothctl from the command line, make sure your device is on / ready to be discovered:

$ bluetoothctl
[NEW] Controller AA:BB:CC:DD:EE:FF device-name [default]

Any other bluetooth devices will be listed here. You'll then be inside a [bluetooth] prompt.

First, turn bluetooth power on (if your device is off):

[bluetooth]# power on
Changing power on succeeded

Then, make sure your agent is registered:

[bluetooth]# agent on
Agent registered

[bluetooth]# default-agent 
Default agent request successful

Now you can scan for devices from the console:

[bluetooth]# scan on
Discovery started
[CHG] Controller AA:BB:CC:DD:EE:FF Discovering: yes
[NEW] Device FF:EE:DD:CC:BB:AA Someone's Keyboard

You can manually pair from here as well:

[bluetooth]# pair FF:EE:DD:CC:BB:AA 
Attempting to pair with FF:EE:DD:CC:BB:AA 
[CHG] Device C8:E0:EB:04:52:55 Connected: yes

At this point, you should be prompted to enter a pin code for pairing:

Request PIN code
[agent] Enter PIN code: 12345

Enter a number (eg. 12345), and you will be prompted to input the same number from the device:

[Someone's Keyboard]# 12345

You should then be notified that your keyboard has paired:

[CHG] Device FF:EE:DD:CC:BB:AA Paired: yes

Hopefully this works for you, was trying to solve this for a while before I found any reference to bluetoothctl.


EDIT: The Ubuntu Touch OTA9 release includes Bluez 5, enabling pairing with the ThinkPad keyboards. Here's the little BQ Aquaris E4.5 acting almost as a palmtop.

10
  • Ok, silly question: how do I install bluetoothctl? I've tried sudo add-apt-repository ppa:vidplace7/bluez5; sudo apt-get update; sudo apt-get install bluez bluez-tools.
    – d3pd
    Dec 10, 2015 at 13:10
  • ... ¯_(ツ)_/¯ - it was already there on my machine, looking at my Bluez packages, the only other ones I've got are bluez-obexd and libbluetooth3, but my guess is they come with bluez (I'm running 5.35 fwiw).
    – 1nfiniti
    Dec 10, 2015 at 22:29
  • Thanks for your help on this. I have no idea how to get BlueZ 5 installed in Ubuntu Touch (and bricked/reflashed a device trying to do so), so I'll ask a separate question about this.
    – d3pd
    Dec 20, 2015 at 16:31
  • 1
    Hey again, the Ubuntu Touch OTA9 release includes Bluez 5 and it enables pairing with the ThinkPad Bluetooth keyboards, so the basic ideas of your solution were correct. Thanks again for your help.
    – d3pd
    Jan 28, 2016 at 7:58
  • I have been using bluetoothctl to connect Microsoft Universal Foldable Keyboard to my Aquaris M10 tablet and succeeded at that. Only problem is that Ubuntu Touch doesn't recognize when the keyboard is disconnected and refuses to present me the OSK until I reboot. Is there a way to detach the keyboard through a bluetoothctl command without having to go through the pairing process again? See my launchpad bug report here: bugs.launchpad.net/ubuntu/+source/ubuntu-system-settings/+bug/…
    – tomoqv
    May 2, 2016 at 11:31
14

Followed the steps by 1nfiniti on Ubuntu 16.04 amd64 and it worked great with Logitech MX5000 keyboard and mouse combo. But when I rebooted the computer, the keyboard didn't type again. It showed as connected but not paired on Bluetooth Settings. However, the mouse worked fine.

Having a look at bluetoothctl reference (https://wiki.archlinux.org/index.php/bluetooth#Bluetoothctl) realized that a 'trust' command was used after 'pair' command to allow some devices to successfully reconnect.

So I started bluetoothctl, disconnected and unpaired the keyboard, connected and paired it again, and issued

[bluetooth]# trust [keyboard MAC Address]

Then I was notified that your keyboard has been trusted

Trusted

And that did the trick, now the keyboard connects flawlessly every time I start/restart the computer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .