Skip to content

Commit 94e5481

Browse files
Thalleyfabiobaltieri
authored andcommitted
Bluetooth: BAP: SD: Added missing bad code when using mod_src
When the encrypt state was changed via bt_bap_scan_delegator_mod_src then we didn't set the bad broadcast code correctly. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
1 parent 34fa014 commit 94e5481

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

subsys/bluetooth/audio/bap_scan_delegator.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,12 @@ int bt_bap_scan_delegator_mod_src(const struct bt_bap_scan_delegator_mod_src_par
14691469

14701470
if (state->encrypt_state != param->encrypt_state) {
14711471
state->encrypt_state = param->encrypt_state;
1472+
1473+
if (state->encrypt_state == BT_BAP_BIG_ENC_STATE_BAD_CODE) {
1474+
(void)memcpy(state->bad_code, internal_state->broadcast_code,
1475+
sizeof(internal_state->state.bad_code));
1476+
}
1477+
14721478
state_changed = true;
14731479
}
14741480

tests/bsim/bluetooth/audio/src/bap_broadcast_assistant_test.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ static void bap_broadcast_assistant_recv_state_cb(
142142
SET_FLAG(flag_broadcast_code_requested);
143143
} else if (state->encrypt_state == BT_BAP_BIG_ENC_STATE_BAD_CODE) {
144144
SET_FLAG(flag_incorrect_broadcast_code);
145-
return;
145+
if (memcmp(state->bad_code, INCORRECT_BROADCAST_CODE,
146+
BT_AUDIO_BROADCAST_CODE_SIZE) != 0) {
147+
FAIL("Bad code is not what we sent");
148+
return;
149+
}
146150
}
147151

148152
for (uint8_t i = 0; i < state->num_subgroups; i++) {

0 commit comments

Comments
 (0)