Skip to content

Commit

Permalink
Bluetooth: Audio: Fix PAST support for bap_scan_delegator
Browse files Browse the repository at this point in the history
Fixed PAST support for bap_scan_delegator

Signed-off-by: Lucas Mathias Balling <[email protected]>
  • Loading branch information
lutb-ot committed Sep 24, 2024
1 parent ef40903 commit d7b3d88
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions subsys/bluetooth/audio/bap_scan_delegator.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,11 @@ static int scan_delegator_mod_src(struct bt_conn *conn,
err);

return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED);
} else {
/* If past is supported - state will change */
if (supports_past(conn, pa_sync)) {
state_changed = true;
}
}
} else if (pa_sync == BT_BAP_BASS_PA_REQ_NO_SYNC &&
(state->pa_sync_state == BT_BAP_PA_STATE_INFO_REQ ||
Expand Down
17 changes: 17 additions & 0 deletions tests/bsim/bluetooth/audio/src/bap_scan_delegator_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -267,6 +268,14 @@ 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);
}
Expand Down Expand Up @@ -358,6 +367,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);
Expand Down

0 comments on commit d7b3d88

Please sign in to comment.