diff --git a/include/zephyr/bluetooth/audio/bap.h b/include/zephyr/bluetooth/audio/bap.h index 583644a37e8c8f..c6dbb1798f0e82 100644 --- a/include/zephyr/bluetooth/audio/bap.h +++ b/include/zephyr/bluetooth/audio/bap.h @@ -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 * diff --git a/subsys/bluetooth/audio/shell/audio.h b/subsys/bluetooth/audio/shell/audio.h index 8539725d5948f6..97478158324f0e 100644 --- a/subsys/bluetooth/audio/shell/audio.h +++ b/subsys/bluetooth/audio/shell/audio.h @@ -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, diff --git a/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c b/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c index d47e730d4ef910..d434f1a79450c0 100644 --- a/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c +++ b/subsys/bluetooth/audio/shell/bap_broadcast_assistant.c @@ -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; diff --git a/subsys/bluetooth/audio/shell/cap_commander.c b/subsys/bluetooth/audio/shell/cap_commander.c index 4531c68426e957..579039b34938c2 100644 --- a/subsys/bluetooth/audio/shell/cap_commander.c +++ b/subsys/bluetooth/audio/shell/cap_commander.c @@ -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;