As part of this blog post, the idea is to connect  the Beaglebone Wireless to a bluetooth speaker, so that I can play music via bluetooth, but the idea as part of the bluetooth maze project is to have music play via the Beaglebone Wireless via a USB connected to sound card from using their APIs, and some local music stored on the SD card connected to the Beaglebone.   Now since the theme of this challenge is "Bluetooth Unleashed" , I wanted to try and checkout how easy it was to connect to the a bluetooth speaker to my 'Hero board the Beaglebone Black Wireless.

Here are the steps, and some screenshots, if you are interested in following along, in my case I am using a Vivitar Bluetooth Wireless Speaker .


Once you have SSH'ed into your Beaglebone and connected to WiFi router, or connected to terminal via the cloud9 IDE ( ) , run the following commands


apt-get update
apt-get install -y pulseaudio pulseaudio-module-bluetooth
gpasswd -a root pulse-access


Then switch on your speaker, and check the led sequence to ensure that it is in discovery mode, and run the following commands


scan on
agent on


Now make a note of the device address, which in my case is 00:25:DB:14:53:30 for the speaker, replace this with your device id.

pair 00:25:DB:14:53:30
connect 00:25:DB:14:53:30
trust 00:25:DB:14:53:30


Add the following to the end of the file using-  nano /etc/dbus-1/system.conf


  <policy user="root">
  <allow own="org.pulseaudio.Server"/>
  <allow send_destination="org.bluez"/>
  <allow send_interface="org.bluez.Manager"/>
  <policy user="pulse">
  <allow own="org.pulseaudio.Server"/>
  <allow send_destination="org.bluez"/>
  <allow send_interface="org.bluez.Manager"/>
  <policy context="default">
  <deny own="org.pulseaudio.Server"/>
  <deny send_destination="org.bluez"/>
  <deny send_interface="org.bluez.Manager"/>


once you save and exit the file, restart the Beaglebone wireless so that the changes can take effect using the command - reboot


After reboot is done, run the following commands

LANG=C pulseaudio -vvvv --log-time=1 -D --system --disallow-exit --disable-shm
pactl load-module module-bluetooth-policy
pactl load-module module-bluetooth-discover
echo connect 0A:EC:12:01:02:A9 | bluetoothctl
pactl set-default-sink bluez_sink.00_25_DB_14_53_30 


And then to play sample wav file that comes as part of alsa

aplay /usr/share/sounds/alsa/Front_Center.wav

If you think the volume is too loud use the command - alsamixer , to reduce the volume

Just in case you face an issue were you are not able to here sound out of your speaker, and to check if pactl has setup your speaker as the default output , run the following command as shown in the screenshot above.

pactl stat | grep -i "Default Sink:"