Skip to content

Commit

Permalink
Bluetooth: Audio: CAP: babblesim test for broadcast reception start
Browse files Browse the repository at this point in the history
Add a babblesim test for the broadcast reception start procedure
from the CAP commander

Signed-off-by: Andries Kruithof <[email protected]>
  • Loading branch information
kruithofa authored and aescolar committed Jun 14, 2024
1 parent 9ae5352 commit 8113876
Show file tree
Hide file tree
Showing 4 changed files with 758 additions and 18 deletions.
24 changes: 12 additions & 12 deletions tests/bsim/bluetooth/audio/src/bap_broadcast_sink_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
#if defined(CONFIG_BT_BAP_BROADCAST_SINK)
extern enum bst_result_t bst_result;

CREATE_FLAG(broadcaster_found);
CREATE_FLAG(flag_broadcaster_found);
CREATE_FLAG(flag_base_received);
CREATE_FLAG(flag_base_metadata_updated);
CREATE_FLAG(pa_synced);
CREATE_FLAG(flag_pa_synced);
CREATE_FLAG(flag_syncable);
CREATE_FLAG(pa_sync_lost);
CREATE_FLAG(flag_pa_sync_lost);
CREATE_FLAG(flag_received);
CREATE_FLAG(flag_pa_request);
CREATE_FLAG(flag_bis_sync_requested);
Expand Down Expand Up @@ -265,7 +265,7 @@ static bool scan_check_and_sync_broadcast(struct bt_data *data, void *user_data)
struct bt_uuid_16 adv_uuid;
uint32_t broadcast_id;

if (TEST_FLAG(broadcaster_found)) {
if (TEST_FLAG(flag_broadcaster_found)) {
/* no-op*/
return false;
}
Expand Down Expand Up @@ -293,7 +293,7 @@ static bool scan_check_and_sync_broadcast(struct bt_data *data, void *user_data)
printk("Found broadcaster with ID 0x%06X and addr %s and sid 0x%02X\n", broadcast_id,
le_addr, info->sid);

SET_FLAG(broadcaster_found);
SET_FLAG(flag_broadcaster_found);

/* Store info for PA sync parameters */
memcpy(&broadcaster_info, info, sizeof(broadcaster_info));
Expand Down Expand Up @@ -322,7 +322,7 @@ static void bap_pa_sync_synced_cb(struct bt_le_per_adv_sync *sync,
printk("PA sync %p synced for broadcast sink with broadcast ID 0x%06X\n", sync,
broadcaster_broadcast_id);

SET_FLAG(pa_synced);
SET_FLAG(flag_pa_synced);
}
}

Expand All @@ -333,7 +333,7 @@ static void bap_pa_sync_terminated_cb(struct bt_le_per_adv_sync *sync,
printk("PA sync %p lost with reason %u\n", sync, info->reason);
pa_sync = NULL;

SET_FLAG(pa_sync_lost);
SET_FLAG(flag_pa_sync_lost);
}
}

Expand Down Expand Up @@ -640,9 +640,9 @@ static int init(void)
bt_le_per_adv_sync_cb_register(&bap_pa_sync_cb);
bt_le_scan_cb_register(&bap_scan_cb);

UNSET_FLAG(broadcaster_found);
UNSET_FLAG(flag_broadcaster_found);
UNSET_FLAG(flag_base_received);
UNSET_FLAG(pa_synced);
UNSET_FLAG(flag_pa_synced);

for (size_t i = 0U; i < ARRAY_SIZE(streams); i++) {
streams[i] = bap_stream_from_audio_test_stream(&broadcast_sink_streams[i]);
Expand Down Expand Up @@ -710,7 +710,7 @@ static void test_scan_and_pa_sync(void)
return;
}

WAIT_FOR_FLAG(broadcaster_found);
WAIT_FOR_FLAG(flag_broadcaster_found);

printk("Broadcast source found, stopping scan\n");
err = bt_le_scan_stop();
Expand All @@ -728,7 +728,7 @@ static void test_scan_and_pa_sync(void)
}

printk("Waiting for PA sync\n");
WAIT_FOR_FLAG(pa_synced);
WAIT_FOR_FLAG(flag_pa_synced);
}

static void test_broadcast_sink_create(void)
Expand Down Expand Up @@ -976,7 +976,7 @@ static void test_main(void)
* either way will work.
*/
printk("Waiting for PA disconnected\n");
WAIT_FOR_FLAG(pa_sync_lost);
WAIT_FOR_FLAG(flag_pa_sync_lost);

printk("Waiting for streams to be stopped\n");
for (size_t i = 0U; i < ARRAY_SIZE(streams); i++) {
Expand Down
Loading

0 comments on commit 8113876

Please sign in to comment.