Bluetooth: host: Add helper function to find an attribute from its uuid
Expose a helper function to the application that searches the local database for the given attribute from its UUID. Provide arguments to limit the search that matches the service declaration to make it easy to limit the search to a specific service. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
3ad3a72caf
commit
b4ce2ba481
2 changed files with 33 additions and 0 deletions
|
@ -2254,6 +2254,21 @@ static bool gatt_find_by_uuid(struct notify_data *found,
|
|||
return found->attr ? true : false;
|
||||
}
|
||||
|
||||
struct bt_gatt_attr *bt_gatt_find_by_uuid(const struct bt_gatt_attr *attr,
|
||||
uint16_t attr_count,
|
||||
const struct bt_uuid *uuid)
|
||||
{
|
||||
struct bt_gatt_attr *found = NULL;
|
||||
uint16_t start_handle = bt_gatt_attr_value_handle(attr);
|
||||
uint16_t end_handle = start_handle && attr_count ?
|
||||
start_handle + attr_count : 0xffff;
|
||||
|
||||
bt_gatt_foreach_attr_type(start_handle, end_handle, uuid, NULL, 1,
|
||||
find_next, &found);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
int bt_gatt_notify_cb(struct bt_conn *conn,
|
||||
struct bt_gatt_notify_params *params)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue