Bluetooth: Audio: Fix PAST support for bap_scan_delegator
Fixed PAST support for bap_scan_delegator Signed-off-by: Lucas Mathias Balling <lutb@demant.com>
This commit is contained in:
parent
533a75dff4
commit
01872642f4
2 changed files with 23 additions and 0 deletions
|
@ -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 ||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue