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.

Brian Ge
  • 81
  • 1
  • 1
  • 10

2 Answers2

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.

Brian Ge
  • 81
  • 1
  • 1
  • 10
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

Max Muster
  • 174
  • 1
  • 10