BlueZ5 provides support for the core Bluetooth layers and protocols. It is flexible, efficient and uses a modular implementation. BlueZ5 has implemented the Bluetooth low level host stack for Bluetooth core specification 4.0 and 3.0+HS which includes GAP, L2CAP, RFCOMM, and SDP. Besides the host stack, BlueZ5 has also supported the following profiles itself or via a third party software.
BlueZ5 has been supported in the latest Freescale Linux BSP release, so it would be pretty easy to generate the binaries for Bluetooth core stack and its profiles. In order to support A2DP sink on a SabreSD board, the following software should be downloaded and installed onto the target rootfs too.
PulseAudio package has some dependencies with bluetooth and sbc packages, and pulseaudio will detect if the two packages have been built and then decide which pulse plugin modules to be generated. So the building order will be 1) bluez5_utils or bluez_utils 2) sbc 3) pulseaudio.
After compile and install the above software onto the target rootfs, you should be able to see the following executable under the directory /usr/bin
If the building dependency has been setup correctly, the following pulse plugin modules should be located under the directory /usr/lib/pulse-5.0/modules
Edit the file /etc/dbus-1/system.d/pulseaudio-system.conf, and add the following lines in red:
Edit the file /etc/dbus-1/system.d/bluetooth.conf, and add the following lines:
Adding the following settings at the bottom of the pulseaudio system configuration file which locates in /etc/pulse/system.pa
### Automatically load driver modules for Bluetooth hardware
load-module module-alsa-sink device_id=0 tsched=true tsched_buffer_size=1048576 tsched_buffer_watermark=262144
On the system that can automatically detect the alsa cards, the above line #13 should be removed.
Also make sure "auth-anonymous=1" is added to the following line, which can resolve the issue: "Denied access to client with invalid authorization data".
load-module module-native-protocol-unix auth-anonymous=1
Selecting a audio re-sampling algorithm and configuring the audio output by adding the following settings to the file daemon.conf locating in /etc/pulse
resample-method = trivial
enable-remixing = no
enable-lfe-remixing = no
default-sample-format = s16le
default-sample-rate = 48000
alternate-sample-rate = 24000
default-sample-channels = 2
Pulseaudio can be started as a daemon or as a system-wide instance. To run PulseAudio in system-wide mode, the program will automatically drop privileges from "root" and change to the "pulse" user and group. In this case, before launching the program, the "pulse" user and group needs to be created on the target system. In the example below, "/var/run/pulse" is the home directory for "pulse" user.
adduser -h /var/run/pulse pulse
adduser pulse pulse-access
Because PulseAudio needs to access the sound devices, add the user "pulse" to the "audio" group too.
adduser pulse audio
Starting bluetoothd and pulseaudio:
/usr/libexec/bluetooth/bluetoothd -d &
pulseaudio --system --realtime &
To verify if the pulseaudio has been set up correctly, you can play a local wave file by using the following command. If you can hear the sound, the system should have been configured correctly.
paplay -vvv audio8k16S.wav
After setting up the pulseaudio, launch bluetoothctl to pair and connect to a mobile phone. After connecting to a mobile phone, you should be able to see the following information in bluetoothctl console:
Name: BlueZ 5.21
Alias: BlueZ 5.21
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: Message Notification Se.. (00001133-0000-1000-8000-00805f9b34fb)
UUID: Message Access Server (00001132-0000-1000-8000-00805f9b34fb)
UUID: Phonebook Access Server (0000112f-0000-1000-8000-00805f9b34fb)
UUID: IrMC Sync (00001104-0000-1000-8000-00805f9b34fb)
UUID: OBEX File Transfer (00001106-0000-1000-8000-00805f9b34fb)
UUID: OBEX Object Push (00001105-0000-1000-8000-00805f9b34fb)
UUID: Vendor specific (00005005-0000-1000-8000-0002ee000001)
UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)
UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb)
If you can see the audio sink UUID, you are ready to enjoy the bluetooth music now.