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.
This commit is contained in:
Marcin Kraglak 2014-04-25 14:28:44 +02:00 committed by Szymon Janc
parent de16594cd9
commit d11de55a40
2 changed files with 19 additions and 0 deletions

View File

@ -57,6 +57,7 @@ struct gatt_db_attribute {
}; };
struct gatt_db_service { struct gatt_db_service {
bool active;
uint16_t num_handles; uint16_t num_handles;
struct gatt_db_attribute **attributes; 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); 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;
}

View File

@ -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 gatt_db_add_included_service(struct gatt_db *db, uint16_t handle,
uint16_t included_handle); uint16_t included_handle);
bool gatt_db_service_set_active(struct gatt_db *db, uint16_t handle,
bool active);