Skip to content

Commit

Permalink
samples: Add Broadcast Assistant sample
Browse files Browse the repository at this point in the history
First version of Broadcast Assistant sample
with hard coded selection of sink and source.

Signed-off-by: Lars Knudsen <[email protected]>
  • Loading branch information
larsgk committed Jan 29, 2024
1 parent c9208b3 commit 38af85b
Show file tree
Hide file tree
Showing 7 changed files with 496 additions and 0 deletions.
11 changes: 11 additions & 0 deletions samples/bluetooth/broadcast_assistant/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(broadcast_assistant)

target_sources(app PRIVATE
src/main.c
)

zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
24 changes: 24 additions & 0 deletions samples/bluetooth/broadcast_assistant/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2024 Demant A/S
# SPDX-License-Identifier: Apache-2.0

mainmenu "Bluetooth: Broadcast Assistant"

config SELECT_SOURCE_NAME
string "Selected Broadcast Source name"
default "Broadcast Audio Source"
help
Name of broadcast source device to select. This will be used as a
substring match against both BT device name and broadcast name.
If empty, the first broadcast source found will be chosen.
Matching is not case sensitive.

config SELECT_SINK_NAME
string "Selected Broadcast Sink name"
default "Broadcast Audio Sink"
help
Name of broadcast sink device to select. This will be used as a
substring match against the BT device name.
If empty, the first broadcast sink found will be chosen.
Matching is not case sensitive.

source "Kconfig.zephyr"
50 changes: 50 additions & 0 deletions samples/bluetooth/broadcast_assistant/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.. zephyr:code-sample:: bluetooth_broadcast_assistant
:name: Bluetooth: Broadcast Assistant
:relevant-api: bt_bap

Bluetooth: Broadcast Assistant

Overview
********

Application demonstrating the LE Audio broadcast assistant functionality.

The sample will automatically try to connect to the Broadcast Audio Scan Service (BASS)
on a preconfigured broadcast sink. It will then search for a specific broadcast source and
(if found) add the broadcast ID to the BASS.

This sample can be found under
:zephyr_file:`samples/bluetooth/broadcast_assistant` in the Zephyr tree.

Check the :ref:`bluetooth samples section <bluetooth-samples>` for general information.

Requirements
************

* BlueZ running on the host, or
* A board with Bluetooth Low Energy 5.2 support

Building and Running
********************

The application will act as a Broadcast Assistant with preconfigured selection
of Broadcast Sink and Broadcast Source names. By default, the application will
search for the bluetooth audio sink (:zephyr_file:`samples/bluetooth/broadcast_audio_sink`)
and bluetooth audio source (:zephyr_file:`samples/bluetooth/broadcast_audio_source`) samples
with their respective default names.

Customize this by modifying the following configs:

``CONFIG_SELECT_SINK_NAME``: Substring of BT name of the sink.

and

``CONFIG_SELECT_SOURCE_NAME``: Substring of BT name or broadcast name of the source.

Building for an nrf52840dk
--------------------------

.. zephyr-app-commands::
:zephyr-app: samples/bluetooth/broadcast_assistant/
:board: nrf52840dk_nrf52840
:goals: build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191
12 changes: 12 additions & 0 deletions samples/bluetooth/broadcast_assistant/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CONFIG_BT=y
CONFIG_LOG=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_AUDIO=y
CONFIG_BT_SMP=y
CONFIG_BT_BUF_ACL_RX_SIZE=255
CONFIG_BT_BUF_ACL_TX_SIZE=251

CONFIG_BT_TINYCRYPT_ECC=y

CONFIG_BT_EXT_ADV=y
CONFIG_BT_BAP_BROADCAST_ASSISTANT=y
11 changes: 11 additions & 0 deletions samples/bluetooth/broadcast_assistant/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sample:
description: Bluetooth Low Energy Broadcast Assistant sample
name: Bluetooth Low Energy Broadcast Assistant sample
tests:
sample.bluetooth.broadcast_assistant:
harness: bluetooth
platform_allow:
- nrf52840dk_nrf52840
integration_platforms:
- nrf52840dk_nrf52840
tags: bluetooth
Loading

0 comments on commit 38af85b

Please sign in to comment.