Commit 1b83555d authored by Emil Gydesen's avatar Emil Gydesen Committed by Fabio Baltieri
Browse files

Samples: Bluetooth: CAP Initiator broadcast support



Add broadcast support to the CAP initiator 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.

This also moves common TX functionality
to cap_initiator_tx to reuse the same TX thread
and functionality.

Finally there is a babblesim implemented for
the broadcast. There is not broadcast support for the
CAP acceptor sample yet, so this test only verifies that we
get the TX complete events from the controller.

Signed-off-by: default avatarEmil Gydesen <emil.gydesen@nordicsemi.no>
parent 6211de87
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -6,7 +6,10 @@ project(cap_initiator)

target_sources(app PRIVATE
  src/main.c
  src/cap_initiator_unicast.c
  src/cap_initiator_tx.c
)

zephyr_sources_ifdef(CONFIG_SAMPLE_UNICAST src/cap_initiator_unicast.c)
zephyr_sources_ifdef(CONFIG_SAMPLE_BROADCAST src/cap_initiator_broadcast.c)

zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)
+28 −0
Original line number Diff line number Diff line
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

mainmenu "Bluetooth: Common Audio Profile initiator sample"

config SAMPLE_UNICAST
	bool "Whether or not to search for CAP acceptors for unicast audio"
	default y
	select BT_CENTRAL
	select BT_SMP
	select BT_KEYS_OVERWRITE_OLDEST
	select BT_CSIP_SET_COORDINATOR
	select BT_BAP_UNICAST_CLIENT
	select BT_CTLR_CENTRAL_ISO if BT_CTLR
	help
	  If set to true, the sample will start advertising connectable for
	  Broadcast Assistants.

config SAMPLE_BROADCAST
	bool "Whether or not to search for CAP acceptors for broadcast audio"
	default y if !SAMPLE_UNICAST
	select BT_BROADCASTER
	select BT_BAP_BROADCAST_SOURCE
	select BT_CTLR_ADV_ISO if BT_CTLR
	help
	  If set to true, the sample will start advertising syncable audio streams

source "Kconfig.zephyr"
+4 −2
Original line number Diff line number Diff line
@@ -2,13 +2,15 @@
   :name: Bluetooth: Common Audio Profile Initiator
   :relevant-api: bt_cap bt_bap bluetooth

   CAP Initiator sample that connects to CAP Acceptors and setup audio streaming.
   CAP Initiator sample that connects to CAP Acceptors and setup unicast audio streaming,
   or broadcast audio streams.

Overview
********

Application demonstrating the CAP Initiator functionality.
Starts by scanning for a CAP Acceptor and then connects to and sets up available streams.
Starts by either scanning for a CAP Acceptor and then connects to and sets up available unicast
audio streams, sets up a broadcast audio stream, or both.

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

+1 −3
Original line number Diff line number Diff line
@@ -3,9 +3,7 @@ CONFIG_BT_LL_SW_SPLIT=y

# Zephyr Controller tested maximum advertising data that can be set in a single HCI command
CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191

# Enable support for central ISO in Zephyr Bluetooth Controller
CONFIG_BT_CTLR_CENTRAL_ISO=y
CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=191

# Support the highest SDU size required by any BAP LC3 presets (155) + 8 bytes of HCI ISO Data
# packet overhead (the Packet_Sequence_Number, ISO_SDU_Length, Packet_Status_Flag fields; and
+8 −15
Original line number Diff line number Diff line
CONFIG_BT=y
CONFIG_LOG=y
CONFIG_BT_CENTRAL=y
CONFIG_MAIN_STACK_SIZE=2048

CONFIG_BT=y
CONFIG_BT_AUDIO=y
CONFIG_BT_EXT_ADV=y
CONFIG_BT_DEVICE_NAME="CAP Initiator"

CONFIG_BT_SMP=y
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y

# CAP support
CONFIG_BT_CAP_INITIATOR=y

# CSIP support
CONFIG_BT_CSIP_SET_COORDINATOR=y

# BAP support
CONFIG_BT_ISO_MAX_CHAN=2
CONFIG_BT_BAP_UNICAST_CLIENT=y

# Unicast client values if enabled by CONFIG_SAMPLE_UNICAST
CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT=2
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT=2
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT=2

# Controller configuration
CONFIG_BT_CTLR_CENTRAL_ISO=y

# Supports the highest SDU size required by any BAP LC3 presets (155)
CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=155
# Broadcast sources values if enabled by CONFIG_SAMPLE_BROADCAST
CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT=2
CONFIG_BT_BAP_BROADCAST_SRC_SUBGROUP_COUNT=1
Loading