Skip to content

Commit

Permalink
Bluetooth: Audio: Make HAS optional notify characteristics optional
Browse files Browse the repository at this point in the history
Added Kconfig options to make HAS characteristics that has notify as
optional property selectable and thus optional. These settings are
global, meaning that a chosen notify property will be used for all
registered has instances.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
  • Loading branch information
fredrikdanebjer authored and nashif committed May 26, 2023
1 parent 527591a commit 7457bcf
Show file tree
Hide file tree
Showing 9 changed files with 344 additions and 78 deletions.
19 changes: 15 additions & 4 deletions include/zephyr/bluetooth/audio/has.h
Expand Up @@ -68,8 +68,8 @@ enum bt_has_capabilities {
BT_HAS_PRESET_SUPPORT = BIT(0),
};

/** @brief Structure for registering a Hearing Access Service instance. */
struct bt_has_register_param {
/** @brief Structure for registering features of a Hearing Access Service instance. */
struct bt_has_features_param {
/** Hearing Aid Type value */
enum bt_has_hearing_aid_type type;

Expand Down Expand Up @@ -341,11 +341,11 @@ struct bt_has_preset_register_param {
/**
* @brief Register the Hearing Access Service instance.
*
* @param param Hearing Access Service register parameters.
* @param features Hearing Access Service register parameters.
*
* @return 0 if success, errno on failure.
*/
int bt_has_register(const struct bt_has_register_param *param);
int bt_has_register(const struct bt_has_features_param *features);

/**
* @brief Register preset.
Expand Down Expand Up @@ -470,6 +470,17 @@ static inline int bt_has_preset_active_clear(void)
*/
int bt_has_preset_name_change(uint8_t index, const char *name);

/**
* @brief Change the Hearing Aid Features.
*
* Change the hearing aid features.
*
* @param features The features to be set.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_features_set(const struct bt_has_features_param *features);

#ifdef __cplusplus
}
#endif
Expand Down
8 changes: 4 additions & 4 deletions samples/bluetooth/hap_ha/src/has_server.c
Expand Up @@ -75,7 +75,7 @@ int has_server_preset_init(void)
return 0;
}

static struct bt_has_register_param param = {
static struct bt_has_features_param features = {
.type = BT_HAS_HEARING_AID_TYPE_MONAURAL,
.preset_sync_support = false,
.independent_presets = false
Expand All @@ -86,12 +86,12 @@ int has_server_init(void)
int err;

if (IS_ENABLED(CONFIG_HAP_HA_HEARING_AID_BINAURAL)) {
param.type = BT_HAS_HEARING_AID_TYPE_BINAURAL;
features.type = BT_HAS_HEARING_AID_TYPE_BINAURAL;
} else if (IS_ENABLED(CONFIG_HAP_HA_HEARING_AID_BANDED)) {
param.type = BT_HAS_HEARING_AID_TYPE_BANDED;
features.type = BT_HAS_HEARING_AID_TYPE_BANDED;
}

err = bt_has_register(&param);
err = bt_has_register(&features);
if (err) {
return err;
}
Expand Down
18 changes: 18 additions & 0 deletions subsys/bluetooth/audio/Kconfig.has
Expand Up @@ -15,6 +15,12 @@ menuconfig BT_HAS

if BT_HAS

config BT_HAS_FEATURES_NOTIFIABLE
bool "Hearing Aid Features Notifiable Support"
help
This option enables support for clients to subscribe for notifications
on the Hearing Aid Features characteristic.

config BT_HAS_PRESET_COUNT
int "Preset record list size"
default 2
Expand All @@ -33,6 +39,18 @@ config BT_HAS_PRESET_NAME_DYNAMIC
help
Enabling this option allows for runtime configuration of preset name.

config BT_HAS_PRESET_CONTROL_POINT_NOTIFIABLE
bool "Preset Control Point Notifiable support"
depends on BT_HAS_PRESET_SUPPORT && BT_EATT
help
This option enables support for clients to subscribe for notifications
on the Hearing Aid Preset Control Point characteristic.

config BT_HAS_ACTIVE_PRESET_INDEX
def_bool BT_HAS_PRESET_SUPPORT
help
This option enables the Hearing Aid Active Preset Index characteristic.

endif # BT_HAS_PRESET_SUPPORT

endif # BT_HAS
Expand Down

0 comments on commit 7457bcf

Please sign in to comment.