Bluetooth: has: Fix HAS features value

The bt_has_register_param's preset_sync_support and independent_presets
make sense only if CONFIG_BT_HAS_PRESET_COUNT is non-zero meaning the
CONFIG_BT_HAS_PRESET_SUPPORT is enabled.
Otherwise, those parameters shall be skipped.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit is contained in:
Mariusz Skamra 2023-01-12 10:51:19 +01:00 committed by Carles Cufí
commit 80f87b9480
2 changed files with 27 additions and 15 deletions

View file

@ -72,10 +72,20 @@ struct bt_has_register_param {
/** Hearing Aid Type value */
enum bt_has_hearing_aid_type type;
/** Preset Synchronization Support. Only applicable for binaural hearing aids. */
/**
* @brief Preset Synchronization Support.
*
* Only applicable if @p type is @ref BT_HAS_HEARING_AID_TYPE_BINAURAL
* and @kconfig{CONFIG_BT_HAS_PRESET_COUNT} is non-zero.
*/
bool preset_sync_support;
/** Independent Presets. Only applicable for binaural hearing aids. */
/**
* @brief Independent Presets.
*
* Only applicable if @p type is @ref BT_HAS_HEARING_AID_TYPE_BINAURAL
* and @kconfig{CONFIG_BT_HAS_PRESET_COUNT} is non-zero.
*/
bool independent_presets;
};

View file

@ -1142,11 +1142,11 @@ int bt_has_register(const struct bt_has_register_param *param)
if (IS_ENABLED(CONFIG_BT_HAS_PRESET_SUPPORT)) {
has.features |= BT_HAS_FEAT_DYNAMIC_PRESETS;
}
if (param->preset_sync_support) {
if (param->type != BT_HAS_HEARING_AID_TYPE_BINAURAL) {
LOG_DBG("Preset sync support only available for binaural hearing aid type");
LOG_DBG("Preset sync support only available "
"for binaural hearing aid type");
return -EINVAL;
}
@ -1155,12 +1155,14 @@ int bt_has_register(const struct bt_has_register_param *param)
if (param->independent_presets) {
if (param->type != BT_HAS_HEARING_AID_TYPE_BINAURAL) {
LOG_DBG("Independent presets only available for binaural hearing aid type");
LOG_DBG("Independent presets only available "
"for binaural hearing aid type");
return -EINVAL;
}
has.features |= BT_HAS_FEAT_INDEPENDENT_PRESETS;
}
}
if (IS_ENABLED(CONFIG_BT_HAS_PRESET_NAME_DYNAMIC)) {
has.features |= BT_HAS_FEAT_WRITABLE_PRESETS_SUPP;