diff --git a/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c b/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c index 482aaa812ba..963d5dcd51f 100644 --- a/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c +++ b/tests/bsim/bluetooth/audio/src/cap_acceptor_test.c @@ -400,6 +400,11 @@ static void broadcast_code_cb(struct bt_conn *conn, { printk("Broadcast code received for %p\n", recv_state); + if (memcmp(broadcast_code, BROADCAST_CODE, sizeof(BROADCAST_CODE)) != 0) { + FAIL("Failed to receive correct broadcast code\n"); + return; + } + SET_FLAG(flag_broadcast_code); } @@ -996,6 +1001,12 @@ static void base_wait_for_metadata_update(void) backchannel_sync_send_all(); /* let others know we have received a metadata update */ } +static void wait_for_broadcast_code(void) +{ + printk("Waiting for broadcast code\n"); + WAIT_FOR_FLAG(flag_broadcast_code); +} + static void wait_for_streams_stop(int stream_count) { /* The order of PA sync lost and BIG Sync lost is irrelevant @@ -1046,6 +1057,7 @@ static void test_cap_acceptor_broadcast_reception(void) create_and_sync_sink(bap_streams, &stream_count); + wait_for_broadcast_code(); sink_wait_for_data(); /* Since we are re-using the BAP broadcast source test diff --git a/tests/bsim/bluetooth/audio/src/cap_commander_test.c b/tests/bsim/bluetooth/audio/src/cap_commander_test.c index aecb6faa6a0..6ac9aab62e3 100644 --- a/tests/bsim/bluetooth/audio/src/cap_commander_test.c +++ b/tests/bsim/bluetooth/audio/src/cap_commander_test.c @@ -34,6 +34,7 @@ #include "bstests.h" #include "common.h" +#include "bap_common.h" #if defined(CONFIG_BT_CAP_COMMANDER) @@ -1056,6 +1057,27 @@ static void test_broadcast_reception_stop(size_t acceptor_count) WAIT_FOR_FLAG(flag_broadcast_reception_stop); } +static void test_distribute_broadcast_code(size_t acceptor_count) +{ + struct bt_cap_commander_distribute_broadcast_code_param distribute_broadcast_code_param = { + 0}; + struct bt_cap_commander_distribute_broadcast_code_member_param param[CONFIG_BT_MAX_CONN] = { + 0}; + + distribute_broadcast_code_param.type = BT_CAP_SET_TYPE_AD_HOC; + distribute_broadcast_code_param.param = param; + distribute_broadcast_code_param.count = acceptor_count; + memcpy(distribute_broadcast_code_param.broadcast_code, BROADCAST_CODE, + sizeof(BROADCAST_CODE)); + for (size_t i = 0; i < acceptor_count; i++) { + + distribute_broadcast_code_param.param[i].member.member = connected_conns[i]; + distribute_broadcast_code_param.param[i].src_id = src_id[i]; + } + + bt_cap_commander_distribute_broadcast_code(&distribute_broadcast_code_param); +} + static void test_main_cap_commander_capture_and_render(void) { const size_t acceptor_cnt = get_dev_cnt() - 1; /* Assume all other devices are acceptors @@ -1133,6 +1155,8 @@ static void test_main_cap_commander_broadcast_reception(void) test_broadcast_reception_start(acceptor_count); + test_distribute_broadcast_code(acceptor_count); + backchannel_sync_wait_any(); /* wait for the acceptor to receive data */ backchannel_sync_wait_any(); /* wait for the acceptor to receive a metadata update */