Trust your bluetooth mouse on Linux

I recently acquired a Logitech bluetooth mouse and, although I was enjoying it a lot as always with Logitech, I was quite disappointed that I had to pair it again with my computer everytime it went to sleep or I would reboot it. So, after a small time of frustration, I decided to take a look on what was really going on, because the bluetooth keyboard was working like a charm, surviving reboots and so on.

The [Logitech m535](https://www.logitech.fr/fr-fr/product/bluetooth-mouse-m535?crid=7) is embarking Bluetooth 3.0 and my computer was powered with a Fedora 29 when this happened. The problem is that by default, because your device is not capable of inputting a PIN code like the keyboard could, it won't be trusted, thus needing a new pairing everytime the connexion is dropped. Thankfully, we can manually trust the device and get rid of this annoying ritual.

First of all, we need to completely remove the device from your bluetooth device list. In order to do so, you need to go in the bluetooth settings of Gnome, click on your device on the devices list and click the "Remove Device" button.

Remove Device Menu in Gnome - Fedora 29

Once this is done, shut off the mouse and the fun can start. What we will basically do is use the command-line client for bluetooth bluetoothctl and query manually with it.

So, first step is to launch it with bluetoothctl:

> $ bluetoothctl                                                 
Agent registered
[Keyboard K380]# 

Now that this is done, we can launch the scanner with scan on and then turn on the mouse:

[Keyboard K380]# scan on
Discovery started
[CHG] Controller 18:56:80:BF:23:C6 Discovering: yes
[CHG] Device C0:28:8D:D7:95:D1 RSSI: -68
[CHG] Device C0:28:8D:D7:95:D1 ManufacturerData Key: 0x0003
[CHG] Device C0:28:8D:D7:95:D1 ManufacturerData Value:
  01 12 63 00 60 0a 00 00 00 00 00 00 c0 28 8d d7  ..c.`........(..
  95 d1 22                                         .."             
[CHG] Device 7C:9F:89:CD:95:26 RSSI: -91
[CHG] Device 5D:40:51:12:7F:FA RSSI: -83
[CHG] Device 7F:EE:D2:4F:01:65 RSSI: -77
[CHG] Device 44:BB:ED:0E:C1:6A RSSI: -73
[CHG] Device 42:61:A6:0B:1D:F9 RSSI: -92
[CHG] Device 7D:F5:40:E3:AC:A0 RSSI: -87
[CHG] Device 48:9E:B1:AB:B1:A3 RSSI: -79
[CHG] Device 3C:BD:3E:37:B4:6B RSSI: -92
[CHG] Device 48:48:60:9F:68:93 RSSI: -89
[CHG] Device C4:1D:23:05:5F:B3 RSSI: -90
[CHG] Device 9C:DA:3E:B5:15:CA RSSI: -77
[CHG] Device 9C:DA:3E:B5:15:CA TxPower: 12
[NEW] Device XX:XX:XX:XX:XX:XX Bluetooth Mouse M336/M337/M535
[Keyboard K380]# 
[Keyboard K380]# scan off

You see the line with [NEW] ? That's the one we are looking for. You can then turn off the scanner to reduce the noise with scan of, copy the MAC address, here XX:XX:XX:XX:XX:XX, and then ask for pairing with pair XX:XX:XX:XX:XX:XX:

[Keyboard K380]# pair XX:XX:XX:XX:XX:XX
Attempting to pair with XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes
[CHG] Device XX:XX:XX:XX:XX:XX Modalias: usb:v046DpB016d1203
[CHG] Device XX:XX:XX:XX:XX:XX UUIDs: 00001000-0000-1000-8000-00805f9b34fb
[CHG] Device XX:XX:XX:XX:XX:XX UUIDs: 00001124-0000-1000-8000-00805f9b34fb
[CHG] Device XX:XX:XX:XX:XX:XX UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device XX:XX:XX:XX:XX:XX ServicesResolved: yes
[CHG] Device XX:XX:XX:XX:XX:XX Paired: yes
Pairing successful
[CHG] Device XX:XX:XX:XX:XX:XX ServicesResolved: no
[CHG] Device XX:XX:XX:XX:XX:XX Connected: no

Okay, now your device is paired, it's a good start! Now let's connect to it so that you can use it again with connect XX:XX:XX:XX:XX:XX:

[Keyboard K380]# connect XX:XX:XX:XX:XX:XX
Attempting to connect to XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes
Connection successful
[CHG] Device XX:XX:XX:XX:XX:XX ServicesResolved: yes

Perfect, now, if you move your mouse it should be working like before. Great, now the crucial part, let's manually trust your device with trust XX:XX:XX:XX:XX:XX:

[Bluetooth Mouse M336/M337/M535]# trust XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Trusted: yes
Changing XX:XX:XX:XX:XX:XX trust succeeded

Perfect! Now you can simply quit the command line utility with quit and you should be good to go. Try to restart your computer, your Bluetooth mouse should connect back automatically.

See you soon !

Show Comments