Commit 240749c7 authored by Emil Gydesen's avatar Emil Gydesen Committed by Benjamin Cabé
Browse files

tests: Bluetooth: CAP: Add bcast reception with multiple acceptors

Expand the CAP broadcast reception test to also run with
multiple acceptors to better verify correctness in the
procedures.

For this to run more stable, the maximum number of streams
has been reduce to 2, rather than
CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT.

Signed-off-by: default avatarEmil Gydesen <emil.gydesen@nordicsemi.no>
parent e96bf44d
Loading
Loading
Loading
Loading
+7 −7
Changes for tests/bsim/bluetooth/audio/src/cap_commander_test.c: 7 added lines, 7 removed lines.
Original line number Diff line number Diff line
/*
 * Copyright (c) 2023 Nordic Semiconductor ASA
 * Copyright (c) 2023-2025 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */
@@ -771,12 +771,6 @@ static void discover_bass(size_t acceptor_cnt)
{
	k_sem_reset(&sem_bass_discovered);

	if (acceptor_cnt > 1) {
		FAIL("Current implementation does not support multiple connections for the "
		     "broadcast assistant");
		return;
	}

	for (size_t i = 0U; i < acceptor_cnt; i++) {
		int err;

@@ -1215,15 +1209,21 @@ static void test_main_cap_commander_broadcast_reception(void)

	test_distribute_broadcast_code(acceptor_count);

	for (size_t i = 0U; i < acceptor_count; i++) {
		backchannel_sync_wait_any(); /* wait for the acceptor to receive data */
	}

	test_broadcast_reception_stop(acceptor_count);

	for (size_t i = 0U; i < acceptor_count; i++) {
		backchannel_sync_wait_any(); /* wait for the acceptor to stop reception */
	}

	/* Disconnect all CAP acceptors */
	disconnect_acl(acceptor_count);

	backchannel_sync_send_all(); /* let others know we have received what we wanted */

	PASS("Broadcast reception passed\n");
}

+3 −2
Changes for tests/bsim/bluetooth/audio/src/cap_initiator_broadcast_test.c: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -37,10 +37,10 @@
#if defined(CONFIG_BT_CAP_INITIATOR) && defined(CONFIG_BT_BAP_BROADCAST_SOURCE)
CREATE_FLAG(flag_source_started);

#define BROADCAST_STREMT_CNT    CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT
#define CAP_AC_MAX_STREAM       2
#define LOCATION                (BT_AUDIO_LOCATION_FRONT_LEFT | BT_AUDIO_LOCATION_FRONT_RIGHT)
#define CONTEXT                 (BT_AUDIO_CONTEXT_TYPE_MEDIA)
#define BROADCAST_STREMT_CNT    MIN(CAP_AC_MAX_STREAM, CONFIG_BT_BAP_BROADCAST_SRC_STREAM_COUNT)

struct cap_initiator_ac_param {
	char *name;
@@ -673,7 +673,8 @@ static void test_main_cap_initiator_broadcast(void)
	WAIT_FOR_FLAG(flag_source_started);

	/* Wait for other devices to have received the data they wanted */
	backchannel_sync_wait_any();
	printk("Waiting for broadcast stop signal");
	backchannel_sync_wait_all();

	test_broadcast_audio_tx_sync();

+6 −2
Changes for tests/bsim/bluetooth/audio/test_scripts/cap_broadcast_reception.sh: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@

SIMULATION_ID="cap_broadcast_reception"
VERBOSITY_LEVEL=2
NR_OF_DEVICES=3
NR_OF_DEVICES=4
EXECUTE_TIMEOUT=180

source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
@@ -20,13 +20,17 @@ Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_audio_prj_conf \
  -RealEncryption=1 -rs=46 -D=${NR_OF_DEVICES}

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_audio_prj_conf \
  -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=broadcast_source \
  -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=1 -testid=cap_initiator_broadcast \
  -RealEncryption=1 -rs=23 -D=${NR_OF_DEVICES}

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_audio_prj_conf \
  -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=2 -testid=cap_acceptor_broadcast_reception \
  -RealEncryption=1 -rs=69 -D=${NR_OF_DEVICES} -start_offset=7e3

Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_audio_prj_conf \
  -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} -d=3 -testid=cap_acceptor_broadcast_reception \
  -RealEncryption=1 -rs=87 -D=${NR_OF_DEVICES} -start_offset=7e3

# Simulation time should be larger than the WAIT_TIME in common.h
Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \
  -D=${NR_OF_DEVICES} -sim_length=60e6 $@