Skip to content

Commit 265a7a9

Browse files
author
Andries Kruithof
committed
Bluetooth: Audio: add babblesim tests for CAP distribute broadcastcode
Adding a babblesim test for the distribute broadcastcode CAP procedure Signed-off-by: Andries Kruithof <[email protected]>
1 parent 5be4aed commit 265a7a9

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/bsim/bluetooth/audio/src/cap_acceptor_test.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ static void broadcast_code_cb(struct bt_conn *conn,
399399
{
400400
printk("Broadcast code received for %p\n", recv_state);
401401

402+
if (memcmp(broadcast_code, BROADCAST_CODE, sizeof(BROADCAST_CODE)) != 0) {
403+
FAIL("Failed to receive correct broadcast code\n");
404+
return;
405+
}
406+
402407
SET_FLAG(flag_broadcast_code);
403408
}
404409

@@ -984,6 +989,12 @@ static void base_wait_for_metadata_update(void)
984989
backchannel_sync_send_all(); /* let others know we have received a metadata update */
985990
}
986991

992+
static void wait_for_broadcast_code(void)
993+
{
994+
printk("Waiting for broadcast code\n");
995+
WAIT_FOR_FLAG(flag_broadcast_code);
996+
}
997+
987998
static void wait_for_streams_stop(int stream_count)
988999
{
9891000
/* The order of PA sync lost and BIG Sync lost is irrelevant
@@ -1032,6 +1043,7 @@ static void test_cap_acceptor_broadcast_reception(void)
10321043

10331044
create_and_sync_sink(bap_streams, &stream_count);
10341045

1046+
wait_for_broadcast_code();
10351047
sink_wait_for_data();
10361048

10371049
/* Since we are re-using the BAP broadcast source test

tests/bsim/bluetooth/audio/src/cap_commander_test.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "bstests.h"
3636
#include "common.h"
37+
#include "bap_common.h"
3738

3839
#if defined(CONFIG_BT_CAP_COMMANDER)
3940

@@ -1026,6 +1027,27 @@ static void test_broadcast_reception_stop(size_t acceptor_count)
10261027
WAIT_FOR_FLAG(flag_broadcast_reception_stop);
10271028
}
10281029

1030+
static void test_distribute_broadcast_code(size_t acceptor_count)
1031+
{
1032+
struct bt_cap_commander_distribute_broadcast_code_param distribute_broadcast_code_param = {
1033+
0};
1034+
struct bt_cap_commander_distribute_broadcast_code_member_param param[CONFIG_BT_MAX_CONN] = {
1035+
0};
1036+
1037+
distribute_broadcast_code_param.type = BT_CAP_SET_TYPE_AD_HOC;
1038+
distribute_broadcast_code_param.param = param;
1039+
distribute_broadcast_code_param.count = acceptor_count;
1040+
memcpy(distribute_broadcast_code_param.broadcast_code, BROADCAST_CODE,
1041+
sizeof(BROADCAST_CODE));
1042+
for (size_t i = 0; i < acceptor_count; i++) {
1043+
1044+
distribute_broadcast_code_param.param[i].member.member = connected_conns[i];
1045+
distribute_broadcast_code_param.param[i].src_id = src_id[i];
1046+
}
1047+
1048+
bt_cap_commander_distribute_broadcast_code(&distribute_broadcast_code_param);
1049+
}
1050+
10291051
static void test_main_cap_commander_capture_and_render(void)
10301052
{
10311053
const size_t acceptor_cnt = get_dev_cnt() - 1; /* Assume all other devices are acceptors
@@ -1103,6 +1125,8 @@ static void test_main_cap_commander_broadcast_reception(void)
11031125

11041126
test_broadcast_reception_start(acceptor_count);
11051127

1128+
test_distribute_broadcast_code(acceptor_count);
1129+
11061130
backchannel_sync_wait_any(); /* wait for the acceptor to receive data */
11071131

11081132
backchannel_sync_wait_any(); /* wait for the acceptor to receive a metadata update */

0 commit comments

Comments
 (0)