Skip to content

Commit 0813966

Browse files
Thalleymbolivar-nordic
authored andcommitted
Bluetooth: GATT: Remove use of BT_GATT_ATTRIBUTE macro for discover results
The macro was remove for the GATT discover callbacks, as only 2 out of 5 parameters for BT_GATT_ATTRIBUTE were used. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 7b601b7 commit 0813966

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

subsys/bluetooth/host/gatt.c

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3258,10 +3258,11 @@ static void gatt_find_type_rsp(struct bt_conn *conn, uint8_t err,
32583258
value.end_handle = end_handle;
32593259
value.uuid = params->uuid;
32603260

3261-
attr = (struct bt_gatt_attr)BT_GATT_ATTRIBUTE(&uuid_svc.uuid, 0,
3262-
NULL, NULL,
3263-
&value);
3264-
attr.handle = start_handle;
3261+
attr = (struct bt_gatt_attr) {
3262+
.uuid = &uuid_svc.uuid,
3263+
.user_data = &value,
3264+
.handle = start_handle,
3265+
};
32653266

32663267
if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) {
32673268
return;
@@ -3341,6 +3342,7 @@ static void read_included_uuid_cb(struct bt_conn *conn, uint8_t err,
33413342
struct bt_gatt_discover_params *params = user_data;
33423343
struct bt_gatt_include value;
33433344
struct bt_gatt_attr attr;
3345+
uint16_t handle;
33443346
union {
33453347
struct bt_uuid uuid;
33463348
struct bt_uuid_128 u128;
@@ -3352,6 +3354,7 @@ static void read_included_uuid_cb(struct bt_conn *conn, uint8_t err,
33523354
return;
33533355
}
33543356

3357+
handle = params->_included.attr_handle;
33553358
value.start_handle = params->_included.start_handle;
33563359
value.end_handle = params->_included.end_handle;
33573360
value.uuid = &u.uuid;
@@ -3367,9 +3370,11 @@ static void read_included_uuid_cb(struct bt_conn *conn, uint8_t err,
33673370
goto next;
33683371
}
33693372

3370-
attr = (struct bt_gatt_attr)BT_GATT_ATTRIBUTE(
3371-
BT_UUID_GATT_INCLUDE, 0, NULL, NULL, &value);
3372-
attr.handle = params->_included.attr_handle;
3373+
attr = (struct bt_gatt_attr) {
3374+
.uuid = BT_UUID_GATT_INCLUDE,
3375+
.user_data = &value,
3376+
.handle = handle,
3377+
};
33733378

33743379
if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) {
33753380
return;
@@ -3474,9 +3479,11 @@ static uint16_t parse_include(struct bt_conn *conn, const void *pdu,
34743479
continue;
34753480
}
34763481

3477-
attr = (struct bt_gatt_attr)BT_GATT_ATTRIBUTE(
3478-
BT_UUID_GATT_INCLUDE, 0, NULL, NULL, &value);
3479-
attr.handle = handle;
3482+
attr = (struct bt_gatt_attr) {
3483+
.uuid = BT_UUID_GATT_INCLUDE,
3484+
.user_data = &value,
3485+
.handle = handle,
3486+
};
34803487

34813488
if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) {
34823489
return 0;
@@ -3552,9 +3559,12 @@ static uint16_t parse_characteristic(struct bt_conn *conn, const void *pdu,
35523559
value = (struct bt_gatt_chrc)BT_GATT_CHRC_INIT(
35533560
&u.uuid, sys_le16_to_cpu(chrc->value_handle),
35543561
chrc->properties);
3555-
attr = (struct bt_gatt_attr)BT_GATT_ATTRIBUTE(
3556-
BT_UUID_GATT_CHRC, 0, NULL, NULL, &value);
3557-
attr.handle = handle;
3562+
3563+
attr = (struct bt_gatt_attr) {
3564+
.uuid = BT_UUID_GATT_CHRC,
3565+
.user_data = &value,
3566+
.handle = handle,
3567+
};
35583568

35593569
if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) {
35603570
return 0;
@@ -3628,9 +3638,11 @@ static uint16_t parse_read_std_char_desc(struct bt_conn *conn, const void *pdu,
36283638
goto done;
36293639
}
36303640

3631-
attr = (struct bt_gatt_attr)BT_GATT_ATTRIBUTE(
3632-
params->uuid, 0, NULL, NULL, &value);
3633-
attr.handle = handle;
3641+
attr = (struct bt_gatt_attr) {
3642+
.uuid = params->uuid,
3643+
.user_data = &value,
3644+
.handle = handle,
3645+
};
36343646

36353647
if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) {
36363648
return 0;
@@ -3947,9 +3959,11 @@ static void gatt_find_info_rsp(struct bt_conn *conn, uint8_t err,
39473959
}
39483960
}
39493961

3950-
attr = (struct bt_gatt_attr)BT_GATT_ATTRIBUTE(
3951-
&u.uuid, 0, NULL, NULL, NULL);
3952-
attr.handle = handle;
3962+
/* No user_data in this case */
3963+
attr = (struct bt_gatt_attr) {
3964+
.uuid = &u.uuid,
3965+
.handle = handle,
3966+
};
39533967

39543968
if (params->func(conn, &attr, params) == BT_GATT_ITER_STOP) {
39553969
return;

0 commit comments

Comments
 (0)