This guide is a draft copy of how to setup your Raspberry Pi as a Bluetooth speaker. The following instructions were tested using the JustBoom DAC HAT and a Raspberry Pi 3B+ with the latest version of Raspbian OS.
Launch the BlueZ command line interface:
Setup a pairing agent:
agent on default-agent
Make the Raspberry Pi discoverable:
On your phone (Bluetooth device) search and select your Raspberry Pi from the Bluetooth menu. Confirm the pairing on both your phone and the Raspberry Pi:
Request confirmation [agent] Confirm passkey 123456 (yes/no): yes
Authorize A2DP service:
Authorize service [agent] Authorize service 0000110d-0000-1000-8000-00805f9b34fb (yes/no): yes
Note: If asked about other services simply enter “yes”
Trust the phone (device) so that the Raspberry Pi will automatically accept connection from the phone next time it connects:
Note: Replace xx:xx:xx:xx:xx:xx with your phones device address which will be displayed when authorizing a service. [CHG] Device 24:4B:81:BC:36:1E
Exit from BlueZ command line interface:
Forward audio from the phone to the Raspberry Pi’s output:
sudo bluealsa-aplay -d hw 00:00:00:00:00:00
Launch a media/music player from your phone(device) and play some music or a video. You should hear the music from the Raspberry Pi/JustBoom HAT output.
Note: When you disconnect the Bluetooth from either device and then re-connect again you will need to forward the audio routing each time.
There is a possible issue where the audio cuts out and this is due to the on-board WI-Fi. Yet to confirm this and experience it.