Debian – How to set up automatic connection of bluetooth headset

bluetoothbluezdebianlinux

My bluetooth headset works fine. Audio sink works. Everything work. But the problem is that I need to connect it manually to the PC:

  • click on bluetooth icon near the time on kde taskbar => known devices => Connect
  • # bluetoothctl => connect xx:xx:xx:xx:xx:xx

It used to connect automatically just a month ago with standard debian installation/updates. I don't know why it got broken. I didn't install any bluetooth-related packages nor change bluetooth-related configuration files.

What I did to fix my problem:

  • purged and reinstalled all bluetooth-related packages (see below).
  • added a line load-module module-switch-on-connect to /etc/pulse/default.pa as described here
  • created a file /etc/bluetooth/audio.conf with a line AutoConnect=true and restarted bluetooth service afterwards, as said here
  • script (from askubuntu) does not work. I get this message:

    Browsing 00:18:09:29:XX:XX ...
    Sink bluez_sink.00_18_09_29_XX_XX does not exist.
    

How to make it to be able to connect to bluetooth headset automatically when it goes online?
I feel like the solution is easy.

Debian 8.6, kde 4.14.2. Packages used: bluedevil, bluetooth, bluez, pulseaudio-module-bluetooth.

Best Answer

Normally your headset should try to connect to last device it connected automatically (most, if not all, does that). However this may fail if your device is not a trusted device.

First thing to check is the log files. In Ubuntu under /var/log/syslog, may have different name under Debian... There I saw the error: Authentication attempt without agent

A quick web search returned this page and all I needed to do is to add device to trusted devices. Run bluetoothctl and then enter trust XX:XX:XX:XX:XX:XX. Replace X'es with MAC address of your device. There is example in the link I provided also

You may have a different problem, but check your log files at least to see if your device is trying to connect. If it is trying to connect, you can also see some messages if you run bluetoothctl and wait. I kept seeing Connected: yes , no , yes , no... messages all the time. It was being disconnected because it was not a trusted device.

Related Question