Add user pi to bluetooth group
sudo adduser pi bluetooth
newgrp bluetooth
Change capabilities of bluetooth-service (/lib/systemd/system/bluetooth.service) add CAP_NET_RAW
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
Install bluealsa
sudo apt-get install bluealsa
Restart system. Afterwards connecting to a Bluetooth device is possible via:
bluetoothctl
scan on
pair X:X:X:X
trust X:X:X:X
connect X:X:X:X
scan off
exit
To enable an autoreconnect of a specific device on each reboot do sudo crontab -e and add
@reboot sleep 15 && /bin/echo -e 'connect X:X:X:X \n quit \n' | bluetoothctl
Download example file and test if playing audio is working
wget http://www.music.helsinki.fi/tmt/opetus/uusmedia/esim/a2002011001-e02.wav
aplay -D bluealsa:HCI=hci0,DEV=X:X:X:X,PROFILE=a2dp a2002011001-e02.wav
See https://github.com/davidedg/NAS-mod-config/blob/master/bt-sound/bt-sound-Bluez5_PulseAudio5.txt#L121 Install pulseaudio
sudo apt-get install pulseaudio pulseaudio-module-bluetooth pulseaudio-module-zeroconf
Add pi-user to pulseaudio groups
sudo adduser pi pulse
sudo adduser pi pulse-access
Edit /etc/dbus-1/system.d/pulseaudio-system.conf
<busconfig>
<policy user="pulse">
<allow send_destination="org.bluez"/>
</policy>
</busconfig>
Edit /etc/pulse/system.pa add
### Bluetooth Support
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif
Create /etc/systemd/system/pulseaudio.service
[Unit]
Description=Pulse Audio
[Service]
Type=simple
ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm --exit-idle-time=-1
[Install]
WantedBy=multi-user.target
Enable service
sudo systemctl daemon-reload
sudo systemctl enable pulseaudio.service
Maybe restarting is also required here. Afterwards again connect to the bluetooth device and try
aplay a2002011001-e02.wav
sudo apt-get install linphone
Start linphone-console and register client and set soundcard
linphonec
linphonec> register sip:<address>@<server> <server> <password>
linphonec> soundcard list
0: ALSA: default device
1: ALSA: bcm2835 ALSA
2: PulseAudio: default
linphonec> soundcard use 2