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.
|
* as it may incur in extra round trips.
|
||||||
*/
|
*/
|
||||||
BT_GATT_DISCOVER_DESCRIPTOR,
|
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 */
|
/** @brief GATT Discover Attributes parameters */
|
||||||
|
|
|
@ -2252,22 +2252,26 @@ static void gatt_find_info_rsp(struct bt_conn *conn, u8_t err,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip attributes that are not considered descriptors */
|
if (params->type == BT_GATT_DISCOVER_DESCRIPTOR) {
|
||||||
if (!bt_uuid_cmp(&u.uuid, BT_UUID_GATT_PRIMARY) ||
|
/* Skip attributes that are not considered
|
||||||
!bt_uuid_cmp(&u.uuid, BT_UUID_GATT_SECONDARY) ||
|
* descriptors.
|
||||||
!bt_uuid_cmp(&u.uuid, BT_UUID_GATT_INCLUDE)) {
|
*/
|
||||||
continue;
|
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)) {
|
||||||
/* If Characteristic Declaration skip ahead as the next entry
|
continue;
|
||||||
* must be its value.
|
}
|
||||||
*/
|
|
||||||
if (!bt_uuid_cmp(&u.uuid, bt_uuid_gatt_chrc)) {
|
/* If Characteristic Declaration skip ahead as the next
|
||||||
if (length >= len) {
|
* entry must be its value.
|
||||||
pdu = (const u8_t *)pdu + len;
|
*/
|
||||||
length -= len;
|
if (!bt_uuid_cmp(&u.uuid, BT_UUID_GATT_CHRC)) {
|
||||||
|
if (length >= len) {
|
||||||
|
pdu = (const u8_t *)pdu + len;
|
||||||
|
length -= len;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
attr = (&(struct bt_gatt_attr)
|
attr = (&(struct bt_gatt_attr)
|
||||||
|
@ -2345,6 +2349,8 @@ int bt_gatt_discover(struct bt_conn *conn,
|
||||||
!bt_uuid_cmp(params->uuid, BT_UUID_GATT_CHRC)) {
|
!bt_uuid_cmp(params->uuid, BT_UUID_GATT_CHRC)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
/* Fallthrough. */
|
||||||
|
case BT_GATT_DISCOVER_ATTRIBUTE:
|
||||||
return gatt_find_info(conn, params);
|
return gatt_find_info(conn, params);
|
||||||
default:
|
default:
|
||||||
BT_ERR("Invalid discovery type: %u", params->type);
|
BT_ERR("Invalid discovery type: %u", params->type);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue