Skip to content

Commit 405492f

Browse files
larsgknashif
authored andcommitted
Bluetooth: Audio: Shell: Fix BIS sync bit field validity check
NO PREF (0xFFFFFFFF) and BIT(0) was wrongly rejected. Signed-off-by: Lars Knudsen <[email protected]>
1 parent 7f1589e commit 405492f

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

include/zephyr/bluetooth/audio/bap.h

+12
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@
4141
extern "C" {
4242
#endif
4343

44+
/**
45+
* @brief Check if a BAP BASS BIS_Sync bitfield is valid
46+
*
47+
* Valid options are eiter a bitmask of valid BIS indices, including none (0x00000000)
48+
* or @ref BT_BAP_BIS_SYNC_NO_PREF (0xFFFFFFFF).
49+
*
50+
* @param _bis_bitfield BIS_Sync bitfield (uint32)
51+
*/
52+
#define BT_BAP_BASS_VALID_BIT_BITFIELD(_bis_bitfield) \
53+
((_bis_bitfield) == 0U || (_bis_bitfield) == BT_BAP_BIS_SYNC_NO_PREF || \
54+
BT_ISO_VALID_BIS_BITFIELD(_bis_bitfield))
55+
4456
/**
4557
* @brief Helper to declare elements of bt_bap_qos_cfg
4658
*

subsys/bluetooth/audio/shell/audio.h

-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@
3737
#define SHELL_PRINT_INDENT_LEVEL_SIZE 2
3838
#define MAX_CODEC_FRAMES_PER_SDU 4U
3939

40-
/* BIS sync is a 32-bit bitfield where BIT(0) is not allowed */
41-
#define VALID_BIS_SYNC(_bis_sync) ((bis_sync & BIT(0)) == 0U && bis_sync < UINT32_MAX)
42-
4340
extern struct bt_csip_set_member_svc_inst *svc_inst;
4441

4542
ssize_t audio_ad_data_add(struct bt_data *data, const size_t data_size, const bool discoverable,

subsys/bluetooth/audio/shell/bap_broadcast_assistant.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ static int cmd_bap_broadcast_assistant_add_src(const struct shell *sh,
439439
return -ENOEXEC;
440440
}
441441

442-
if (!VALID_BIS_SYNC(bis_sync)) {
442+
if (!BT_BAP_BASS_VALID_BIT_BITFIELD(bis_sync)) {
443443
shell_error(sh, "Invalid bis_sync: %lu", bis_sync);
444444

445445
return -ENOEXEC;
@@ -667,7 +667,7 @@ static int cmd_bap_broadcast_assistant_add_broadcast_id(const struct shell *sh,
667667
shell_error(sh, "failed to parse bis_sync: %d", err);
668668

669669
return -ENOEXEC;
670-
} else if (!VALID_BIS_SYNC(bis_sync)) {
670+
} else if (!BT_BAP_BASS_VALID_BIT_BITFIELD(bis_sync)) {
671671
shell_error(sh, "Invalid bis_sync: %lu", bis_sync);
672672

673673
return -ENOEXEC;
@@ -735,7 +735,7 @@ static int cmd_bap_broadcast_assistant_add_broadcast_name(const struct shell *sh
735735
shell_error(sh, "failed to parse bis_sync: %d", err);
736736

737737
return -ENOEXEC;
738-
} else if (!VALID_BIS_SYNC(bis_sync)) {
738+
} else if (!BT_BAP_BASS_VALID_BIT_BITFIELD(bis_sync)) {
739739
shell_error(sh, "Invalid bis_sync: %lu", bis_sync);
740740

741741
return -ENOEXEC;
@@ -836,7 +836,7 @@ static int cmd_bap_broadcast_assistant_mod_src(const struct shell *sh,
836836
return -ENOEXEC;
837837
}
838838

839-
if (!VALID_BIS_SYNC(bis_sync)) {
839+
if (!BT_BAP_BASS_VALID_BIT_BITFIELD(bis_sync)) {
840840
shell_error(sh, "Invalid bis_sync: %lu", bis_sync);
841841

842842
return -ENOEXEC;

subsys/bluetooth/audio/shell/cap_commander.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ static int cmd_cap_commander_broadcast_reception_start(const struct shell *sh, s
605605
return -ENOEXEC;
606606
}
607607

608-
if (!VALID_BIS_SYNC(bis_sync)) {
608+
if (!BT_BAP_BASS_VALID_BIT_BITFIELD(bis_sync)) {
609609
shell_error(sh, "Invalid bis_sync: %lu", bis_sync);
610610

611611
return -ENOEXEC;

0 commit comments

Comments
 (0)