From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> This adds gatt_db_attribute_get_service which can be used to get the service which the given attribute belongs to. --- src/shared/gatt-db.c | 9 +++++++++ src/shared/gatt-db.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 9a92090ec493..b696fe33da93 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -1712,6 +1712,15 @@ uint16_t gatt_db_attribute_get_handle(const struct gatt_db_attribute *attrib) return attrib->handle; } +struct gatt_db_attribute * +gatt_db_attribute_get_service(const struct gatt_db_attribute *attrib) +{ + if (!attrib) + return NULL; + + return attrib->service->attributes[0]; +} + bool gatt_db_attribute_get_service_uuid(const struct gatt_db_attribute *attrib, bt_uuid_t *uuid) { diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h index 41464ad3e7e0..163a981df233 100644 --- a/src/shared/gatt-db.h +++ b/src/shared/gatt-db.h @@ -225,6 +225,9 @@ const bt_uuid_t *gatt_db_attribute_get_type( uint16_t gatt_db_attribute_get_handle(const struct gatt_db_attribute *attrib); +struct gatt_db_attribute * +gatt_db_attribute_get_service(const struct gatt_db_attribute *attrib); + bool gatt_db_attribute_get_service_uuid(const struct gatt_db_attribute *attrib, bt_uuid_t *uuid); -- 2.37.3