diff --git a/subsys/bluetooth/audio/bap_scan_delegator.c b/subsys/bluetooth/audio/bap_scan_delegator.c index 39ecf17062e..a68f6b43163 100644 --- a/subsys/bluetooth/audio/bap_scan_delegator.c +++ b/subsys/bluetooth/audio/bap_scan_delegator.c @@ -822,6 +822,7 @@ static int scan_delegator_mod_src(struct bt_conn *conn, */ if (pa_sync != BT_BAP_BASS_PA_REQ_NO_SYNC && state->pa_sync_state != BT_BAP_PA_STATE_SYNCED) { + const uint8_t pa_sync_state = state->pa_sync_state; const int err = pa_sync_request(conn, state, pa_sync, pa_interval); @@ -834,6 +835,12 @@ static int scan_delegator_mod_src(struct bt_conn *conn, err); return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED); + } else if (pa_sync_state != state->pa_sync_state) { + /* Temporary work around if the state is changed when pa_sync_request is + * called. See https://github.com/zephyrproject-rtos/zephyr/issues/79308 for + * more information about this issue. + */ + state_changed = true; } } else if (pa_sync == BT_BAP_BASS_PA_REQ_NO_SYNC && (state->pa_sync_state == BT_BAP_PA_STATE_INFO_REQ || diff --git a/tests/bsim/bluetooth/audio/src/bap_scan_delegator_test.c b/tests/bsim/bluetooth/audio/src/bap_scan_delegator_test.c index 6d34ee21a4a..10a41acb654 100644 --- a/tests/bsim/bluetooth/audio/src/bap_scan_delegator_test.c +++ b/tests/bsim/bluetooth/audio/src/bap_scan_delegator_test.c @@ -138,6 +138,7 @@ static int pa_sync_past(struct bt_conn *conn, struct bt_le_per_adv_sync_transfer_param param = { 0 }; int err; + param.options = BT_LE_PER_ADV_SYNC_TRANSFER_OPT_FILTER_DUPLICATES; param.skip = PA_SYNC_SKIP; param.timeout = interval_to_sync_timeout(pa_interval); @@ -267,6 +268,13 @@ static int pa_sync_req_cb(struct bt_conn *conn, if (past_avail) { err = pa_sync_past(conn, state, pa_interval); + if (err == 0) { + err = bt_bap_scan_delegator_set_pa_state(state->recv_state->src_id, + BT_BAP_PA_STATE_INFO_REQ); + if (err != 0) { + printk("Failed to set INFO_REQ state: %d", err); + } + } } else { err = pa_sync_no_past(state, pa_interval); } @@ -358,6 +366,14 @@ static void pa_synced_cb(struct bt_le_per_adv_sync *sync, printk("PA %p synced\n", sync); + if (info->conn) { /* if from PAST */ + for (size_t i = 0U; i < ARRAY_SIZE(sync_states); i++) { + if (!sync_states[i].pa_sync) { + sync_states[i].pa_sync = sync; + } + } + } + state = sync_state_get_by_pa(sync); if (state == NULL) { FAIL("Could not get sync state from PA sync %p\n", sync);