tests: Bluetooth: PBP: Fix several issues in the PBP bsim tests
The PBP bsim tests had several issues that was not uncovered until the PA sync timeout was increased. This commit fixes these, as well as increase some timeout values due to recently increased PA sync timeout. Among the issues were lack of support for the alternating PBA features, missing reset of values and specific time sleeps. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
0dcf3c197e
commit
984b0807c4
4 changed files with 30 additions and 20 deletions
|
@ -68,7 +68,7 @@ static const uint8_t mock_iso_data[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MIN_SEND_COUNT 100
|
#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_TIME (WAIT_SECONDS * USEC_PER_SEC) /* microseconds*/
|
||||||
|
|
||||||
#define WAIT_FOR_COND(cond) while (!(cond)) { k_sleep(K_MSEC(1)); }
|
#define WAIT_FOR_COND(cond) while (!(cond)) { k_sleep(K_MSEC(1)); }
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#define SEM_TIMEOUT K_SECONDS(1.5)
|
#define SEM_TIMEOUT K_SECONDS(30)
|
||||||
|
|
||||||
extern enum bst_result_t bst_result;
|
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 const uint32_t bis_index_mask = BIT_MASK(ARRAY_SIZE(streams) + 1U);
|
||||||
static uint32_t bis_index_bitfield;
|
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 = {
|
static struct bt_pacs_cap cap = {
|
||||||
.codec_cap = &codec,
|
.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)
|
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);
|
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,
|
static void broadcast_pa_synced(struct bt_le_per_adv_sync *sync,
|
||||||
struct bt_le_per_adv_sync_synced_info *info)
|
struct bt_le_per_adv_sync_synced_info *info)
|
||||||
{
|
{
|
||||||
|
printk("PA synced\n");
|
||||||
k_sem_give(&sem_pa_synced);
|
k_sem_give(&sem_pa_synced);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +183,11 @@ static int reset(void)
|
||||||
k_sem_reset(&sem_base_received);
|
k_sem_reset(&sem_base_received);
|
||||||
k_sem_reset(&sem_syncable);
|
k_sem_reset(&sem_syncable);
|
||||||
k_sem_reset(&sem_pa_sync_lost);
|
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) {
|
if (broadcast_sink != NULL) {
|
||||||
err = bt_bap_broadcast_sink_delete(broadcast_sink);
|
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);
|
bt_le_scan_cb_unregister(&broadcast_scan_cb);
|
||||||
err = bt_le_scan_stop();
|
err = bt_le_scan_stop();
|
||||||
if (err != 0) {
|
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);
|
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);
|
param.timeout = interval_to_sync_timeout(info->interval);
|
||||||
err = bt_le_per_adv_sync_create(¶m, &bcast_pa_sync);
|
err = bt_le_per_adv_sync_create(¶m, &bcast_pa_sync);
|
||||||
if (err != 0) {
|
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);
|
ret = bt_pbp_parse_announcement(data, &source_features, &tmp_meta);
|
||||||
if (ret >= 0) {
|
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",
|
printk("Found Suitable Public Broadcast Announcement with %d octets of metadata\n",
|
||||||
ret);
|
ret);
|
||||||
pbs_found = true;
|
pbs_found = true;
|
||||||
|
@ -333,6 +331,7 @@ static void test_main(void)
|
||||||
init();
|
init();
|
||||||
|
|
||||||
while (count < PBP_STREAMS_TO_SEND) {
|
while (count < PBP_STREAMS_TO_SEND) {
|
||||||
|
printk("Resetting for iteration %d\n", count);
|
||||||
err = reset();
|
err = reset();
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
printk("Resetting failed: %d\n", err);
|
printk("Resetting failed: %d\n", err);
|
||||||
|
@ -343,6 +342,7 @@ static void test_main(void)
|
||||||
bt_le_scan_cb_register(&broadcast_scan_cb);
|
bt_le_scan_cb_register(&broadcast_scan_cb);
|
||||||
|
|
||||||
/* Start scanning */
|
/* Start scanning */
|
||||||
|
printk("Starting scan\n");
|
||||||
err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, NULL);
|
err = bt_le_scan_start(BT_LE_SCAN_PASSIVE, NULL);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk("Scan start failed (err %d)\n", err);
|
printk("Scan start failed (err %d)\n", err);
|
||||||
|
@ -350,6 +350,7 @@ static void test_main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for PA sync */
|
/* Wait for PA sync */
|
||||||
|
printk("Waiting for PA Sync\n");
|
||||||
err = k_sem_take(&sem_pa_synced, SEM_TIMEOUT);
|
err = k_sem_take(&sem_pa_synced, SEM_TIMEOUT);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
printk("sem_pa_synced timed out\n");
|
printk("sem_pa_synced timed out\n");
|
||||||
|
@ -357,6 +358,7 @@ static void test_main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for BASE decode */
|
/* Wait for BASE decode */
|
||||||
|
printk("Waiting for BASE\n");
|
||||||
err = k_sem_take(&sem_base_received, SEM_TIMEOUT);
|
err = k_sem_take(&sem_base_received, SEM_TIMEOUT);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
printk("sem_base_received timed out\n");
|
printk("sem_base_received timed out\n");
|
||||||
|
@ -364,19 +366,22 @@ static void test_main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create broadcast sink */
|
/* Create broadcast sink */
|
||||||
|
printk("Creating broadcast sink\n");
|
||||||
err = bt_bap_broadcast_sink_create(bcast_pa_sync, broadcast_id, &broadcast_sink);
|
err = bt_bap_broadcast_sink_create(bcast_pa_sync, broadcast_id, &broadcast_sink);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
printk("Sink not created!\n");
|
printk("Sink not created!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_sem_take(&sem_syncable, SEM_TIMEOUT);
|
printk("Waiting for syncable\n");
|
||||||
|
err = k_sem_take(&sem_syncable, SEM_TIMEOUT);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
printk("sem_syncable timed out\n");
|
printk("sem_syncable timed out\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sync to broadcast source */
|
/* Sync to broadcast source */
|
||||||
|
printk("Syncing broadcast sink\n");
|
||||||
err = bt_bap_broadcast_sink_sync(broadcast_sink, bis_index_bitfield,
|
err = bt_bap_broadcast_sink_sync(broadcast_sink, bis_index_bitfield,
|
||||||
streams_p, NULL);
|
streams_p, NULL);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
|
@ -385,19 +390,24 @@ static void test_main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for data */
|
/* Wait for data */
|
||||||
|
printk("Waiting for data\n");
|
||||||
k_sem_take(&sem_data_received, SEM_TIMEOUT);
|
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 */
|
/* Wait for the stream to end */
|
||||||
|
printk("Waiting for sync lost\n");
|
||||||
k_sem_take(&sem_pa_sync_lost, SEM_TIMEOUT);
|
k_sem_take(&sem_pa_sync_lost, SEM_TIMEOUT);
|
||||||
|
|
||||||
count++;
|
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 if we synced only with the high quality broadcast */
|
||||||
PASS("Public Broadcast sink passed\n");
|
PASS("Public Broadcast sink passed\n");
|
||||||
} else {
|
} else {
|
||||||
FAIL("Public Broadcast sink failed\n");
|
FAIL("Public Broadcast sink failed (%d/%d)\n", count, PBP_STREAMS_TO_SEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,8 +339,8 @@ static void test_main(void)
|
||||||
sent_cb(&broadcast_stream->bap_stream);
|
sent_cb(&broadcast_stream->bap_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keeping running for a little while */
|
/* Wait for other devices to let us know when we can stop the source */
|
||||||
k_sleep(K_SECONDS(3));
|
printk("Waiting for signal from receiver to stop\n"); backchannel_sync_wait_any();
|
||||||
|
|
||||||
err = bt_cap_initiator_broadcast_audio_stop(broadcast_source);
|
err = bt_cap_initiator_broadcast_audio_stop(broadcast_source);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
|
|
|
@ -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
|
# Simulation time should be larger than the WAIT_TIME in common.h
|
||||||
Execute ./bs_2G4_phy_v1 -v=${VERBOSITY_LEVEL} -s=${SIMULATION_ID} \
|
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
|
wait_for_background_jobs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue