Bluetooth and pulseaudio on RPI3

Hi,
I am a bit struggling with getting bluetooth and a2dp running properly. I have a hard time understanding where I should pair my devices and how I can make my pulseaudio container see the bluetooth sink.

I am currently trying to run bluetoothctl in the host os to pair, but I’m failing to connect to the device (a bluetooth speaker) after a successful pairing. The error message is

[bluetooth]# connect B3:63:99:47:C6:CA
Attempting to connect to B3:63:99:47:C6:CA
Failed to connect: org.bluez.Error.Failed

Trying to run bluetoothctl in the container where I have pulseaudio installed results in a timeout waiting to connect to the bluetoothd daemon (which AFAIK is running directly in the host).

bash-4.4# bluetoothctl
Waiting to connect to bluetoothd...

I have been trying both with a single container as well as with a multi container setup using docker-compose.

Any pointers on this? It seems that most of the example projects and documentation I can find is outdated.

Hi,

Are you sure this issue is specific for the balenaOS ?
I see that you have tried it in the host os.
Did you try the same thing on a raspberry pi with raspbian installed and did the command work in that case ?

kr
Jan.

Hi @par.degerman, looking at bluetooth, it should be available to all containers over dbus that needs some settings:

Are you setting up a multicontainer project, or using docker-compose.yml in general? If yes:

  • either the service is privileged
  • or, add this label io.resin.features.dbus = '1' to the given service (from 2.26.0 onwards it will be io.balena.features.dbus, but this change is backwards compatible, can keep the first one for a while)

If you are using a single Dockerfile/Dockerfile.template, that should be privileged already, only need the next steps:

Then set the system dbus address, for example

export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket

and after that bluetoothctl should behave correctly in my experience. I’ve checked in terms of scanning and finding devices, but since that works, connection would do as well.

Let us know what do you think based on this!

Thanks this helped me solve the issue I had. I also switched from pulseaudio to bluetooth alsa backend (https://github.com/Arkq/bluez-alsa).
Works like a charm now!

I’m still tweaking the final build, but I will push it to github (https://github.com/pardegerman/audio-streamer) once it’s in a working state. Thanks for the help!

1 Like

Could you share your solution? I was trying to do something similar

1 Like