Diff between cf2ea03a61149976e9882e62de43ba7a03d75915 and 3d92c843ab0ce2bd8e886afb229c608d68541a9d

Changed Files

File Additions Deletions Status
src/shared/gatt-db.c +29 -0 modified
src/shared/gatt-db.h +8 -0 modified

Full Patch

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 7177a0b..eac7948 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -835,6 +835,8 @@ struct find_by_type_value_data {
 	uint16_t end_handle;
 	gatt_db_attribute_cb_t func;
 	void *user_data;
+	const void *value;
+	size_t value_len;
 };
 
 static void find_by_type(void *data, void *user_data)
@@ -860,6 +862,12 @@ static void find_by_type(void *data, void *user_data)
 		if (bt_uuid_cmp(&search_data->uuid, &attribute->uuid))
 			continue;
 
+		/* TODO: fix for read-callback based attributes */
+		if (search_data->value && memcmp(attribute->value,
+							search_data->value,
+							search_data->value_len))
+			continue;
+
 		search_data->func(attribute, search_data->user_data);
 	}
 }
@@ -881,6 +889,27 @@ void gatt_db_find_by_type(struct gatt_db *db, uint16_t start_handle,
 	queue_foreach(db->services, find_by_type, &data);
 }
 
+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 void *value,
+						size_t value_len,
+						gatt_db_attribute_cb_t func,
+						void *user_data)
+{
+	struct find_by_type_value_data data;
+
+	data.uuid = *type;
+	data.start_handle = start_handle;
+	data.end_handle = end_handle;
+	data.func = func;
+	data.user_data = user_data;
+	data.value = value;
+	data.value_len = value_len;
+
+	queue_foreach(db->services, find_by_type, &data);
+}
+
 struct read_by_type_data {
 	struct queue *queue;
 	bt_uuid_t uuid;
diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
index 9fc1b11..2edd13f 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
@@ -97,6 +97,14 @@ void gatt_db_find_by_type(struct gatt_db *db, uint16_t start_handle,
 						gatt_db_attribute_cb_t func,
 						void *user_data);
 
+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 void *value,
+						size_t value_len,
+						gatt_db_attribute_cb_t func,
+						void *user_data);
+
 void gatt_db_read_by_type(struct gatt_db *db, uint16_t start_handle,
 							uint16_t end_handle,
 							const bt_uuid_t type,