From 460ac477c1e9fcf36cee82c4d3c0571476a4bca2 Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Thu, 27 Oct 2022 11:12:42 +0200 Subject: [PATCH] tests: Bluetooth: Update broadcast_iso test to support PA sync term cb The callback is now called whenever the PA sync is terminated, even if it was locally terminated. The test case has been updated to handle that. Signed-off-by: Emil Gydesen --- tests/bluetooth/bsim_bt/bsim_test_iso/src/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/bluetooth/bsim_bt/bsim_test_iso/src/main.c b/tests/bluetooth/bsim_bt/bsim_test_iso/src/main.c index dacd293da06..ea432647aad 100644 --- a/tests/bluetooth/bsim_bt/bsim_test_iso/src/main.c +++ b/tests/bluetooth/bsim_bt/bsim_test_iso/src/main.c @@ -58,6 +58,7 @@ static const struct bt_data per_ad_data2[] = { static uint8_t chan_map[] = { 0x1F, 0XF1, 0x1F, 0xF1, 0x1F }; static bool volatile is_iso_connected; +static bool volatile deleting_pa_sync; static void iso_connected(struct bt_iso_chan *chan); static void iso_disconnected(struct bt_iso_chan *chan, uint8_t reason); static void iso_recv(struct bt_iso_chan *chan, @@ -395,7 +396,11 @@ static void pa_terminated_cb(struct bt_le_per_adv_sync *sync, printk("PER_ADV_SYNC[%u]: [DEVICE]: %s sync terminated\n", bt_le_per_adv_sync_get_index(sync), le_addr); - FAIL("PA terminated unexpectedly\n"); + if (!deleting_pa_sync) { + FAIL("PA terminated unexpectedly\n"); + } else { + deleting_pa_sync = false; + } } static bool volatile is_sync_recv; @@ -618,6 +623,7 @@ static void test_iso_recv_main(void) k_sleep(K_MSEC(5000)); printk("Deleting Periodic Advertising Sync..."); + deleting_pa_sync = true; err = bt_le_per_adv_sync_delete(sync); if (err) { FAIL("Failed to delete periodic advertising sync (err %d)\n", @@ -766,6 +772,7 @@ static void test_iso_recv_main(void) printk("success.\n"); printk("Deleting Periodic Advertising Sync..."); + deleting_pa_sync = true; err = bt_le_per_adv_sync_delete(sync); if (err) { FAIL("Failed to delete periodic advertising sync (err %d)\n", @@ -923,6 +930,7 @@ static void test_iso_recv_vs_dp_main(void) printk("success.\n"); printk("Deleting Periodic Advertising Sync... "); + deleting_pa_sync = true; err = bt_le_per_adv_sync_delete(sync); if (err) { FAIL("Failed to delete periodic advertising sync (err %d)\n",