Skip to content
Permalink
Browse files

Bluetooth: GATT: Make use of bt_gatt_foreach_attr_type on bt_gatt_notify

This make use of bt_gatt_foreach_attr_type to match the CCC UUID which
previously was not possible with bt_gatt_foreach_attr.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information...
Vudentz authored and jhedberg committed May 24, 2019
1 parent a5c07aa commit e6ef539667c689181f35cc1d15c0efbf50286a63
Showing with 4 additions and 10 deletions.
  1. +4 −10 subsys/bluetooth/host/gatt.c
@@ -1459,14 +1459,6 @@ static u8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data)
struct _bt_gatt_ccc *ccc;
size_t i;

if (bt_uuid_cmp(attr->uuid, BT_UUID_GATT_CCC)) {
/* Stop if we reach the next characteristic */
if (!bt_uuid_cmp(attr->uuid, BT_UUID_GATT_CHRC)) {
return BT_GATT_ITER_STOP;
}
return BT_GATT_ITER_CONTINUE;
}

/* Check attribute user_data must be of type struct _bt_gatt_ccc */
if (attr->write != bt_gatt_attr_write_ccc) {
return BT_GATT_ITER_CONTINUE;
@@ -1565,7 +1557,8 @@ int bt_gatt_notify_cb(struct bt_conn *conn, const struct bt_gatt_attr *attr,
nfy.data = data;
nfy.len = len;

bt_gatt_foreach_attr(handle, 0xffff, notify_cb, &nfy);
bt_gatt_foreach_attr_type(handle, 0xffff, BT_UUID_GATT_CCC, NULL, 1,
notify_cb, &nfy);

return nfy.err;
}
@@ -1592,7 +1585,8 @@ int bt_gatt_indicate(struct bt_conn *conn,
nfy.type = BT_GATT_CCC_INDICATE;
nfy.params = params;

bt_gatt_foreach_attr(handle, 0xffff, notify_cb, &nfy);
bt_gatt_foreach_attr_type(handle, 0xffff, BT_UUID_GATT_CCC, NULL, 1,
notify_cb, &nfy);

return nfy.err;
}

0 comments on commit e6ef539

Please sign in to comment.
You can’t perform that action at this time.