Diff between ff797556da5f896d43e4b0e16f5e1a8231b8cd1f and fce3c5c21503eebad7dd4b829942bffe012d1d66

Changed Files

File Additions Deletions Status
android/gatt.c +18 -18 modified

Full Patch

diff --git a/android/gatt.c b/android/gatt.c
index 19d9b60..4cd94b8 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1136,28 +1136,28 @@ static void discover_srvc_by_uuid_cb(uint8_t status, GSList *ranges,
 	}
 
 	bt_uuid_to_string(&cb_data->uuid, prim.uuid, sizeof(prim.uuid));
-	/*
-	 * If multiple instances of the same service (as identified by UUID)
-	 * exist, the first instance of the service is returned.
-	 */
-	memcpy(&prim.range, ranges->data, sizeof(prim.range));
 
-	s = create_service(instance_id++, true, prim.uuid, &prim);
-	if (!s) {
-		gatt_status = GATT_FAILURE;
-		goto reply;
-	}
+	for (; ranges; ranges = ranges->next) {
+		memcpy(&prim.range, ranges->data, sizeof(prim.range));
 
-	if (!queue_push_tail(dev->services, s)) {
-		error("gatt: Cannot push primary service to the list");
-		gatt_status = GATT_FAILURE;
-		goto reply;
-	}
+		s = create_service(instance_id++, true, prim.uuid, &prim);
+		if (!s) {
+			gatt_status = GATT_FAILURE;
+			goto reply;
+		}
+
+		if (!queue_push_tail(dev->services, s)) {
+			error("gatt: Cannot push primary service to the list");
+			destroy_service(s);
+			gatt_status = GATT_FAILURE;
+			goto reply;
+		}
 
-	send_client_primary_notify(s, INT_TO_PTR(cb_data->conn->id));
+		send_client_primary_notify(s, INT_TO_PTR(cb_data->conn->id));
 
-	DBG("attr handle = 0x%04x, end grp handle = 0x%04x uuid: %s",
-		prim.range.start, prim.range.end, prim.uuid);
+		DBG("attr handle = 0x%04x, end grp handle = 0x%04x uuid: %s",
+				prim.range.start, prim.range.end, prim.uuid);
+	}
 
 	/* Partial search service scanning was performed */
 	dev->partial_srvc_search = true;