diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index fededa5..d17c389 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
queue_foreach(db->services, read_by_group_type, &data);
}
+
+struct find_by_type_value_data {
+ struct queue *queue;
+ bt_uuid_t uuid;
+ uint16_t start_handle;
+ uint16_t end_handle;
+ uint16_t value_length;
+ const uint8_t *value;
+};
+
+static void find_by_type_value(void *data, void *user_data)
+{
+ struct find_by_type_value_data *search_data = user_data;
+ struct gatt_db_service *service = data;
+ struct gatt_db_attribute *attribute;
+ struct gatt_db_range *range;
+ int i;
+
+ if (!service->active)
+ return;
+
+ for (i = 0; i < service->num_handles; i++) {
+ attribute = service->attributes[i];
+
+ if (!attribute)
+ continue;
+
+ if ((attribute->handle < search_data->start_handle) ||
+ (attribute->handle > search_data->end_handle))
+ continue;
+
+ if (bt_uuid_cmp(&search_data->uuid, &attribute->uuid))
+ continue;
+
+ if (attribute->value_len != search_data->value_length)
+ continue;
+
+ if (!memcmp(attribute->value, search_data->value,
+ attribute->value_len))
+ continue;
+
+ range = new0(struct gatt_db_range, 1);
+ if (!range)
+ return;
+
+ range->handle = attribute->handle;
+ range->end_group = service->attributes[0]->handle +
+ service->num_handles - 1;
+
+ if (!queue_push_tail(search_data->queue, range))
+ free(range);
+ }
+}
+
+void gatt_db_find_by_type_value(struct gatt_db *db, uint16_t start_handle,
+ uint16_t end_handle,
+ const bt_uuid_t type,
+ const uint8_t *value,
+ uint16_t length,
+ struct queue *queue)
+{
+ struct find_by_type_value_data data;
+
+ data.uuid = type;
+ data.start_handle = start_handle;
+ data.end_handle = end_handle;
+ data.queue = queue;
+ data.value_length = length;
+ data.value = value;
+
+ queue_foreach(db->services, find_by_type_value, &data);
+}
diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
index 8c04c0f..9bfdb12 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
uint16_t end_handle,
const bt_uuid_t type,
struct queue *queue);
+
+struct gatt_db_range {
+ uint16_t handle;
+ uint16_t end_group;
+};
+
+void gatt_db_find_by_type_value(struct gatt_db *db, uint16_t start_handle,
+ uint16_t end_handle,
+ const bt_uuid_t type,
+ const uint8_t *value,
+ uint16_t length,
+ struct queue *queue);