Skip to content

Commit e055110

Browse files
committed
tests: Bluetooth: BAP: SD: Update test to set PA sync state
The Scan Delegator has been modified to not set the PA sync state automatically anymore, so the test needed to be updated. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 9fb3ea3 commit e055110

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,19 @@ static void pa_timer_handler(struct k_work *work)
123123

124124
if (state->recv_state != NULL) {
125125
enum bt_bap_pa_state pa_state;
126+
int err;
126127

127128
if (state->recv_state->pa_sync_state == BT_BAP_PA_STATE_INFO_REQ) {
128129
pa_state = BT_BAP_PA_STATE_NO_PAST;
129130
} else {
130131
pa_state = BT_BAP_PA_STATE_FAILED;
131132
}
132133

133-
bt_bap_scan_delegator_set_pa_state(state->recv_state->src_id,
134-
pa_state);
134+
err = bt_bap_scan_delegator_set_pa_state(state->recv_state->src_id, pa_state);
135+
if (err != 0) {
136+
FAIL("Could not set PA sync state: %d\n", err);
137+
return;
138+
}
135139
}
136140

137141
FAIL("PA timeout\n");
@@ -286,7 +290,8 @@ static int pa_sync_req_cb(struct bt_conn *conn,
286290
err = bt_bap_scan_delegator_set_pa_state(state->recv_state->src_id,
287291
BT_BAP_PA_STATE_INFO_REQ);
288292
if (err != 0) {
289-
printk("Failed to set INFO_REQ state: %d", err);
293+
FAIL("Could not set PA sync state: %d\n", err);
294+
return err;
290295
}
291296
}
292297
} else {
@@ -426,6 +431,16 @@ static void pa_synced_cb(struct bt_le_per_adv_sync *sync,
426431
return;
427432
}
428433

434+
if (state->recv_state != NULL) {
435+
int err;
436+
437+
err = bt_bap_scan_delegator_set_pa_state(state->src_id, BT_BAP_PA_STATE_SYNCED);
438+
if (err != 0) {
439+
FAIL("Could not set PA sync state: %d\n", err);
440+
return;
441+
}
442+
}
443+
429444
k_work_cancel_delayable(&state->pa_timer);
430445

431446
SET_FLAG(flag_pa_synced);
@@ -444,6 +459,16 @@ static void pa_term_cb(struct bt_le_per_adv_sync *sync,
444459
return;
445460
}
446461

462+
if (state->recv_state != NULL) {
463+
int err;
464+
465+
err = bt_bap_scan_delegator_set_pa_state(state->src_id, BT_BAP_PA_STATE_NOT_SYNCED);
466+
if (err != 0) {
467+
FAIL("Could not set PA sync state: %d\n", err);
468+
return;
469+
}
470+
}
471+
447472
k_work_cancel_delayable(&state->pa_timer);
448473

449474
SET_FLAG(flag_pa_terminated);
@@ -541,6 +566,7 @@ static int add_source(struct sync_state *state)
541566

542567
bt_addr_le_copy(&param.addr, &sync_info.addr);
543568
param.sid = sync_info.sid;
569+
param.pa_state = BT_BAP_PA_STATE_SYNCED;
544570
param.encrypt_state = BT_BAP_BIG_ENC_STATE_NO_ENC;
545571
param.broadcast_id = g_broadcast_id;
546572
param.num_subgroups = 1U;
@@ -657,6 +683,8 @@ static int remove_source(struct sync_state *state)
657683
return err;
658684
}
659685

686+
state->recv_state = NULL;
687+
660688
WAIT_FOR_FLAG(flag_recv_state_updated);
661689

662690
return 0;

0 commit comments

Comments
 (0)