Skip to content

Commit 0fdd247

Browse files
Thalleyrlubos
authored andcommitted
[nrf fromtree] Bluetooth: BAP: Broadcast sink MIC failure behavior
Modify the behavior of update_recv_state_big_cleared to follow what the current BASS test specification and PTS expects to pass test cases related to bad broadcast codes. There are open errata for this behavior to properly define it, but until then we should follow what the qualification tests expect. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no> (cherry picked from commit 57816ad)
1 parent dcdd450 commit 0fdd247

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

subsys/bluetooth/audio/bap_broadcast_sink.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ static void update_recv_state_big_cleared(const struct bt_bap_broadcast_sink *si
152152
uint8_t reason)
153153
{
154154
const struct bt_bap_scan_delegator_recv_state *recv_state;
155-
bool sink_is_streaming = false;
156155
int err;
157156

158157
recv_state = bt_bap_scan_delegator_find_state(find_recv_state_by_src_id_cb, (void *)sink);
@@ -174,20 +173,26 @@ static void update_recv_state_big_cleared(const struct bt_bap_broadcast_sink *si
174173
mod_src_param.encrypt_state = BT_BAP_BIG_ENC_STATE_NO_ENC;
175174
}
176175

177-
/* Determine if the previous receive state reported that streaming was active
178-
* If it was previously active, then we need to set the BIS_sync state to 0
179-
* (not streaming), and if not then we consider this a BIG Sync failure and
180-
* set BT_BAP_BIS_SYNC_FAILED
176+
/* If we are currently not synced (bis_sync == 0U) then we set the BIS sync to
177+
* BT_BAP_BIS_SYNC_FAILED to indicate a sync failure, unless the reason is
178+
* BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL (indicating a bad broadcast code). We treat this as a
179+
* special case due to current open errata https://bluetooth.atlassian.net/browse/ES-28435
180+
* and https://bluetooth.atlassian.net/browse/ES-28482 where the expected behavior is not
181+
* properly defined but the qualification tests expect the BIS sync value to be set to 0 in
182+
* case of a bad broadcast code.
183+
*
184+
* If we are already synced and this is called, then that indicates a sync lost, in which
185+
* case we set the BIS sync to 0.
181186
*/
182-
for (uint8_t i = 0U; i < recv_state->num_subgroups && !sink_is_streaming; i++) {
183-
sink_is_streaming = recv_state->subgroups[i].bis_sync != 0 &&
184-
recv_state->subgroups[i].bis_sync != BT_BAP_BIS_SYNC_FAILED;
185-
}
186-
187-
if (!sink_is_streaming) {
188-
/* BASS spec 3.1.1.5: Set Sync Failed when the server fails to sync to the BIG */
189-
for (uint8_t i = 0U; i < recv_state->num_subgroups; i++) {
190-
mod_src_param.subgroups[i].bis_sync = BT_BAP_BIS_SYNC_FAILED;
187+
for (uint8_t i = 0U; i < recv_state->num_subgroups; i++) {
188+
if (recv_state->subgroups[i].bis_sync == 0U) {
189+
if (reason == BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL) {
190+
mod_src_param.subgroups[i].bis_sync = 0U;
191+
} else {
192+
mod_src_param.subgroups[i].bis_sync = BT_BAP_BIS_SYNC_FAILED;
193+
}
194+
} else {
195+
mod_src_param.subgroups[i].bis_sync = 0U;
191196
}
192197
}
193198

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ static void bap_broadcast_assistant_recv_state_cb(
156156
for (uint8_t i = 0; i < state->num_subgroups; i++) {
157157
const struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i];
158158

159-
if (subgroup->bis_sync != BT_BAP_BIS_SYNC_FAILED) {
160-
FAIL("Invalid BIS sync value 0x%08X for failed sync\n",
159+
if (subgroup->bis_sync != 0U) {
160+
FAIL("Invalid BIS sync value 0x%08X for bad broadcast code\n",
161161
subgroup->bis_sync);
162162
return;
163163
}

0 commit comments

Comments
 (0)