Bluetooth: GATT: Allow Characterist to be used with bt_gatt_indicate
Since BT_GATT_CHARACTERISTIC now expands to 2 attributes it may be confusing to use bt_gatt_indicate as that expects the Value attribute to be given which is no longer visible, so this enables the user to use the Characteristic attribute in addition to its value. Fixes #8231 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
c3edc82fe7
commit
679a0b395f
1 changed files with 14 additions and 2 deletions
|
@ -685,6 +685,18 @@ static int gatt_indicate(struct bt_conn *conn,
|
||||||
{
|
{
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
struct bt_att_indicate *ind;
|
struct bt_att_indicate *ind;
|
||||||
|
u16_t value_handle = params->attr->handle;
|
||||||
|
|
||||||
|
/* Check if attribute is a characteristic then adjust the handle */
|
||||||
|
if (!bt_uuid_cmp(params->attr->uuid, BT_UUID_GATT_CHRC)) {
|
||||||
|
struct bt_gatt_chrc *chrc = params->attr->user_data;
|
||||||
|
|
||||||
|
if (!(chrc->properties & BT_GATT_CHRC_INDICATE)) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
value_handle += 1;
|
||||||
|
}
|
||||||
|
|
||||||
buf = bt_att_create_pdu(conn, BT_ATT_OP_INDICATE,
|
buf = bt_att_create_pdu(conn, BT_ATT_OP_INDICATE,
|
||||||
sizeof(*ind) + params->len);
|
sizeof(*ind) + params->len);
|
||||||
|
@ -693,10 +705,10 @@ static int gatt_indicate(struct bt_conn *conn,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
BT_DBG("conn %p handle 0x%04x", conn, params->attr->handle);
|
BT_DBG("conn %p handle 0x%04x", conn, value_handle);
|
||||||
|
|
||||||
ind = net_buf_add(buf, sizeof(*ind));
|
ind = net_buf_add(buf, sizeof(*ind));
|
||||||
ind->handle = sys_cpu_to_le16(params->attr->handle);
|
ind->handle = sys_cpu_to_le16(value_handle);
|
||||||
|
|
||||||
net_buf_add(buf, params->len);
|
net_buf_add(buf, params->len);
|
||||||
memcpy(ind->value, params->data, params->len);
|
memcpy(ind->value, params->data, params->len);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue