Friday, December 20, 2013

Programmer's Diary: The Bluetooth Hell Continues on Linux

In my previous post I described an elaborate way to configure your bluetooth device on the badly behaving Bluez and newer kernels. Well, things seems to be changing again.

My distribution, Sabayon, pushed yesterday a newer pre-release of Bluez 5.... something. Now pairing actually works from KDE, however the bluetooth service segfaults when I connect my keyboard. Mouse connects though without a problem.

What is even funnier is that even though the service goes bye-bye, and I can not remove or add devices, once connected both mouse and keyboard works, with the service crashed!


csaba ~ # systemctl status bluetooth
bluetooth.service - Bluetooth service
   Loaded: loaded (/usr/lib64/systemd/system/bluetooth.service; enabled)
   Active: failed (Result: signal) since Fri 2013-12-20 19:08:15 EET; 14s ago
     Docs: man:bluetoothd(8)
  Process: 20461 ExecStart=/usr/libexec/bluetooth/bluetoothd (code=killed, signal=SEGV)
   Status: "Running"

Dec 20 19:08:01 csaba bluetoothd[20461]: Bluetooth daemon 5.12
Dec 20 19:08:01 csaba bluetoothd[20461]: Starting SDP server
Dec 20 19:08:01 csaba systemd[1]: Started Bluetooth service.
Dec 20 19:08:01 csaba bluetoothd[20461]: Bluetooth management interface 1.3 initialized
Dec 20 19:08:15 csaba systemd[1]: bluetooth.service: main process exited, code=killed, status=11/SEGV
Dec 20 19:08:15 csaba systemd[1]: Unit bluetooth.service entered failed state.

So it seems to be no problem, right? If the service crashes after my devices manage to connect, all I have to be careful about is to first connect my mouse, and only then my keyboard. Wrong! Bluetooth devices have this habit of entering in a sleep mode after a few minutes, so they reconnect automatically after an idle period of time when moved or touched. I must have my service up and running at that point.

In lack of a better idea ... I mean in lack of a lot of free time, because ideas I have plenty, here is a one liner crontab entry that will issue a start to your bluetooth daemon. Just put it in /etc/crontab


* * * * *       root    systemctl start bluetooth

If the service is already running, start will do nothing, if it does not, it will start it. Still, I have to remember to enable my mouse first, but in the worst case scenario I will need to wait one minute to connect the keyboard... or grab my other, non-bluetooth, keyboard and restart the service.

1 comment: