https://forum.volumio.org/volumio-bluetooth-receiver-t8937.html
Install dependencies:
sudo apt-get update
sudo apt-get install wajig
wajig install dh-autoreconf libasound2-dev libortp-dev pi-bluetooth
wajig install libusb-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libsbc1 libsbc-dev
Compile Bluez 5.52:
git clone git://git.kernel.org/pub/scm/bluetooth/bluez.git
cd bluez
git checkout 5.52
./bootstrap
./configure --enable-library --enable-experimental --enable-tools
make
sudo make install
sudo ln -s /usr/local/lib/libbluetooth.so.3.19.0 /usr/lib/arm-linux-gnueabihf/libbluetooth.so
sudo ln -s /usr/local/lib/libbluetooth.so.3.19.0 /usr/lib/arm-linux-gnueabihf/libbluetooth.so.3
sudo ln -s /usr/local/lib/libbluetooth.so.3.19.0 /usr/lib/arm-linux-gnueabihf/libbluetooth.so.3.19.0
Compile Bluez-Alsa
cd ..
git clone https://github.com/Arkq/bluez-alsa.git
cd bluez-alsa
autoreconf --install
mkdir build && cd build
../configure --disable-hcitop --with-alsaplugindir=/usr/lib/arm-linux-gnueabihf/alsa-lib
make
sudo make install
Configure Bluetooth subsystem: Create file /etc/bluetooth/audio.conf
sudo nano /etc/bluetooth/audio.conf
add
[General]
Class = 0x20041C
Enable = Source,Sink,Media,Socket
Update file /etc/bluetooth/main.conf
sudo nano /etc/bluetooth/main.conf
add
[General]
Class = 0x20041C
Automate BluezAlsa: Set BlueAlsa as a service Create file /lib/systemd/system/bluealsa.service
sudo nano /lib/systemd/system/bluealsa.service
add
[Unit]
Description=BluezAlsa proxy
Requires=bluetooth.service
After=bluetooth.service
[Service]
Type=simple
User=root
Group=audio
ExecStart=/usr/bin/bluealsa --profile=a2dp-sink
[Install]
WantedBy=multi-user.target
Enable BluezAlsa starts from boot:
sudo systemctl daemon-reload
sudo systemctl enable bluealsa.service
Set bluealsa-aplay as a service:
Create file /lib/systemd/system/[email protected]
hw1:0 is the hifiberry audio device I want to use. Use aplay -l
to check.
There may be better way to link it.
sudo nano /lib/systemd/system/[email protected]
add
[Unit]
Description=BlueAlsa-Aplay %I -dhw:1,0
Requires=bluetooth.service bluealsa.service
[Service]
Type=simple
User=volumio
Group=audio
ExecStart=/usr/bin/bluealsa-aplay %I -dhw:1,0
[Install]
WantedBy=multi-user.target
Add UDEV rules Create file /etc/udev/rules.d/99-input.rules
sudo nano /etc/udev/rules.d/99-input.rules
add
KERNEL=="input[0-9]*", RUN+="/home/volumio/a2dp-autoconnect"
Tell Bluetooth how to create a bluetooth->Alsa connection: Create file /home/volumio/a2dp-autoconnect
nano /home/volumio/a2dp-autoconnect
add
#!/bin/bash
# at each BT connection/disconnection start/stop the service bluealsa-aplay
function log {
sudo echo "[$(date)]: $*" >> /var/log/a2dp-autoconnect
}
BTMAC=${NAME//\"/}
if [ `echo $BTMAC | egrep "^([0-9A-F]{2}:){5}[0-9A-F]{2}$"` ]
then
if [ $ACTION = "remove" ]
then
log "Stop Played Connection " $BTMAC
sudo systemctl stop bluealsa-aplay@$BTMAC
elif [ $ACTION = "add" ]
then
log "Start Played Connection " $BTMAC
sudo systemctl start bluealsa-aplay@$BTMAC
else
log "Other action " $ACTION
fi
fi
Set the right access permissions:
sudo chmod a+rwx /home/volumio/a2dp-autoconnect
sudo touch /var/log/a2dp-autoconnect
sudo chmod a+rw /var/log/a2dp-autoconnect
REBOOT
After reboot, use bluetoothctl to connect to your bluetooth music source:
sudo bluetoothctl
# power on
# agent on
# default-agent
# scan on => xx:xx of your device
# pair xx:xx
# trust xx:xx
# exit
On your mobile, connect volumio. Should work. Once the device is connected you should be able to play something ...
Checking To check if the services are all up and running: $ systemctl | grep blue You should get something like that:
systemctl | grep blue
sys-devices-platform-soc-3f980000.usb-usb1-1\x2d1-1\x2d1.2-1\x2d1.2:1.0-bluetooth-hci0-rfkill0.device loaded active plugged /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/bluetooth/hci0/rfkill0
sys-devices-platform-soc-3f980000.usb-usb1-1\x2d1-1\x2d1.2-1\x2d1.2:1.0-bluetooth-hci0.device loaded active plugged /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/bluetooth/hci0
sys-subsystem-bluetooth-devices-hci0.device loaded active plugged /sys/subsystem/bluetooth/devices/hci0
bluealsa.service loaded active running BluezAlsa proxy
bluetooth.service loaded active running Bluetooth service
bluetooth.target loaded active active Bluetooth
Great tutorial! I had to change "/usr/bin/bluealsa-aplay %I -dhw:1,0" to "/usr/bin/bluealsa-aplay %I -D hw:1,0" in /lib/systemd/system/[email protected] to get it working, but otherwise good stuff.