Skip to content

Commit d578c59

Browse files
Thalleyaescolar
authored andcommitted
Samples: Bluetooth: CAP Acceptor broadcast support
Add broadcast support for the CAP acceptor sample. This adds new sample-specific Kconfig options to help select the right Kconfig options based on whether unicast, broadcast or both is being used. The babblesim implemented for the broadcast has been expanded to verify that the CAP acceptor receives the broadcast audio. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 2af4ae1 commit d578c59

File tree

15 files changed

+912
-41
lines changed

15 files changed

+912
-41
lines changed

samples/bluetooth/cap_acceptor/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ project(cap_acceptor)
66

77
target_sources(app PRIVATE
88
src/main.c
9-
src/cap_acceptor_unicast.c
109
)
1110

11+
zephyr_sources_ifdef(CONFIG_SAMPLE_UNICAST src/cap_acceptor_unicast.c)
12+
zephyr_sources_ifdef(CONFIG_SAMPLE_BROADCAST src/cap_acceptor_broadcast.c)
13+
1214
zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2022 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
mainmenu "Bluetooth: Common Audio Profile Acceptor sample"
5+
6+
config SAMPLE_UNICAST
7+
bool "Whether or not to search for CAP acceptors for unicast audio"
8+
default y
9+
select BT_BAP_UNICAST_SERVER
10+
select BT_ISO_PERIPHERAL
11+
select BT_ASCS
12+
select BT_PAC_SNK
13+
select BT_PAC_SNK_LOC
14+
select BT_PAC_SRC
15+
select BT_PAC_SRC_LOC
16+
select BT_CTLR_PERIPHERAL_ISO if BT_CTLR
17+
help
18+
If set to true, the sample will start advertising connectable for
19+
Broadcast Assistants.
20+
21+
config SAMPLE_BROADCAST
22+
bool "Whether or not to search for CAP acceptors for unicast audio"
23+
default y if !SAMPLE_UNICAST
24+
select BT_ISO_SYNC_RECEIVER
25+
select BT_BAP_SCAN_DELEGATOR
26+
select BT_BAP_BROADCAST_SINK
27+
select BT_PAC_SNK
28+
select BT_PAC_SNK_LOC
29+
select BT_PER_ADV_SYNC_TRANSFER_RECEIVER if !BT_CTLR || BT_CTLR_SYNC_TRANSFER_RECEIVER_SUPPORT
30+
select BT_CTLR_SYNC_ISO if BT_CTLR
31+
help
32+
If set to true, the sample will start advertising syncable audio streams
33+
34+
config SAMPLE_SCAN_SELF
35+
bool "Whether to scan for Broadcast Sources without Broadcast Assistant"
36+
depends on SAMPLE_BROADCAST
37+
help
38+
If set to true, the sample will start scanning for Broadcast Sources
39+
without waiting for a Broadcast Assistant to connect.
40+
41+
config SAMPLE_TARGET_BROADCAST_NAME
42+
string "Target Broadcast Device Name when self-scanning"
43+
default ""
44+
help
45+
Name of target broadcast device. If not empty string, sink device
46+
will only listen to the specified broadcast source. Not case sensitive.
47+
48+
source "Kconfig.zephyr"

samples/bluetooth/cap_acceptor/README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Overview
99

1010
Application demonstrating the CAP Acceptor functionality.
1111
Starts by advertising for a CAP Initiator to connect and set up available streams.
12+
It can also be configured to start scanning for broadcast audio streams by itself.
1213

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

samples/bluetooth/cap_acceptor/overlay-bt_ll_sw_split.conf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
CONFIG_BT_LL_SW_SPLIT=y
33

44
# Zephyr Controller tested maximum advertising data that can be set in a single HCI command
5+
CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191
56
CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=191
67

7-
# Enable support for central ISO in Zephyr Bluetooth Controller
8-
CONFIG_BT_CTLR_PERIPHERAL_ISO=y
9-
108
# Support the highest SDU size required by any BAP LC3 presets (155) + 8 bytes of HCI ISO Data
119
# packet overhead (the Packet_Sequence_Number, ISO_SDU_Length, Packet_Status_Flag fields; and
1210
# the optional Time_Stamp field, if supplied)
Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
CONFIG_BT=y
22
CONFIG_LOG=y
33
CONFIG_BT_PERIPHERAL=y
4-
CONFIG_BT_ISO_PERIPHERAL=y
5-
CONFIG_BT_GATT_DYNAMIC_DB=y
64
CONFIG_BT_GATT_CLIENT=y
75
CONFIG_BT_EXT_ADV=y
86
CONFIG_BT_DEVICE_NAME="CAP Acceptor"
9-
107
CONFIG_BT_AUDIO=y
11-
128
CONFIG_BT_SMP=y
139
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
1410

1511
# CAP
1612
CONFIG_BT_CAP_ACCEPTOR=y
1713

18-
# BAP support
19-
CONFIG_BT_BAP_UNICAST_SERVER=y
20-
2114
# Mandatory to support at least 1 for ASCS
2215
CONFIG_BT_ATT_PREPARE_COUNT=1
2316

@@ -28,9 +21,3 @@ CONFIG_BT_ASCS_MAX_ASE_SRC_COUNT=1
2821

2922
# Support an ISO channel per ASE
3023
CONFIG_BT_ISO_MAX_CHAN=2
31-
32-
# PACS
33-
CONFIG_BT_PAC_SNK=y
34-
CONFIG_BT_PAC_SNK_LOC=y
35-
CONFIG_BT_PAC_SRC=y
36-
CONFIG_BT_PAC_SRC_LOC=y

samples/bluetooth/cap_acceptor/src/cap_acceptor.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ struct peer_config {
3838
*/
3939
int init_cap_acceptor_unicast(struct peer_config *peer);
4040

41+
/**
42+
* @brief Initialize the unicast part of the CAP Acceptor
43+
*
44+
* @retval 0 if success
45+
* @retval -ENOEXEC if callbacks failed to be registered
46+
*/
47+
int init_cap_acceptor_broadcast(void);
48+
4149
/**
4250
* @brief Request to allocate a CAP stream
4351
*

0 commit comments

Comments
 (0)