Bluetooth: BAP: Shell: Fix state lookup with PAST

When a PA is synced via PAST, the receive state does not
have a PA sync object, and the address and SID must be
used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2024-03-26 14:41:56 +01:00 committed by Anas Nashif
commit ab57f2275a

View file

@ -77,6 +77,21 @@ static struct sync_state *sync_state_get_by_pa(struct bt_le_per_adv_sync *sync)
return NULL;
}
static struct sync_state *
sync_state_get_by_sync_info(const struct bt_le_per_adv_sync_synced_info *info)
{
for (size_t i = 0U; i < ARRAY_SIZE(sync_states); i++) {
if (sync_states[i].recv_state != NULL &&
bt_addr_le_eq(info->addr, &sync_states[i].recv_state->addr) &&
info->sid == sync_states[i].recv_state->adv_sid) {
return &sync_states[i];
}
}
return NULL;
}
static struct sync_state *sync_state_new(void)
{
for (size_t i = 0U; i < ARRAY_SIZE(sync_states); i++) {
@ -337,7 +352,13 @@ static void pa_synced_cb(struct bt_le_per_adv_sync *sync,
shell_info(ctx_shell, "PA %p synced", sync);
state = sync_state_get_by_pa(sync);
if (info->conn == NULL) {
state = sync_state_get_by_pa(sync);
} else {
/* In case of PAST we need to use the addr instead */
state = sync_state_get_by_sync_info(info);
}
if (state == NULL) {
shell_info(ctx_shell,
"Could not get sync state from PA sync %p",