From b91d9213d951277896845830d0680061c7643828 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 16 Dec 2022 16:56:05 -0800 Subject: [PATCH] shared/gatt-db: Add gatt_db_attribute_get_service 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 9a92090ec..b696fe33d 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 41464ad3e..163a981df 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.47.3