mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-15 23:14:38 +08:00
shared/gatt-db: Add gatt_db_service_insert_included
This introduces gatt_db_service_insert_included which is a variant of gatt_db_service_add_included containing the handle where it should be inserted.
This commit is contained in:
parent
ba07a8bfc0
commit
108336ee3e
@ -834,19 +834,15 @@ gatt_db_service_add_descriptor(struct gatt_db_attribute *attrib,
|
||||
user_data);
|
||||
}
|
||||
|
||||
struct gatt_db_attribute *
|
||||
gatt_db_service_add_included(struct gatt_db_attribute *attrib,
|
||||
static struct gatt_db_attribute *
|
||||
service_insert_included(struct gatt_db_service *service, uint16_t handle,
|
||||
struct gatt_db_attribute *include)
|
||||
{
|
||||
struct gatt_db_service *service, *included;
|
||||
struct gatt_db_service *included;
|
||||
uint8_t value[MAX_INCLUDED_VALUE_LEN];
|
||||
uint16_t included_handle, len = 0;
|
||||
int index;
|
||||
|
||||
if (!attrib || !include)
|
||||
return NULL;
|
||||
|
||||
service = attrib->service;
|
||||
included = include->service;
|
||||
|
||||
/* Adjust include to point to the first attribute */
|
||||
@ -873,7 +869,14 @@ gatt_db_service_add_included(struct gatt_db_attribute *attrib,
|
||||
if (!index)
|
||||
return NULL;
|
||||
|
||||
service->attributes[index] = new_attribute(service, 0,
|
||||
/* Check if handle is in within service range */
|
||||
if (handle && handle <= service->attributes[0]->handle)
|
||||
return NULL;
|
||||
|
||||
if (!handle)
|
||||
handle = get_handle_at_index(service, index - 1) + 1;
|
||||
|
||||
service->attributes[index] = new_attribute(service, handle,
|
||||
&included_service_uuid,
|
||||
value, len);
|
||||
if (!service->attributes[index])
|
||||
@ -889,6 +892,27 @@ gatt_db_service_add_included(struct gatt_db_attribute *attrib,
|
||||
return attribute_update(service, index);
|
||||
}
|
||||
|
||||
struct gatt_db_attribute *
|
||||
gatt_db_service_add_included(struct gatt_db_attribute *attrib,
|
||||
struct gatt_db_attribute *include)
|
||||
{
|
||||
if (!attrib || !include)
|
||||
return NULL;
|
||||
|
||||
return service_insert_included(attrib->service, 0, include);
|
||||
}
|
||||
|
||||
struct gatt_db_attribute *
|
||||
gatt_db_service_insert_included(struct gatt_db_attribute *attrib,
|
||||
uint16_t handle,
|
||||
struct gatt_db_attribute *include)
|
||||
{
|
||||
if (!attrib || !handle || !include)
|
||||
return NULL;
|
||||
|
||||
return service_insert_included(attrib->service, handle, include);
|
||||
}
|
||||
|
||||
bool gatt_db_service_set_active(struct gatt_db_attribute *attrib, bool active)
|
||||
{
|
||||
struct gatt_db_service *service;
|
||||
|
@ -96,6 +96,10 @@ gatt_db_service_insert_descriptor(struct gatt_db_attribute *attrib,
|
||||
struct gatt_db_attribute *
|
||||
gatt_db_service_add_included(struct gatt_db_attribute *attrib,
|
||||
struct gatt_db_attribute *include);
|
||||
struct gatt_db_attribute *
|
||||
gatt_db_service_insert_included(struct gatt_db_attribute *attrib,
|
||||
uint16_t handle,
|
||||
struct gatt_db_attribute *include);
|
||||
|
||||
bool gatt_db_service_set_active(struct gatt_db_attribute *attrib, bool active);
|
||||
bool gatt_db_service_get_active(struct gatt_db_attribute *attrib);
|
||||
|
Loading…
Reference in New Issue
Block a user