Commit ab57f227 authored by Emil Gydesen's avatar Emil Gydesen Committed by Anas Nashif
Browse files

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: default avatarEmil Gydesen <emil.gydesen@nordicsemi.no>
parent 3caa8f40
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -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);

	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",