Bluetooth: has: Introduce BT_HAS_PRESET_SUPPORT helper symbol

Introduce invisible helper symbol that could simplify and make more
readable condiitional code checks.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit is contained in:
Mariusz Skamra 2022-05-12 10:45:18 +02:00 committed by Carles Cufí
commit e5aad57fc5
2 changed files with 11 additions and 8 deletions

View file

@ -30,7 +30,7 @@
static struct bt_has has;
#if CONFIG_BT_HAS_PRESET_COUNT > 0
#if defined(CONFIG_BT_HAS_PRESET_SUPPORT)
static ssize_t write_control_point(struct bt_conn *conn, const struct bt_gatt_attr *attr,
const void *data, uint16_t len, uint16_t offset, uint8_t flags);
@ -46,7 +46,7 @@ static ssize_t read_active_preset_index(struct bt_conn *conn, const struct bt_ga
return bt_gatt_attr_read(conn, attr, buf, len, offset, &has.active_index,
sizeof(has.active_index));
}
#endif /* CONFIG_BT_HAS_PRESET_COUNT > 0 */
#endif /* CONFIG_BT_HAS_PRESET_SUPPORT */
static ssize_t read_features(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf,
uint16_t len, uint16_t offset)
@ -71,7 +71,7 @@ BT_GATT_SERVICE_DEFINE(has_svc,
BT_GATT_PRIMARY_SERVICE(BT_UUID_HAS),
BT_GATT_CHARACTERISTIC(BT_UUID_HAS_HEARING_AID_FEATURES, BT_GATT_CHRC_READ,
BT_GATT_PERM_READ_ENCRYPT, read_features, NULL, NULL),
#if CONFIG_BT_HAS_PRESET_COUNT > 0
#if defined(CONFIG_BT_HAS_PRESET_SUPPORT)
BT_GATT_CHARACTERISTIC(BT_UUID_HAS_PRESET_CONTROL_POINT,
#if defined(CONFIG_BT_EATT)
BT_GATT_CHRC_WRITE | BT_GATT_CHRC_INDICATE | BT_GATT_CHRC_NOTIFY,
@ -84,10 +84,10 @@ BT_GATT_SERVICE_DEFINE(has_svc,
BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, BT_GATT_PERM_READ_ENCRYPT,
read_active_preset_index, NULL, NULL),
BT_GATT_CCC(ccc_cfg_changed, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE_ENCRYPT),
#endif /* CONFIG_BT_HAS_PRESET_COUNT > 0 */
#endif /* CONFIG_BT_HAS_PRESET_SUPPORT */
);
#if CONFIG_BT_HAS_PRESET_COUNT > 0
#if defined(CONFIG_BT_HAS_PRESET_SUPPORT)
#define PRESET_CONTROL_POINT_ATTR &has_svc.attrs[4]
static struct has_client {
@ -706,7 +706,7 @@ void bt_has_preset_foreach(uint8_t index, bt_has_preset_func_t func, void *user_
preset_foreach(start_index, end_index, bt_has_preset_foreach_func, &data);
}
#endif /* CONFIG_BT_HAS_PRESET_COUNT > 0 */
#endif /* CONFIG_BT_HAS_PRESET_SUPPORT */
static int has_init(const struct device *dev)
{