Lines Matching full:state

70 	struct bt_bap_scan_delegator_recv_state state;  member
129 const struct bt_bap_scan_delegator_recv_state *state = &recv_state->state; in bt_debug_dump_recv_state() local
130 const bool is_bad_code = state->encrypt_state == BT_BAP_BIG_ENC_STATE_BAD_CODE; in bt_debug_dump_recv_state()
132 LOG_DBG("Receive State[%d]: src ID %u, addr %s, adv_sid %u, broadcast_id 0x%06X, " in bt_debug_dump_recv_state()
133 "pa_sync_state %u, encrypt state %u%s%s, num_subgroups %u", in bt_debug_dump_recv_state()
134 recv_state->index, state->src_id, bt_addr_le_str(&state->addr), in bt_debug_dump_recv_state()
135 state->adv_sid, state->broadcast_id, state->pa_sync_state, in bt_debug_dump_recv_state()
136 state->encrypt_state, is_bad_code ? ", bad code" : "", in bt_debug_dump_recv_state()
137 is_bad_code ? bt_hex(state->bad_code, sizeof(state->bad_code)) : "", in bt_debug_dump_recv_state()
138 state->num_subgroups); in bt_debug_dump_recv_state()
140 for (uint8_t i = 0U; i < state->num_subgroups; i++) { in bt_debug_dump_recv_state()
141 const struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i]; in bt_debug_dump_recv_state()
150 LOG_DBG("Inactive receive state"); in bt_debug_dump_recv_state()
179 LOG_DBG("Could not notify receive state: %d", err); in bass_notify_receive_state()
185 const struct bt_bap_scan_delegator_recv_state *state = &recv_state->state; in net_buf_put_recv_state() local
189 __ASSERT(recv_state, "NULL receive state"); in net_buf_put_recv_state()
197 (void)net_buf_simple_add_u8(&read_buf, state->src_id); in net_buf_put_recv_state()
198 (void)net_buf_simple_add_u8(&read_buf, state->addr.type); in net_buf_put_recv_state()
199 (void)net_buf_simple_add_mem(&read_buf, &state->addr.a, in net_buf_put_recv_state()
200 sizeof(state->addr.a)); in net_buf_put_recv_state()
201 (void)net_buf_simple_add_u8(&read_buf, state->adv_sid); in net_buf_put_recv_state()
202 (void)net_buf_simple_add_le24(&read_buf, state->broadcast_id); in net_buf_put_recv_state()
203 (void)net_buf_simple_add_u8(&read_buf, state->pa_sync_state); in net_buf_put_recv_state()
204 (void)net_buf_simple_add_u8(&read_buf, state->encrypt_state); in net_buf_put_recv_state()
205 if (state->encrypt_state == BT_BAP_BIG_ENC_STATE_BAD_CODE) { in net_buf_put_recv_state()
206 (void)net_buf_simple_add_mem(&read_buf, &state->bad_code, in net_buf_put_recv_state()
207 sizeof(state->bad_code)); in net_buf_put_recv_state()
209 (void)net_buf_simple_add_u8(&read_buf, state->num_subgroups); in net_buf_put_recv_state()
210 for (int i = 0; i < state->num_subgroups; i++) { in net_buf_put_recv_state()
211 const struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i]; in net_buf_put_recv_state()
244 &internal_state->state); in receive_state_updated()
255 scan_delegator_cbs->bis_sync_req(conn, &internal_state->state, in bis_sync_request_updated()
308 scan_delegator.recv_states[i].state.src_id == next_src_id) { in next_src_id()
322 scan_delegator.recv_states[i].state.src_id == src_id) { in bass_lookup_src_id()
344 if (bt_addr_le_eq(&scan_delegator.recv_states[i].state.addr, in bass_lookup_addr()
376 LOG_DBG("BASS receive state not found"); in pa_synced()
382 if (internal_state->state.pa_sync_state != BT_BAP_PA_STATE_SYNCED) { in pa_synced()
383 internal_state->state.pa_sync_state = BT_BAP_PA_STATE_SYNCED; in pa_synced()
395 LOG_DBG("BASS receive state not found"); in pa_terminated()
401 if (internal_state->state.pa_sync_state != BT_BAP_PA_STATE_NOT_SYNCED) { in pa_terminated()
402 internal_state->state.pa_sync_state = BT_BAP_PA_STATE_NOT_SYNCED; in pa_terminated()
429 const struct bt_bap_scan_delegator_recv_state *state, in pa_sync_request() argument
438 err = scan_delegator_cbs->pa_sync_req(conn, state, in pa_sync_request()
449 const struct bt_bap_scan_delegator_recv_state *state) in pa_sync_term_request() argument
455 err = scan_delegator_cbs->pa_sync_term_req(conn, state); in pa_sync_term_request()
465 * Source_Adv_SID, and Broadcast_ID fields of any Broadcast Receive State characteristic exposed
470 struct bass_recv_state_internal *state; in bass_source_is_duplicate() local
473 state = &scan_delegator.recv_states[i]; in bass_source_is_duplicate()
475 if (state != NULL && state->state.broadcast_id == broadcast_id && in bass_source_is_duplicate()
476 state->state.adv_sid == adv_sid && state->state.addr.type == addr_type) { in bass_source_is_duplicate()
477 LOG_DBG("recv_state already exists at src_id=0x%02X", state->state.src_id); in bass_source_is_duplicate()
490 struct bt_bap_scan_delegator_recv_state *state; in scan_delegator_add_source() local
506 LOG_DBG("Could not get free receive state"); in scan_delegator_add_source()
511 state = &internal_state->state; in scan_delegator_add_source()
513 state->src_id = next_src_id(); in scan_delegator_add_source()
514 state->addr.type = net_buf_simple_pull_u8(buf); in scan_delegator_add_source()
515 if (state->addr.type > BT_ADDR_LE_RANDOM) { in scan_delegator_add_source()
516 LOG_DBG("Invalid address type %u", state->addr.type); in scan_delegator_add_source()
521 bt_addr_copy(&state->addr.a, addr); in scan_delegator_add_source()
523 state->adv_sid = net_buf_simple_pull_u8(buf); in scan_delegator_add_source()
524 if (state->adv_sid > BT_GAP_SID_MAX) { in scan_delegator_add_source()
525 LOG_DBG("Invalid adv SID %u", state->adv_sid); in scan_delegator_add_source()
531 if (bass_source_is_duplicate(broadcast_id, state->adv_sid, state->addr.type)) { in scan_delegator_add_source()
533 "result in duplication", state->broadcast_id, state->adv_sid, in scan_delegator_add_source()
534 state->addr.type); in scan_delegator_add_source()
539 state->broadcast_id = broadcast_id; in scan_delegator_add_source()
549 state->num_subgroups = net_buf_simple_pull_u8(buf); in scan_delegator_add_source()
550 if (state->num_subgroups > CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) { in scan_delegator_add_source()
551 LOG_WRN("Too many subgroups %u/%u", state->num_subgroups, in scan_delegator_add_source()
557 for (int i = 0; i < state->num_subgroups; i++) { in scan_delegator_add_source()
558 struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i]; in scan_delegator_add_source()
624 * receive state can be processed in scan_delegator_add_source()
629 * layer calls another function that changes the state in the pa_sync_request callback in scan_delegator_add_source()
636 err = pa_sync_request(conn, state, pa_sync, pa_interval); in scan_delegator_add_source()
639 (void)memset(state, 0, sizeof(*state)); in scan_delegator_add_source()
650 internal_state->index, state->src_id); in scan_delegator_add_source()
669 struct bt_bap_scan_delegator_recv_state *state; in scan_delegator_mod_src() local
693 LOG_DBG("Could not find state by src id %u", src_id); in scan_delegator_mod_src()
780 /* All input has been validated; update receive state and check for changes */ in scan_delegator_mod_src()
781 state = &internal_state->state; in scan_delegator_mod_src()
784 (void)memcpy(&backup_state, state, sizeof(backup_state)); in scan_delegator_mod_src()
786 if (state->num_subgroups != num_subgroups) { in scan_delegator_mod_src()
787 state->num_subgroups = num_subgroups; in scan_delegator_mod_src()
793 subgroups[i].metadata_len != state->subgroups[i].metadata_len; in scan_delegator_mod_src()
796 state->subgroups[i].metadata_len = subgroups[i].metadata_len; in scan_delegator_mod_src()
801 memcmp(subgroups[i].metadata, state->subgroups[i].metadata, in scan_delegator_mod_src()
804 if (state->subgroups[i].metadata_len == 0U) { in scan_delegator_mod_src()
805 memset(state->subgroups[i].metadata, 0, in scan_delegator_mod_src()
806 state->subgroups[i].metadata_len); in scan_delegator_mod_src()
808 (void)memcpy(state->subgroups[i].metadata, subgroups[i].metadata, in scan_delegator_mod_src()
809 state->subgroups[i].metadata_len); in scan_delegator_mod_src()
817 * layer calls another function that changes the state in the pa_sync_request callback in scan_delegator_mod_src()
825 state->pa_sync_state != BT_BAP_PA_STATE_SYNCED) { in scan_delegator_mod_src()
826 const uint8_t pa_sync_state = state->pa_sync_state; in scan_delegator_mod_src()
827 const int err = pa_sync_request(conn, state, pa_sync, in scan_delegator_mod_src()
832 (void)memcpy(state, &backup_state, in scan_delegator_mod_src()
839 } else if (pa_sync_state != state->pa_sync_state) { in scan_delegator_mod_src()
840 /* Temporary work around if the state is changed when pa_sync_request is in scan_delegator_mod_src()
847 (state->pa_sync_state == BT_BAP_PA_STATE_INFO_REQ || in scan_delegator_mod_src()
848 state->pa_sync_state == BT_BAP_PA_STATE_SYNCED)) { in scan_delegator_mod_src()
850 const int err = pa_sync_term_request(conn, &internal_state->state); in scan_delegator_mod_src()
866 internal_state->index, state->src_id); in scan_delegator_mod_src()
895 LOG_DBG("Could not find state by src id %u", src_id); in scan_delegator_broadcast_code()
909 scan_delegator_cbs->broadcast_code(conn, &internal_state->state, in scan_delegator_broadcast_code()
920 struct bt_bap_scan_delegator_recv_state *state; in scan_delegator_rem_src() local
934 LOG_DBG("Could not find state by src id %u", src_id); in scan_delegator_rem_src()
938 state = &internal_state->state; in scan_delegator_rem_src()
941 if (conn != NULL && (state->pa_sync_state == BT_BAP_PA_STATE_INFO_REQ || in scan_delegator_rem_src()
942 state->pa_sync_state == BT_BAP_PA_STATE_SYNCED)) { in scan_delegator_rem_src()
946 err = pa_sync_term_request(conn, &internal_state->state); in scan_delegator_rem_src()
955 for (uint8_t i = 0U; i < state->num_subgroups; i++) { in scan_delegator_rem_src()
967 (void)memset(&internal_state->state, 0, sizeof(internal_state->state)); in scan_delegator_rem_src()
1091 struct bt_bap_scan_delegator_recv_state *state = &recv_state->state; in read_recv_state() local
1097 LOG_DBG("Index %u: Source ID 0x%02x", idx, state->src_id); in read_recv_state()
1193 /* Store the pointer to the first characteristic in each receive state */ in bt_bap_scan_delegator_register()
1255 recv_state = &internal_state->state; in bt_bap_scan_delegator_set_pa_state()
1277 if (internal_state->state.pa_sync_state != BT_BAP_PA_STATE_SYNCED) { in bt_bap_scan_delegator_set_bis_sync_state()
1283 /* Verify state for all subgroups before assigning any data */ in bt_bap_scan_delegator_set_bis_sync_state()
1284 for (uint8_t i = 0U; i < internal_state->state.num_subgroups; i++) { in bt_bap_scan_delegator_set_bis_sync_state()
1299 for (uint8_t i = 0U; i < internal_state->state.num_subgroups; i++) { in bt_bap_scan_delegator_set_bis_sync_state()
1301 &internal_state->state.subgroups[i]; in bt_bap_scan_delegator_set_bis_sync_state()
1316 if (internal_state->state.encrypt_state == BT_BAP_BIG_ENC_STATE_BAD_CODE) { in bt_bap_scan_delegator_set_bis_sync_state()
1317 (void)memcpy(internal_state->state.bad_code, in bt_bap_scan_delegator_set_bis_sync_state()
1319 sizeof(internal_state->state.bad_code)); in bt_bap_scan_delegator_set_bis_sync_state()
1382 struct bt_bap_scan_delegator_recv_state *state; in bt_bap_scan_delegator_add_src() local
1394 LOG_DBG("PA Sync already in a receive state with src_id %u", in bt_bap_scan_delegator_add_src()
1395 internal_state->state.src_id); in bt_bap_scan_delegator_add_src()
1403 LOG_DBG("Could not get free receive state"); in bt_bap_scan_delegator_add_src()
1408 state = &internal_state->state; in bt_bap_scan_delegator_add_src()
1410 state->src_id = next_src_id(); in bt_bap_scan_delegator_add_src()
1411 bt_addr_le_copy(&state->addr, &param->addr); in bt_bap_scan_delegator_add_src()
1412 state->adv_sid = param->sid; in bt_bap_scan_delegator_add_src()
1413 state->broadcast_id = param->broadcast_id; in bt_bap_scan_delegator_add_src()
1414 state->pa_sync_state = in bt_bap_scan_delegator_add_src()
1416 state->num_subgroups = param->num_subgroups; in bt_bap_scan_delegator_add_src()
1417 if (state->num_subgroups > 0U) { in bt_bap_scan_delegator_add_src()
1418 (void)memcpy(state->subgroups, param->subgroups, in bt_bap_scan_delegator_add_src()
1419 sizeof(state->subgroups)); in bt_bap_scan_delegator_add_src()
1421 (void)memset(state->subgroups, 0, sizeof(state->subgroups)); in bt_bap_scan_delegator_add_src()
1435 internal_state->index, state->src_id); in bt_bap_scan_delegator_add_src()
1439 return state->src_id; in bt_bap_scan_delegator_add_src()
1485 struct bt_bap_scan_delegator_recv_state *state; in bt_bap_scan_delegator_mod_src() local
1494 LOG_DBG("Could not find receive state with src_id %u", param->src_id); in bt_bap_scan_delegator_mod_src()
1499 state = &internal_state->state; in bt_bap_scan_delegator_mod_src()
1501 if (state->broadcast_id != param->broadcast_id) { in bt_bap_scan_delegator_mod_src()
1502 state->broadcast_id = param->broadcast_id; in bt_bap_scan_delegator_mod_src()
1506 if (state->num_subgroups != param->num_subgroups) { in bt_bap_scan_delegator_mod_src()
1507 state->num_subgroups = param->num_subgroups; in bt_bap_scan_delegator_mod_src()
1511 if (state->encrypt_state != param->encrypt_state) { in bt_bap_scan_delegator_mod_src()
1512 state->encrypt_state = param->encrypt_state; in bt_bap_scan_delegator_mod_src()
1514 if (state->encrypt_state == BT_BAP_BIG_ENC_STATE_BAD_CODE) { in bt_bap_scan_delegator_mod_src()
1515 (void)memcpy(state->bad_code, internal_state->broadcast_code, in bt_bap_scan_delegator_mod_src()
1516 sizeof(internal_state->state.bad_code)); in bt_bap_scan_delegator_mod_src()
1522 /* Verify that the BIS sync values is acceptable for the receive state */ in bt_bap_scan_delegator_mod_src()
1523 for (uint8_t i = 0U; i < state->num_subgroups; i++) { in bt_bap_scan_delegator_mod_src()
1536 for (uint8_t i = 0U; i < state->num_subgroups; i++) { in bt_bap_scan_delegator_mod_src()
1538 struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i]; in bt_bap_scan_delegator_mod_src()
1568 internal_state->index, state->src_id); in bt_bap_scan_delegator_mod_src()
1595 stop = func(&scan_delegator.recv_states[i].state, user_data); in bt_bap_scan_delegator_foreach_state()
1645 return &internal_state->state; in bt_bap_scan_delegator_lookup_src_id()