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:
parent
3caa8f403a
commit
ab57f2275a
1 changed files with 22 additions and 1 deletions
|
@ -77,6 +77,21 @@ static struct sync_state *sync_state_get_by_pa(struct bt_le_per_adv_sync *sync)
|
||||||
return NULL;
|
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)
|
static struct sync_state *sync_state_new(void)
|
||||||
{
|
{
|
||||||
for (size_t i = 0U; i < ARRAY_SIZE(sync_states); i++) {
|
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);
|
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) {
|
if (state == NULL) {
|
||||||
shell_info(ctx_shell,
|
shell_info(ctx_shell,
|
||||||
"Could not get sync state from PA sync %p",
|
"Could not get sync state from PA sync %p",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue