Commit 405492f0 authored by Lars Knudsen's avatar Lars Knudsen Committed by Anas Nashif
Browse files

Bluetooth: Audio: Shell: Fix BIS sync bit field validity check



NO PREF (0xFFFFFFFF) and BIT(0) was wrongly rejected.

Signed-off-by: default avatarLars Knudsen <LAKD@demant.com>
parent 7f1589e2
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -41,6 +41,18 @@
extern "C" {
#endif

/**
 * @brief Check if a BAP BASS BIS_Sync bitfield is valid
 *
 * Valid options are eiter a bitmask of valid BIS indices, including none (0x00000000)
 * or @ref BT_BAP_BIS_SYNC_NO_PREF (0xFFFFFFFF).
 *
 * @param _bis_bitfield BIS_Sync bitfield (uint32)
 */
#define BT_BAP_BASS_VALID_BIT_BITFIELD(_bis_bitfield)                                              \
	((_bis_bitfield) == 0U || (_bis_bitfield) == BT_BAP_BIS_SYNC_NO_PREF ||                    \
	 BT_ISO_VALID_BIS_BITFIELD(_bis_bitfield))

/**
 * @brief Helper to declare elements of bt_bap_qos_cfg
 *
+0 −3
Original line number Diff line number Diff line
@@ -37,9 +37,6 @@
#define SHELL_PRINT_INDENT_LEVEL_SIZE 2
#define MAX_CODEC_FRAMES_PER_SDU      4U

/* BIS sync is a 32-bit bitfield where BIT(0) is not allowed */
#define VALID_BIS_SYNC(_bis_sync) ((bis_sync & BIT(0)) == 0U && bis_sync < UINT32_MAX)

extern struct bt_csip_set_member_svc_inst *svc_inst;

ssize_t audio_ad_data_add(struct bt_data *data, const size_t data_size, const bool discoverable,
+4 −4
Original line number Diff line number Diff line
@@ -439,7 +439,7 @@ static int cmd_bap_broadcast_assistant_add_src(const struct shell *sh,
			return -ENOEXEC;
		}

		if (!VALID_BIS_SYNC(bis_sync)) {
		if (!BT_BAP_BASS_VALID_BIT_BITFIELD(bis_sync)) {
			shell_error(sh, "Invalid bis_sync: %lu", bis_sync);

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

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

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

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

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

		if (!VALID_BIS_SYNC(bis_sync)) {
		if (!BT_BAP_BASS_VALID_BIT_BITFIELD(bis_sync)) {
			shell_error(sh, "Invalid bis_sync: %lu", bis_sync);

			return -ENOEXEC;
+1 −1
Original line number Diff line number Diff line
@@ -605,7 +605,7 @@ static int cmd_cap_commander_broadcast_reception_start(const struct shell *sh, s
			return -ENOEXEC;
		}

		if (!VALID_BIS_SYNC(bis_sync)) {
		if (!BT_BAP_BASS_VALID_BIT_BITFIELD(bis_sync)) {
			shell_error(sh, "Invalid bis_sync: %lu", bis_sync);

			return -ENOEXEC;