Logo

dev-resources.site

for different kinds of informations.

Broadcast Audio URI

Published at
6/6/2024
Categories
leaudio
web
bluetooth
zephyr
Author
denladeside
Categories
4 categories in total
leaudio
open
web
open
bluetooth
open
zephyr
open
Author
11 person written this
denladeside
open
Broadcast Audio URI

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:

Image description

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;;
Enter fullscreen mode Exit fullscreen mode

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();
}
Enter fullscreen mode Exit fullscreen mode

The result is here:

Broadcast Audio URI QR code

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

Also, major credits to Emil Gydesen, maintainer of the LE Audio stack in Zephyr, that made this possible.

bluetooth Article's
30 articles in total
Favicon
Building a BLE Real-Time macOS Menu Bar App
Favicon
"Why is it, when something happens, it is always you TWO?"- troubleshooting Bluetooth and Wi-Fi devices on Debian 12
Favicon
🎉 The Fun Beginner’s Guide to Bluetooth on Void Linux 🎉
Favicon
Automated Session Control with Bluetooth: An Insight into ble-lock-session
Favicon
Capturing the perfect (radio) wave
Favicon
How the Web Bluetooth API Enhances Passkeys
Favicon
High-Power Bluetooth LE Modules and Their Applications
Favicon
Broadcast Audio URI
Favicon
What's the Difference of BLE Connection Roles: Central vs. Peripheral?
Favicon
Embedded Rust Bluetooth on ESP: BLE Scanner
Favicon
RF-star Introduces CC2642R-Q1 Automotive Grade BLE Module for PEPS, PaaK, and BMS
Favicon
How To Use The Web Bluetooth API
Favicon
Unraveling the Wonders of Bluetooth: Connecting the World Wirelessly
Favicon
Bluetooth Bring-Up in AOSP
Favicon
How to disable the Lock key on a non-Mac Bluetooth Keyboard
Favicon
Passkeys Bluetooth: Cross-Platform Authentication
Favicon
a2dp-sink profile Protocol not available
Favicon
Handling Bluetooth Programmatically on Windows
Favicon
Developing a Bluetooth Low energy-based application
Favicon
Interacting with Shimmer3 using Node SerialPort
Favicon
TOP 5 ALL-IN-ONE BEST PRINTERS & SCANNERS FOR 2023
Favicon
From PulseAudio to PipeWire
Favicon
Struggling to fix: Bluetooth connection failed: protocol not available?
Favicon
Bluetooth LE cihazlarla çalışma
Favicon
Demystifying machine learning via Bluetooth with Arduino
Favicon
Interacting with Polar Verity Sense using Web Bluetooth
Favicon
Hacking Nespresso Expert Machine To Brew Coffee Using Custom Applications Via Bluetooth
Favicon
A Rundown of IoT Communication Protocols — and Expert Tips for Choosing One for Your Project
Favicon
How to choose in your smart home,is Bluetooth, ZigBee, or WiFi
Favicon
Using Web Bluetooth in an Electron App in 2022

Featured ones: