From 4eaf6bfdbe09d33ecb8071051213c13ed3f4d1aa Mon Sep 17 00:00:00 2001 From: Marcin Kraglak Date: Thu, 15 May 2014 15:02:32 +0200 Subject: [PATCH] shared/gatt: Add function to get end group handle This function will return end group handle or zero if attribute not found. --- src/shared/gatt-db.c | 12 ++++++++++++ src/shared/gatt-db.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 0cca86f0f..2ac9f2d6a 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -751,3 +751,15 @@ const bt_uuid_t *gatt_db_get_attribute_type(struct gatt_db *db, return &attribute->uuid; } + +uint16_t gatt_db_get_end_handle(struct gatt_db *db, uint16_t handle) +{ + struct gatt_db_service *service; + + service = queue_find(db->services, find_service_for_handle, + INT_TO_PTR(handle)); + if (!service) + return 0; + + return service->attributes[0]->handle + service->num_handles - 1; +} diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h index 24bce213e..1a18fb75f 100644 --- a/src/shared/gatt-db.h +++ b/src/shared/gatt-db.h @@ -104,3 +104,5 @@ bool gatt_db_write(struct gatt_db *db, uint16_t handle, uint16_t offset, const bt_uuid_t *gatt_db_get_attribute_type(struct gatt_db *db, uint16_t handle); + +uint16_t gatt_db_get_end_handle(struct gatt_db *db, uint16_t handle); -- 2.47.3