diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index b696fe3..676f963 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
return -1;
}
-static struct gatt_db_attribute *
+struct gatt_db_attribute *
gatt_db_attribute_get_value(struct gatt_db_attribute *attrib)
{
struct gatt_db_service *service;
return NULL;
index = gatt_db_attribute_get_index(attrib);
- if (index < 0)
+ if (index <= 0)
return NULL;
service = attrib->service;
if (!bt_uuid_cmp(&characteristic_uuid, &attrib->uuid))
- index++;
- else if (bt_uuid_cmp(&characteristic_uuid,
+ return service->attributes[index + 1];
+ else if (!bt_uuid_cmp(&characteristic_uuid,
&service->attributes[index - 1]->uuid))
- return NULL;
+ return service->attributes[index];
- return service->attributes[index];
+ return gatt_db_attribute_get_value(service->attributes[index - 1]);
}
void gatt_db_service_foreach_desc(struct gatt_db_attribute *attrib,
diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
index 163a981..fb939e4 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
unsigned int id, int err);
struct gatt_db_attribute *
+gatt_db_attribute_get_value(struct gatt_db_attribute *attrib);
+struct gatt_db_attribute *
gatt_db_attribute_get_ccc(struct gatt_db_attribute *attrib);
bool gatt_db_attribute_notify(struct gatt_db_attribute *attrib,