4

I'm trying to get two bluetooth speakers connected via the native bluetooth controller. The first one connects and plays audio just fine. The second one never connects.

Since I've searched and found some others are having an issue getting a single speaker working, allow me to explain the steps I took to achieve this:

Factory install raspbian jessie onto the raspberry pi 3. Run raspi-config in terminal and expand the filesystem, then reboot. Install pulseaudio bluetooth support via the following command.

sudo apt-get install pulseaudio-module-bluetooth

You may want to update apt-get first using the command:

sudo apt-get update

Restart the system. Once it reboots we will enter the bluetooth administration tool using the following command:

bluetoothctl

This will enter a bluetooth administration console. From here we can scan for our speaker and pair it. Pulseaudio must be running for this to work, but it will start by default after you install the packages above. From the bluetooth console run the following command:

scan on

After a bit you should see your speaker(s) listed. To pair and connect, issue the following commands:

trust 00:02:3C:45:05:E7
pair 00:02:3C:45:05:E7
connect 00:02:3C:45:05:E7

You may not need to issue the trust and pair commands, but several searches showed attempting those commands should any issues arise in pairing. If it still doesn't work make sure the pulseaudio daemon is running, and pulseaudio-module-bluetooth is installed.

After you are connected to the speaker you can exit by simply typing exit in the bluetooth console.

Now you can get your pulseaudio sinks by issuing the command:

pactl list sinks

You should see the speaker listed. You can use this information to configure other applications to route their audio through it. Also, if you install the graphical interface for pulseaudio then you can easily manage the devices for your main desktop, and route the audio from the graphical inteface to the bluetooth speaker. You install it via this command:

sudo apt-get install pavucontrol

You should see the option to manage pulse audio settings afterwards in the main raspbian menu on the desktop.

Now that we have gotten this far, my problem is I cannot connect to a second speaker when the first is connected. I am getting the following error:

Attempting to connect to 00:02:3C:45:05:E7
[CHG] Device 00:02:3C:45:05:E7 Connected: yes
Failed to connect: org.bluez.Error.Failed
[CHG] Device 00:02:3C:45:05:E7 Connected: no

A look into the system logs provide a little insight, but I haven't found much info on how to fix this error besides downgrading bluez which is a very undesirable fix.

 bluetoothd[670]: Unable to select SEP

So that's where I am right now. I'm unsure if the raspberry pi 3 onboard bluetooth interface can support multiple connections to speakers. Any help or nudge in the right direction would be greatly appreciated.

  • Did some more playing around. Seems like it's limited to a2dp sinks, I was able to connect to my smart phone while connected to a speaker. Perhaps the issue is related to pulseaudio rather than the bluez stack. I'll keep playing around with settings for a while before downgrading to bluez 4. – Brian Ge May 10 '16 at 18:42
  • So the developer of the latest Raspbian update commented that he does not believe pulseaudio + bluez will allow for more than one connection to be open at a time. I've had this working on bluez 4 using the ALSA plugin on OpenWRT, I'm going this route and will post the instructions to get it working if I can figure it out. I've got bluez 4 compiled and recognizing a USB bluetooth adapter, but not the onboard on, so there is some hope. – Brian Ge May 20 '16 at 22:31
3

I've got it working with a USB bluetooth dongle right now. Here's a general outline of what I did:

  1. Remove bluez 5 and pulseaudio with apt-get remove.
  2. Compile and install ALSA from source.
  3. Compile and install bluez 4.101 from source.
  4. Copy libasound_module_pcm_bluetooth.so to the folder: /usr/lib/arm-linux-gnueabihf/alsa-lib/ (used find -name to locate it)
  5. Install MPD and MPC.
  6. Configure /etc/mpd.conf, /etc/asound.conf, and /etc/bluetooth/audio.conf

That's it, it works after that but it doesn't recognize the onboard bluetooth adapter. I'm working on getting that working, probably will have to compile my own kernel if I can't get it working with packages. Also for now I am manually starting bluetoothd, this should be corrected but for now I'm going to focus on getting the onboard adapter recognized.

The mpd and asound configurations are well documented on setting up bluetooth, however the audio.conf file has one particular setting that may not be well know:

[A2DP]
SBCSources=20

This enables output to multiple bluetooth speakers.

EDIT- I got the onboard device working in a very hacky way. After doing the steps listed above I did the following:

  1. Install bluez 5 via sudo apt-get install bluez
  2. Manually kill hciattach via sudo killall -9 hciattach
  3. Run the following command: sudo /usr/bin/hciattach /dev/ttyAMA0 bcm43xx 921600 noflow -
  4. Remove bluez 5 via sudo apt-get remove bluez
  5. Pair the onboard adapter to the speakers via the python script simple-agent that's included under the tools folder of the bluez 4.101 source.

It will work, it plays audio through as multiple speakers via the onboard hardware, however restarting the system will break it. You will no longer be able to run the hciattach command referencing bcm43xx, this is due to the support being added in bluez 5. I'm currently tinkering with the source files to see if I can manually patch in support for the onboard hardware.

  • I wonder if building from sources is really necessary, considering that bluez5 is available in jessie-backports. It seems that what really makes a difference is the dongle you're using, so if you're still here, please specify which one it is. – Dmitry Grigoryev Apr 4 at 6:36
1

that's the old Philippine rice cook principle: one cook, one plate, one fireplace.

With other words:
Its not possible, its a principle of pairing: one sender one reciever

  • 1
    This is more or less correct. While pulseaudio only needs the one output (bluetooth), and a bluetooth master module can pair with multiple devices simultaneously, and the protocol has supported some form of multicasting for some time, searching online it seems this is not sufficient for true multiplexing of audio streams. – goldilocks Jun 13 '16 at 17:58
  • 1
    I just went digging a little further and it seems practically no one has applied bluetooth "multicasting" to audio even within the lucrative smartphone market -- so I'm editing my last comment and undeleting this. If you want to delete it again feel free, and all apologies for jumping the gun. :( Multiplexing and multicasting are subtly different concepts, was my mistake (the latter does not necessarily provide the former). – goldilocks Jun 13 '16 at 18:11
  • 1
    Multiplexing is a.f.a.i.k. the situation when you want to use in a optimal way the frequencies and multicasting is used with streaming when you send one package for every receiver. But I see problem if this is not realtime, because with multicasting its almost not possible to control when the package arrives. – Max Muster Jun 13 '16 at 18:41
  • What interesting is I was able to get this working on bluez4 with the ALSA plugin on OpenWRT. I had no issue pairing multiple bluetooth speakers and configuring the outputs in ALSA and MPD, each speaker had it's own MPD entry and it was able to send audio to multiple speakers connected to a single bluetooth dongle. – Brian Ge Jun 15 '16 at 15:51
  • I got it working with a usb adapter, it's using a single adapter for multiple speakers since the onboard one is no longer recognized when you downgrade to bluez 4.101. Once I get this onboard adapter recognized I'll post a full tutorial. I'm working headless for now so I don't know if this will remove the new bluetooth gui bult into rasbian's desktop or if it will break it. – Brian Ge Sep 8 '16 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.