3

Some bluetooth low-energy (BLE) devices are difficult to pair in linux. All information I can find (including this question) suggests that gatttool should be used, like so:

sudo gatttool -t random -b E7:2D:83:06:AA:AB -I
[E7:2D:83:06:AA:AB][LE]> connect

Unfortunately gatttool is deprecated and no longer distributed in several linux distributions.

The archlinux documentation says that btgatt-client is supposed to replace gatttool. I have tried the following, without success:

$ btgatt-client -d F9:B9:1D:A5:73:F4 -t random -v
btgatt-client: Opening L2CAP LE connection on ATT channel:
     src: 00:00:00:00:00:00
    dest: F9:B9:1D:A5:73:F4
Connecting to device... Done
[GATT client]# att: (chan 0x5623a9b9d6e0) ATT op 0x08
[GATT client]# att: < 08 01 00 ff ff 3a 2b                             .....:+         
[GATT client]# att: Channel 0x5623a9b9d6e0 disconnected: Software caused connection abort
[GATT client]# gatt: Primary service discovery failed. ATT ECODE: 0x00
[GATT client]# gatt: Failed to initialize gatt-client
[GATT client]# GATT discovery procedures failed - error code: 0x00
[GATT client]# Device disconnected: Software caused connection abort

Unfortunately due to lack of documentation I do not know how to proceed.

1 Answer 1

1

As you mentioned in your original question, bluetoothctl should be used for pairing. You can also use btmgmt beforehand to set up your device properly. These are the steps that I usually follow in order to pair devices on Linux:

  1. Configure your device to be discoverable, connectable, and pairable
    sudo btmgmt power off
    sudo btmgmt discov on
    sudo btmgmt connectable on
    sudo btmgmt pairable on
    sudo btmgmt power on
    
  2. Set up your device to accept numerical pairing
    bluetoothctl --agent KeyboardDisplay
    
  3. Then, if your device is the peripheral, you should just wait until a pairing request is made from the remote device.

If your device is the central, then you can initiate pairing using the following command:

pair 00:11:22:33:44:55

Where 00:11:22:33:44:55 is the address of the device you want to pair to (you can find the address using the scan on/scan off commands).

Below are a few links that have more information which may help you answer your question:

You must log in to answer this question.

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