Bluetooth: GATT: Replace magic number 0 with macro for auto ccc

Replace the magic number 0 with a #defined value for
the auto CCC discovery feature.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2024-09-24 14:19:15 +02:00 committed by Anas Nashif
commit ec2c5b0c1f
18 changed files with 34 additions and 45 deletions

View file

@ -227,8 +227,8 @@ static struct bt_gatt_discover_params disc_params_short;
static struct bt_gatt_subscribe_params sub_params_short = {
.notify = test_notify,
.subscribe = test_short_subscribed,
.ccc_handle = 0, /* Auto-discover CCC*/
.disc_params = &disc_params_short, /* Auto-discover CCC */
.ccc_handle = BT_GATT_AUTO_DISCOVER_CCC_HANDLE,
.disc_params = &disc_params_short,
.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE,
.value = BT_GATT_CCC_NOTIFY,
};
@ -236,8 +236,8 @@ static struct bt_gatt_discover_params disc_params_long;
static struct bt_gatt_subscribe_params sub_params_long = {
.notify = test_notify,
.subscribe = test_long_subscribed,
.ccc_handle = 0, /* Auto-discover CCC*/
.disc_params = &disc_params_long, /* Auto-discover CCC */
.ccc_handle = BT_GATT_AUTO_DISCOVER_CCC_HANDLE,
.disc_params = &disc_params_long,
.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE,
.value = BT_GATT_CCC_NOTIFY,
};

View file

@ -230,8 +230,8 @@ static struct bt_gatt_discover_params disc_params_short;
static struct bt_gatt_subscribe_params sub_params_short = {
.notify = test_notify,
.subscribe = test_subscribed,
.ccc_handle = 0, /* Auto-discover CCC*/
.disc_params = &disc_params_short, /* Auto-discover CCC */
.ccc_handle = BT_GATT_AUTO_DISCOVER_CCC_HANDLE,
.disc_params = &disc_params_short,
.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE,
.value = BT_GATT_CCC_NOTIFY,
};
@ -239,8 +239,8 @@ static struct bt_gatt_discover_params disc_params_long;
static struct bt_gatt_subscribe_params sub_params_long = {
.notify = test_notify,
.subscribe = test_subscribed,
.ccc_handle = 0, /* Auto-discover CCC*/
.disc_params = &disc_params_long, /* Auto-discover CCC */
.ccc_handle = BT_GATT_AUTO_DISCOVER_CCC_HANDLE,
.disc_params = &disc_params_long,
.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE,
.value = BT_GATT_CCC_NOTIFY,
};

View file

@ -206,8 +206,7 @@ void gatt_subscribe_to_service_changed(bool subscribe)
subscribe_params.subscribe = sc_subscribed;
if (subscribe) {
/* Use the BT_GATT_AUTO_DISCOVER_CCC feature */
subscribe_params.ccc_handle = 0;
subscribe_params.ccc_handle = BT_GATT_AUTO_DISCOVER_CCC_HANDLE;
subscribe_params.disc_params = &disc_params,
subscribe_params.value = BT_GATT_CCC_INDICATE;
subscribe_params.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE;