Create a gist now

Instantly share code, notes, and snippets.

@jadonk /README.md
Last active Jan 4, 2017

What would you like to do?
Setup a Bluetooth speaker on BeagleBone Blue

You'll need to discover the Bluetooth ID of your speaker. In my case, it was 0A:EC:12:01:02:A9. Adjust the scripts below accordingly.

Initial setup:

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

Startup 'bluetoothctl' while the speaker is in discovery mode and do:

scan on
agent on
default-agent
pair 0A:EC:12:01:02:A9
connect 0A:EC:12:01:02:A9
trust 0A:EC:12:01:02:A9

Replace the last line in /etc/dbus-1/system.conf with:

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

Then reboot.

After each boot:

# Load the PulseAudio audio manager and load Bluetooth modules
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
# Trigger the Bluetooth connection
echo connect 0A:EC:12:01:02:A9 | bluetoothctl
# Set the Bluetooth speaker to be the default output
pactl set-default-sink bluez_sink.0A_EC_12_01_02_A9
# Play a sound
aplay /usr/share/sounds/alsa/Front_Center.wav    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment