Bluetooth: GATT: Add BT_GATT_DISCOVER_ATTRIBUTE type
This adds BT_GATT_DISCOVER_ATTRIBUTE which can be used to discover any type of attribute in a given range. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
0aa10521f4
commit
bcf3d8e16b
2 changed files with 30 additions and 15 deletions
|
@ -887,6 +887,15 @@ enum {
|
|||
* as it may incur in extra round trips.
|
||||
*/
|
||||
BT_GATT_DISCOVER_DESCRIPTOR,
|
||||
/** Discover Attributes.
|
||||
*
|
||||
* Discover Attributes of any type.
|
||||
*
|
||||
* Note: The use of this type of discover is not recommended for
|
||||
* discovering in ranges across multiple services/characteristics as
|
||||
* it may incur in more round trips.
|
||||
*/
|
||||
BT_GATT_DISCOVER_ATTRIBUTE,
|
||||
};
|
||||
|
||||
/** @brief GATT Discover Attributes parameters */
|
||||
|
|
|
@ -2252,23 +2252,27 @@ static void gatt_find_info_rsp(struct bt_conn *conn, u8_t err,
|
|||
continue;
|
||||
}
|
||||
|
||||
/* Skip attributes that are not considered descriptors */
|
||||
if (params->type == BT_GATT_DISCOVER_DESCRIPTOR) {
|
||||
/* Skip attributes that are not considered
|
||||
* descriptors.
|
||||
*/
|
||||
if (!bt_uuid_cmp(&u.uuid, BT_UUID_GATT_PRIMARY) ||
|
||||
!bt_uuid_cmp(&u.uuid, BT_UUID_GATT_SECONDARY) ||
|
||||
!bt_uuid_cmp(&u.uuid, BT_UUID_GATT_INCLUDE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If Characteristic Declaration skip ahead as the next entry
|
||||
* must be its value.
|
||||
/* If Characteristic Declaration skip ahead as the next
|
||||
* entry must be its value.
|
||||
*/
|
||||
if (!bt_uuid_cmp(&u.uuid, bt_uuid_gatt_chrc)) {
|
||||
if (!bt_uuid_cmp(&u.uuid, BT_UUID_GATT_CHRC)) {
|
||||
if (length >= len) {
|
||||
pdu = (const u8_t *)pdu + len;
|
||||
length -= len;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
attr = (&(struct bt_gatt_attr)
|
||||
BT_GATT_DESCRIPTOR(&u.uuid, 0, NULL, NULL, NULL));
|
||||
|
@ -2345,6 +2349,8 @@ int bt_gatt_discover(struct bt_conn *conn,
|
|||
!bt_uuid_cmp(params->uuid, BT_UUID_GATT_CHRC)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
/* Fallthrough. */
|
||||
case BT_GATT_DISCOVER_ATTRIBUTE:
|
||||
return gatt_find_info(conn, params);
|
||||
default:
|
||||
BT_ERR("Invalid discovery type: %u", params->type);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue