From d11de55a40629629a779911acba5b7dc1d3f5764 Mon Sep 17 00:00:00 2001 From: Marcin Kraglak Date: Fri, 25 Apr 2014 14:28:44 +0200 Subject: [PATCH] shared/gatt: Add method to set service active This function will set active flag in database. Only active services can be read by client from database. This falg will be checked when remote will read attributes from this database. Non-active services won't be exposed. --- src/shared/gatt-db.c | 16 ++++++++++++++++ src/shared/gatt-db.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 1a8469bed..5d732e8d5 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -57,6 +57,7 @@ struct gatt_db_attribute { }; struct gatt_db_service { + bool active; uint16_t num_handles; struct gatt_db_attribute **attributes; }; @@ -379,3 +380,18 @@ uint16_t gatt_db_add_included_service(struct gatt_db *db, uint16_t handle, return update_attribute_handle(service, index); } + +bool gatt_db_service_set_active(struct gatt_db *db, uint16_t handle, + bool active) +{ + struct gatt_db_service *service; + + service = queue_find(db->services, match_service_by_handle, + INT_TO_PTR(handle)); + if (!service) + return false; + + service->active = active; + + return true; +} diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h index e6e8331c3..f68f4b357 100644 --- a/src/shared/gatt-db.h +++ b/src/shared/gatt-db.h @@ -54,3 +54,6 @@ uint16_t gatt_db_add_char_descriptor(struct gatt_db *db, uint16_t handle, uint16_t gatt_db_add_included_service(struct gatt_db *db, uint16_t handle, uint16_t included_handle); + +bool gatt_db_service_set_active(struct gatt_db *db, uint16_t handle, + bool active); -- 2.47.3