-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bluetooth: Audio: Add implementation for PBP and 2 sample applications.
PBP API allows sources to create a Public Broadcast Announcement. PBP API allows sinks to scan for a Public Broadcast Announcement which fulfills some given requirements. public_broadcast_source application starts extended advertising and includes a Public Broadcast Announcement. The advertised broadcast audio stream quality will cycle between high and standard quality. public_broadcast_sink application scans for broadcast sources and synchronizes to the first found source which defines a Public Broadcast Announcement including a High Quality Public Broadcast Audio Stream configuration. Add bsim tests for Public Broadcast Profile APIs. Signed-off-by: Daniela Andreea Dumitrache <[email protected]>
- Loading branch information
1 parent
dbb0b30
commit 265b80e
Showing
24 changed files
with
2,263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright 2023 NXP | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PBP_ | ||
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PBP_ | ||
|
||
#include <zephyr/sys/util.h> | ||
|
||
#include <zephyr/bluetooth/audio/audio.h> | ||
|
||
/** @brief PBP Roles */ | ||
enum bt_pbp_role { | ||
BT_PBP_ROLE_PBS = BIT(0), /* Public Broadcast Source */ | ||
BT_PBP_ROLE_PBK = BIT(1), /* Public Broadcast Sink */ | ||
BT_PBP_ROLE_PBA = BIT(2), /* Public Broadcast Assistant */ | ||
}; | ||
|
||
enum bt_pbp_encryption { | ||
BT_PBP_STREAMS_NOT_ENCRYPTED = 0, | ||
BT_PBP_STREAMS_ENCRYPTED = 1, | ||
}; | ||
|
||
enum bt_pbp_quality { | ||
BT_PBP_AUDIO_CONFIG_NOT_PRESENT = 0, | ||
BT_PBP_AUDIO_CONFIG_PRESENT = 1, | ||
}; | ||
|
||
enum bt_pbp_announcement_features { | ||
BT_PBP_ANNOUNCEMENT_FEATURE_ENCRYPTION = BIT(0), | ||
BT_PBP_ANNOUNCEMENT_FEATURE_STANDARD_QUALITY = BIT(1), | ||
BT_PBP_ANNOUNCEMENT_FEATURE_HIGH_QUALITY = BIT(2), | ||
}; | ||
|
||
/** | ||
* @brief Sets the received PBP role(s) and Public Broadcast Announcement features. | ||
* | ||
* @param role PBP role(s) of the device (one or multiple). | ||
* @param pba_params Public Broadcast Announcement features | ||
* | ||
*/ | ||
void bt_pbp_init_source(enum bt_pbp_role role, uint8_t pba_params); | ||
|
||
/** | ||
* @brief Sets the received PBP role(s). | ||
* | ||
* @param role PBP role(s) of the device (one or multiple). | ||
* | ||
*/ | ||
void bt_pbp_set_role(enum bt_pbp_role role); | ||
|
||
/** | ||
* @brief Creates a Public Broadcast Announcement based on the information received | ||
* in bt_pbp_init_source(). | ||
* | ||
* @param meta_count Number of metadata fields to be included in the advertising data | ||
* @param meta Metadata to be included in the advertising data | ||
* @param bba_adv_data Advertising data structure to include the Public Broadcast Announcement | ||
* | ||
* @return 0 on success or an appropriate error code. | ||
*/ | ||
int bt_pbp_create_public_broadcast_announcement(size_t meta_count, | ||
const struct bt_audio_codec_data meta[], struct bt_data *pba_adv_data); | ||
|
||
/** | ||
* @brief Parses the received advertising data and looks for the Public Broadcast | ||
* Announcement Service UUID. If found, it checks the received stream configuration | ||
* preferences against the ones advertised by the source. | ||
* | ||
* @param ad Advertising data to be checked | ||
* @param sink_config_preferences Sink stream configuration preferences | ||
* | ||
* @return true if the stream fits the sink's preferences, false otherwise | ||
*/ | ||
bool bt_pbp_parse_public_broadcast_announcement(struct bt_data *ad, | ||
uint8_t sink_config_preferences); | ||
|
||
/** | ||
* @brief Clear the data previously set for a Public Broadcast Announcement. | ||
*/ | ||
void bt_pbp_clear_data_buffer(void); | ||
|
||
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PBP_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(pbp_broadcast_sink) | ||
|
||
target_sources(app PRIVATE | ||
src/main.c | ||
src/bap_broadcast_sink.c | ||
) | ||
|
||
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.. _bluetooth_public_broadcast_sink: | ||
|
||
Bluetooth: Public Broadcast Sink | ||
################################ | ||
|
||
Overview | ||
******** | ||
|
||
Application demonstrating the LE Public Broadcast Profile sink functionality. | ||
Starts by scanning for LE Audio broadcast sources and then synchronizes to | ||
the first found source which defines a Public Broadcast Announcement including | ||
a High Quality Public Broadcast Audio Stream configuration. | ||
|
||
Requirements | ||
************ | ||
|
||
* A board with Bluetooth Low Energy 5.2 support | ||
|
||
Building and Running | ||
******************** | ||
This sample can be found under | ||
:zephyr_file:`samples/bluetooth/public_broadcast_sink` in the Zephyr tree. | ||
|
||
See :ref:`bluetooth samples section <bluetooth-samples>` for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
CONFIG_BT=y | ||
CONFIG_LOG=y | ||
CONFIG_BT_PAC_SNK=y | ||
CONFIG_BT_PERIPHERAL=y | ||
CONFIG_BT_AUDIO=y | ||
CONFIG_UTF8=y | ||
|
||
CONFIG_BT_SMP=y | ||
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y | ||
CONFIG_BT_L2CAP_TX_BUF_COUNT=20 | ||
|
||
# CAP | ||
CONFIG_BT_CAP_ACCEPTOR=y | ||
|
||
# BAP support | ||
CONFIG_BT_BAP_SCAN_DELEGATOR=y | ||
CONFIG_BT_BAP_BROADCAST_SINK=y | ||
CONFIG_BT_BAP_BROADCAST_SNK_SUBGROUP_COUNT=1 | ||
CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT=1 | ||
|
||
# Support an ISO channel per ASE | ||
CONFIG_BT_ISO_MAX_CHAN=2 | ||
|
||
# Sink PAC Location Support | ||
CONFIG_BT_PAC_SNK_LOC=y | ||
|
||
# Generic config | ||
CONFIG_BT_EXT_ADV=y | ||
CONFIG_BT_DEVICE_NAME="PBP Broadcast Sink" | ||
|
||
# PBP Support | ||
CONFIG_BT_PBP=y | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
sample: | ||
description: Bluetooth Low Energy Audio PBP Broadcast Sink sample | ||
name: Bluetooth Low Energy Audio PBP Broadcast Sink sample | ||
tests: | ||
sample.bluetooth.public_broadcast_sink: | ||
harness: bluetooth | ||
platform_allow: | ||
- qemu_cortex_m3 | ||
- qemu_x86 | ||
- nrf5340dk_nrf5340_cpuapp | ||
integration_platforms: | ||
- qemu_x86 | ||
- nrf5340dk_nrf5340_cpuapp | ||
tags: bluetooth | ||
|
||
Oops, something went wrong.