Tuesday, November 5, 2013

Bluetooth headphones on Arch: a new twist in the saga

As of a few days ago the official blueman build for Arch switched from depending on bluez4 to bluez (which is to say, bluez5). If you missed my previous post, I already had gotten my bluetooth headphones working pretty well with bluez4, ALSA and blueman. This new update broke my setup, and sent me on my way to new adventures in bluezland(TM).

I haven't gotten much to work yet. I'm sorry. But as I get things working I'll update this post. This is what I've done:

Tue Nov 5 11:51:07 CST 2013
I updated my system and everything was "broken". I sent a few bug reports, posted a few things on Arch forums, the usual. There are a few problems, and I'll describe them as best I can. First off, bluez5 dropped ALSA support, so I had to install pulseaudio-git from the AUR, since the official repo version of pulseaudio does not yet have bluez5 support. Then there's the issue that blueman-manager and blueman-applet won't work anymore, they just error out with a dbus error that seems to indicate (to my limited knowledge) that they were not properly updated to the new bluez5 API. So I turned to knowledge gleaned from recent edits of the Arch Wiki and tried to use the new command like tool that comes with bluez5, bluetoothctl. At first, this looks awesome. It has its own little shell, color output and everything. The main problem is that it doesn't really work. I can't use it to pair my headphones, and I can't use it to connect to them. The errors a terse, to say the least. So I looked for another alternative and tried using gnome-bluetooth, which is what most people use, I think. The problem with gnome-bluetooth is that, unless you're running gnome, it doesn't come with a system tray applet anymore, so there is no way to connect to your device. This is what I ended up doing: 1. install gnome-bluetooth; 2. run bluetoothctl and remove your device from the list, if it is there; 4. install and run pulseaudio; 3. run bluetooth-wizard and pair with your device, it will also autoconnect and it should now work (test with running speaker-test). The one issue I ran into is turning the headphones off and back on. They will not automatically reconnect they way they did under blueman. Instead, it seems to work to go into bluetoothctl and manually connect (see image).
The other problem is a lack of control over the bitpool rate (maybe there's a way, but I don't know it yet) so every once in a while the sound gets chopped up and dropped.

Mon Nov 18 13:26:28 CST 2013
I managed to figure out how to only use bluetoothctl for pairing and connecting, so that I don't have to rely on gnome-bluetooth any longer. The trick was to turn the agent on before trying to pair. Note that tab completion works inside bluetoothctl, so all these calls are pretty easy to make.
# bluetoothctl
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# scan on
Discovery started
[CHG] Controller 00:13:46:4D:6A:C6 Discovering: yes
[NEW] Device 00:1D:BA:29:50:D3 DR-BT50
[bluetooth]# pair 00:1D:BA:29:50:D3
Attempting to pair with 00:1D:BA:29:50:D3
[CHG] Device 00:1D:BA:29:50:D3 Connected: yes
[CHG] Device 00:1D:BA:29:50:D3 Paired: yes
Pairing successful
[CHG] Device 00:1D:BA:29:50:D3 Connected: no
[bluetooth]# connect 00:1D:BA:29:50:D3
Attempting to connect to 00:1D:BA:29:50:D3
[CHG] Device 00:1D:BA:29:50:D3 Connected: yes
Connection successful
[bluetooth]# scan off
Discovery stopped
[CHG] Controller 00:13:46:4D:6A:C6 Discovering: no
[bluetooth]# exit