Skip to content

Commit e182d75

Browse files
joerchanjhedberg
authored andcommitted
Bluetooth: host: Fix gatt indicate when conn is NULL
Fix gatt indicate when conn is NULL and called with characteristic declaration as the attribute argument. In this case the handle was not advanced to the characteristic value. This is inconsistent with the rest of the notify and indicate API Signed-off-by: Joakim Andersson <[email protected]>
1 parent 82497ec commit e182d75

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

subsys/bluetooth/host/gatt.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,17 +1388,6 @@ static int gatt_indicate(struct bt_conn *conn, u16_t handle,
13881388
}
13891389
#endif
13901390

1391-
/* Check if attribute is a characteristic then adjust the handle */
1392-
if (!bt_uuid_cmp(params->attr->uuid, BT_UUID_GATT_CHRC)) {
1393-
struct bt_gatt_chrc *chrc = params->attr->user_data;
1394-
1395-
if (!(chrc->properties & BT_GATT_CHRC_INDICATE)) {
1396-
return -EINVAL;
1397-
}
1398-
1399-
handle++;
1400-
}
1401-
14021391
buf = bt_att_create_pdu(conn, BT_ATT_OP_INDICATE,
14031392
sizeof(*ind) + params->len);
14041393
if (!buf) {
@@ -1615,6 +1604,17 @@ int bt_gatt_indicate(struct bt_conn *conn,
16151604
return -ENOENT;
16161605
}
16171606

1607+
/* Check if attribute is a characteristic then adjust the handle */
1608+
if (!bt_uuid_cmp(params->attr->uuid, BT_UUID_GATT_CHRC)) {
1609+
struct bt_gatt_chrc *chrc = params->attr->user_data;
1610+
1611+
if (!(chrc->properties & BT_GATT_CHRC_INDICATE)) {
1612+
return -EINVAL;
1613+
}
1614+
1615+
handle++;
1616+
}
1617+
16181618
if (conn) {
16191619
return gatt_indicate(conn, handle, params);
16201620
}

0 commit comments

Comments
 (0)