Audio sharing is caring
Until recently, most generic Bluetooth enabled speakers and headsets have been using Bluetooth Classic. With the introduction of Bluetooth LE Audio, a wide new range of solutions become possible and one of the most exciting ones is the possibility to broadcast audio, where the sender and receiver are no longer required to be connected (like the 1-1 Bluetooth Classic case - e.g a phone and a headset).
"LE Audio introduces broadcast audio to Bluetooth® technology, a new feature that enables an audio transmitter to broadcast to an unlimited number of nearby Bluetooth audio receivers. Broadcast audio opens significant new opportunities for innovation, including a powerful new capability, Auracast™ broadcast audio.
Auracast™ broadcast audio is a set of defined configurations of Bluetooth® broadcast audio which are specified within the Public Broadcast Profile (PBP) specification that enables new, globally interoperable audio experiences for consumers."
Read more about Auracast here: https://www.bluetooth.com/auracast/developers/
Sharing Links to Broadcasts
Even though it is possible to scan for nearby broadcasts using a Broadcast Audio Assistant, sometimes, it will be more practical for users to 'tune in' to Broadcast sources using a trusted link provided through other means.
The Broadcast Audio URI is an exciting new spec that allows just that: Information about a Broadcast Audio Source to be conveyed over an out-of-band (OOB) medium to a Broadcast Audio Assistant - or, if the Broadcast Sink supports it, directly by e.g. touching an NFC tag, containing the Broadcast Audio URI, with a speaker or earbuds.
An example from the spec:
This includes all the information for a Broadcast Sink to find the right broadcast. The data in the QR code is this text:
BLUETOOTH:UUID:184F;BN:SG9ja2V5;SQ:1;AT:0;AD:AABBCC001122;AS:1;BI:DE51E9;PI:F
FFF;NS:1;BS:1;;
Which roughly translates to:
"Related to the 0x184F UUID (Broadcast Audio Scan Service), there is a Standard Quality mono channel broadcast at addresss AA:BB:CC:00:11:22 with Broadcast ID 0x0E51E9 and the Broadcast name 'Hockey'"
Zephyr for the win!
The Zephyr RTOS is a very powerful OS for embedded devices and it also includes support for LE Audio. If this is the first time you hear about it, please check some of my other posts on getting started with Zephyr, e.g. Getting started with Zephyr and Web Bluetooth
In the Zephyr repo, there is a Broadcast Audio Source sample that was used as a starting point.
There is also great support for different displays, which we will need to display the Broadcast Audio URI in a QR code.
To my happy surprise, there was already QR code support in the LVGL module included in Zephyr so I implemented some minimal QR-Code functionality to expose the required data once the Broadcast source was ready on the device. As this is a PoC, the non-changing parameters are hardcoded:
void gui_update_qr_code(const bt_addr_t *addr, uint32_t broadcast_id, uint8_t *name)
{
uint8_t addr_str[13];
uint8_t name_base64[128];
size_t name_base64_len;
/* Address */
snprintk(addr_str, sizeof(addr_str), "%02X%02X%02X%02X%02X%02X",
addr->val[5], addr->val[4], addr->val[3],
addr->val[2], addr->val[1], addr->val[0]);
/* Name */
base64_encode(name_base64, sizeof(name_base64), &name_base64_len, name, strlen(name));
name_base64[name_base64_len + 1] = 0;
/* Most fields hard coded for this demo */
snprintk(qr_data, sizeof(qr_data),
"BLUETOOTH:UUID:184F;BN:%s;SQ:1;AT:1;AD:%s;AS:0;BI:%06X;PI:FFFF;NS:1;BS:1;;",
name_base64, addr_str, broadcast_id);
lv_qrcode_update(qr_code, qr_data, strlen(qr_data));
lv_task_handler();
}
The result is here:
Try it out!
Put together, here is a PoC of how a Broadcast Audio URI can be used to expose a dynamically generated QR code on an nRF5340 Audio DK with a screen attached.
Hardware used:
The code is available here: https://github.com/larsgk/bau-source
Connecting the board to the USB port of any host device supporting USB Audio (Windows, Linux, Mac, Android, ChromeOS, etc), will automatically make the connected board a Broadcast Audio Source, streaming whatever is played on the host device. If you have access to one of the latest Samsung mobile phones and Galaxy Buds2 Pro, you should be able to find and select the broadcast and hear it in the earbuds.
See it in action
Currently, there are no implementations of the full Broadcast Audio URI flow in any device available on the market, so I have been using a dedicated web based stand-alone broadcast assistant application, modified to read and parse the Broadcast Audio URI QR code (this will be covered in a future post). It's using the BarcodeDetector API on supported devices to read the QR code.
It allows a user to scan a Broadcast Audio URI QR code and add it directly to an attached Broadcast Sink (e.g earbuds able to receive broadcasts, like the Samsung Galaxy Buds2 Pro).
The result is here:
Credits to Nick Hunn, Hai Shalom and others on doing great work on the Broadcast Audio URI