diff --git a/tests/bsim/bluetooth/audio/src/common.h b/tests/bsim/bluetooth/audio/src/common.h index cad70f5d8b2..8464f4cd306 100644 --- a/tests/bsim/bluetooth/audio/src/common.h +++ b/tests/bsim/bluetooth/audio/src/common.h @@ -68,7 +68,7 @@ static const uint8_t mock_iso_data[] = { }; #define MIN_SEND_COUNT 100 -#define WAIT_SECONDS 60 /* seconds */ +#define WAIT_SECONDS 100 /* seconds */ #define WAIT_TIME (WAIT_SECONDS * USEC_PER_SEC) /* microseconds*/ #define WAIT_FOR_COND(cond) while (!(cond)) { k_sleep(K_MSEC(1)); } diff --git a/tests/bsim/bluetooth/audio/src/pbp_public_broadcast_sink_test.c b/tests/bsim/bluetooth/audio/src/pbp_public_broadcast_sink_test.c index 657ab1f1b85..f3e58a0abed 100644 --- a/tests/bsim/bluetooth/audio/src/pbp_public_broadcast_sink_test.c +++ b/tests/bsim/bluetooth/audio/src/pbp_public_broadcast_sink_test.c @@ -18,7 +18,7 @@ #include "common.h" -#define SEM_TIMEOUT K_SECONDS(1.5) +#define SEM_TIMEOUT K_SECONDS(30) extern enum bst_result_t bst_result; @@ -48,7 +48,7 @@ static const struct bt_audio_codec_cap codec = BT_AUDIO_CODEC_CAP_LC3( */ static const uint32_t bis_index_mask = BIT_MASK(ARRAY_SIZE(streams) + 1U); static uint32_t bis_index_bitfield; -static uint32_t broadcast_id = INVALID_BROADCAST_ID; +static uint32_t broadcast_id; static struct bt_pacs_cap cap = { .codec_cap = &codec, @@ -69,6 +69,7 @@ static void base_recv_cb(struct bt_bap_broadcast_sink *sink, const struct bt_bap static void syncable_cb(struct bt_bap_broadcast_sink *sink, const struct bt_iso_biginfo *biginfo) { + printk("Broadcast sink %p is now syncable\n", sink); k_sem_give(&sem_syncable); } @@ -147,6 +148,7 @@ static void broadcast_pa_recv(struct bt_le_per_adv_sync *sync, static void broadcast_pa_synced(struct bt_le_per_adv_sync *sync, struct bt_le_per_adv_sync_synced_info *info) { + printk("PA synced\n"); k_sem_give(&sem_pa_synced); } @@ -181,6 +183,11 @@ static int reset(void) k_sem_reset(&sem_base_received); k_sem_reset(&sem_syncable); k_sem_reset(&sem_pa_sync_lost); + k_sem_reset(&sem_data_received); + + broadcast_id = INVALID_BROADCAST_ID; + bis_index_bitfield = 0U; + pbs_found = false; if (broadcast_sink != NULL) { err = bt_bap_broadcast_sink_delete(broadcast_sink); @@ -239,7 +246,7 @@ static void sync_broadcast_pa(const struct bt_le_scan_recv_info *info) bt_le_scan_cb_unregister(&broadcast_scan_cb); err = bt_le_scan_stop(); if (err != 0) { - printk("Could not stop scan: %d", err); + printk("Could not stop scan: %d\n", err); } bt_addr_le_copy(¶m.addr, info->addr); @@ -249,8 +256,7 @@ static void sync_broadcast_pa(const struct bt_le_scan_recv_info *info) param.timeout = interval_to_sync_timeout(info->interval); err = bt_le_per_adv_sync_create(¶m, &bcast_pa_sync); if (err != 0) { - printk("Could not sync to PA: %d", err); - + printk("Could not sync to PA: %d\n", err); } } @@ -283,14 +289,6 @@ static bool scan_check_and_sync_broadcast(struct bt_data *data, void *user_data) ret = bt_pbp_parse_announcement(data, &source_features, &tmp_meta); if (ret >= 0) { - if (!(source_features & BT_PBP_ANNOUNCEMENT_FEATURE_HIGH_QUALITY)) { - /* This is a Standard Quality Public Broadcast Audio stream - do not sync */ - printk("This is a Standard Quality Public Broadcast Audio stream\n"); - pbs_found = false; - - return false; - } - printk("Found Suitable Public Broadcast Announcement with %d octets of metadata\n", ret); pbs_found = true; @@ -333,6 +331,7 @@ static void test_main(void) init(); while (count < PBP_STREAMS_TO_SEND) { + printk("Resetting for iteration %d\n", count); err = reset(); if (err != 0) { printk("Resetting failed: %d\n", err); @@ -343,6 +342,7 @@ static void test_main(void) bt_le_scan_cb_register(&broadcast_scan_cb); /* Start scanning */ + printk("Starting scan\n"); err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, NULL); if (err) { printk("Scan start failed (err %d)\n", err); @@ -350,6 +350,7 @@ static void test_main(void) } /* Wait for PA sync */ + printk("Waiting for PA Sync\n"); err = k_sem_take(&sem_pa_synced, SEM_TIMEOUT); if (err != 0) { printk("sem_pa_synced timed out\n"); @@ -357,6 +358,7 @@ static void test_main(void) } /* Wait for BASE decode */ + printk("Waiting for BASE\n"); err = k_sem_take(&sem_base_received, SEM_TIMEOUT); if (err != 0) { printk("sem_base_received timed out\n"); @@ -364,19 +366,22 @@ static void test_main(void) } /* Create broadcast sink */ + printk("Creating broadcast sink\n"); err = bt_bap_broadcast_sink_create(bcast_pa_sync, broadcast_id, &broadcast_sink); if (err != 0) { printk("Sink not created!\n"); break; } - k_sem_take(&sem_syncable, SEM_TIMEOUT); + printk("Waiting for syncable\n"); + err = k_sem_take(&sem_syncable, SEM_TIMEOUT); if (err != 0) { printk("sem_syncable timed out\n"); break; } /* Sync to broadcast source */ + printk("Syncing broadcast sink\n"); err = bt_bap_broadcast_sink_sync(broadcast_sink, bis_index_bitfield, streams_p, NULL); if (err != 0) { @@ -385,19 +390,24 @@ static void test_main(void) } /* Wait for data */ + printk("Waiting for data\n"); k_sem_take(&sem_data_received, SEM_TIMEOUT); + printk("Sending signal to broadcaster to stop\n"); + backchannel_sync_send_all(); /* let the broadcast source know it can stop */ + /* Wait for the stream to end */ + printk("Waiting for sync lost\n"); k_sem_take(&sem_pa_sync_lost, SEM_TIMEOUT); count++; } - if (count == PBP_STREAMS_TO_SEND - 1) { + if (count == PBP_STREAMS_TO_SEND) { /* Pass if we synced only with the high quality broadcast */ PASS("Public Broadcast sink passed\n"); } else { - FAIL("Public Broadcast sink failed\n"); + FAIL("Public Broadcast sink failed (%d/%d)\n", count, PBP_STREAMS_TO_SEND); } } diff --git a/tests/bsim/bluetooth/audio/src/pbp_public_broadcast_source_test.c b/tests/bsim/bluetooth/audio/src/pbp_public_broadcast_source_test.c index 31cbc4bbb93..dec32f366ad 100644 --- a/tests/bsim/bluetooth/audio/src/pbp_public_broadcast_source_test.c +++ b/tests/bsim/bluetooth/audio/src/pbp_public_broadcast_source_test.c @@ -339,8 +339,8 @@ static void test_main(void) sent_cb(&broadcast_stream->bap_stream); } - /* Keeping running for a little while */ - k_sleep(K_SECONDS(3)); + /* Wait for other devices to let us know when we can stop the source */ + printk("Waiting for signal from receiver to stop\n"); backchannel_sync_wait_any(); err = bt_cap_initiator_broadcast_audio_stop(broadcast_source); if (err != 0) { diff --git a/tests/bsim/bluetooth/audio/test_scripts/pbp.sh b/tests/bsim/bluetooth/audio/test_scripts/pbp.sh index cdffcb3dfa0..ff5499a14f8 100755 --- a/tests/bsim/bluetooth/audio/test_scripts/pbp.sh +++ b/tests/bsim/bluetooth/audio/test_scripts/pbp.sh @@ -23,6 +23,6 @@ Execute ./bs_${BOARD}_tests_bsim_bluetooth_audio_prj_conf \ # Simulation time should be larger than the WAIT_TIME in common.h Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \ - -D=2 -sim_length=70e6 $@ + -D=2 -sim_length=100e6 $@ wait_for_background_jobs