Skip to content

Commit f24ba75

Browse files
Thalleyfabiobaltieri
authored andcommitted
Bluetooth: BAP: BA: Add check for mixing NO_PREF with specific BIS
Based on a dicussion on the Bluetooth SIG GAWG reflector, it is not allowed for a broadcast assistant to request specific BIS indexes as well as BT_BAP_BIS_SYNC_NO_PREF in the same request. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
1 parent de4752c commit f24ba75

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

subsys/bluetooth/audio/bap_broadcast_assistant.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,30 @@ static bool bis_syncs_unique_or_no_pref(uint32_t requested_bis_syncs, uint32_t a
12671267
return (requested_bis_syncs & aggregated_bis_syncs) != 0U;
12681268
}
12691269

1270+
static bool valid_bis_sync_request(uint32_t requested_bis_syncs, uint32_t aggregated_bis_syncs)
1271+
{
1272+
/* Verify that the request BIS sync indexes are unique or no preference */
1273+
if (!bis_syncs_unique_or_no_pref(requested_bis_syncs, aggregated_bis_syncs)) {
1274+
LOG_DBG("Duplicate BIS index 0x%08x (aggregated %x)", requested_bis_syncs,
1275+
aggregated_bis_syncs);
1276+
return false;
1277+
}
1278+
1279+
if (requested_bis_syncs != BT_BAP_BIS_SYNC_NO_PREF &&
1280+
aggregated_bis_syncs == BT_BAP_BIS_SYNC_NO_PREF) {
1281+
LOG_DBG("Invalid BIS index 0x%08X mixing BT_BAP_BIS_SYNC_NO_PREF and specific BIS",
1282+
requested_bis_syncs);
1283+
return false;
1284+
}
1285+
1286+
if (!valid_bis_syncs(requested_bis_syncs)) {
1287+
LOG_DBG("Invalid BIS sync: 0x%08X", requested_bis_syncs);
1288+
return false;
1289+
}
1290+
1291+
return true;
1292+
}
1293+
12701294
static bool valid_subgroup_params(uint8_t pa_sync, const struct bt_bap_bass_subgroup subgroups[],
12711295
uint8_t num_subgroups)
12721296
{
@@ -1284,17 +1308,14 @@ static bool valid_subgroup_params(uint8_t pa_sync, const struct bt_bap_bass_subg
12841308
}
12851309

12861310
/* Verify that the request BIS sync indexes are unique or no preference */
1287-
if (!bis_syncs_unique_or_no_pref(subgroups[i].bis_sync, aggregated_bis_syncs)) {
1288-
LOG_DBG("[%u]: Duplicate BIS index 0x%08x (aggregated 0x%08x)", i,
1289-
subgroups[i].bis_sync, aggregated_bis_syncs);
1311+
if (!valid_bis_sync_request(subgroups[i].bis_sync, aggregated_bis_syncs)) {
1312+
LOG_DBG("Invalid BIS Sync request[%d]", i);
12901313

12911314
return false;
12921315
}
12931316

12941317
/* Keep track of BIS sync values to ensure that we do not have duplicates */
1295-
if (subgroups[i].bis_sync != BT_BAP_BIS_SYNC_NO_PREF) {
1296-
aggregated_bis_syncs |= subgroups[i].bis_sync;
1297-
}
1318+
aggregated_bis_syncs |= subgroups[i].bis_sync;
12981319

12991320
#if defined(CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE)
13001321
if (subgroups[i].metadata_len > CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE) {

0 commit comments

Comments
 (0)