@@ -123,15 +123,19 @@ static void pa_timer_handler(struct k_work *work)
123
123
124
124
if (state -> recv_state != NULL ) {
125
125
enum bt_bap_pa_state pa_state ;
126
+ int err ;
126
127
127
128
if (state -> recv_state -> pa_sync_state == BT_BAP_PA_STATE_INFO_REQ ) {
128
129
pa_state = BT_BAP_PA_STATE_NO_PAST ;
129
130
} else {
130
131
pa_state = BT_BAP_PA_STATE_FAILED ;
131
132
}
132
133
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
+ }
135
139
}
136
140
137
141
FAIL ("PA timeout\n" );
@@ -286,7 +290,8 @@ static int pa_sync_req_cb(struct bt_conn *conn,
286
290
err = bt_bap_scan_delegator_set_pa_state (state -> recv_state -> src_id ,
287
291
BT_BAP_PA_STATE_INFO_REQ );
288
292
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 ;
290
295
}
291
296
}
292
297
} else {
@@ -426,6 +431,16 @@ static void pa_synced_cb(struct bt_le_per_adv_sync *sync,
426
431
return ;
427
432
}
428
433
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
+
429
444
k_work_cancel_delayable (& state -> pa_timer );
430
445
431
446
SET_FLAG (flag_pa_synced );
@@ -444,6 +459,16 @@ static void pa_term_cb(struct bt_le_per_adv_sync *sync,
444
459
return ;
445
460
}
446
461
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
+
447
472
k_work_cancel_delayable (& state -> pa_timer );
448
473
449
474
SET_FLAG (flag_pa_terminated );
@@ -541,6 +566,7 @@ static int add_source(struct sync_state *state)
541
566
542
567
bt_addr_le_copy (& param .addr , & sync_info .addr );
543
568
param .sid = sync_info .sid ;
569
+ param .pa_state = BT_BAP_PA_STATE_SYNCED ;
544
570
param .encrypt_state = BT_BAP_BIG_ENC_STATE_NO_ENC ;
545
571
param .broadcast_id = g_broadcast_id ;
546
572
param .num_subgroups = 1U ;
@@ -657,6 +683,8 @@ static int remove_source(struct sync_state *state)
657
683
return err ;
658
684
}
659
685
686
+ state -> recv_state = NULL ;
687
+
660
688
WAIT_FOR_FLAG (flag_recv_state_updated );
661
689
662
690
return 0 ;
0 commit comments