public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcin Kraglak <marcin.kraglak@tieto.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 3/8] android/gatt: Fix searching primary services by uuids
Date: Thu, 17 Jul 2014 10:42:45 +0200	[thread overview]
Message-ID: <1405586570-16851-3-git-send-email-marcin.kraglak@tieto.com> (raw)
In-Reply-To: <1405586570-16851-1-git-send-email-marcin.kraglak@tieto.com>

Return all instances of services. It is not proper behaviour to
return only one instance of service with same uuid.
---
 android/gatt.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

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;
-- 
1.9.0


  parent reply	other threads:[~2014-07-17  8:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17  8:42 [PATCH 1/8] android/gatt: Fix service class id of built in gatt services Marcin Kraglak
2014-07-17  8:42 ` [PATCH 2/8] attrib: Fix discovering descriptors Marcin Kraglak
2014-07-17  8:42 ` Marcin Kraglak [this message]
2014-07-17  8:42 ` [PATCH 4/8] android/gatt: Fix check for permissions error Marcin Kraglak
2014-07-17  8:42 ` [PATCH 5/8] android/gatt: Fix read responses with o length value Marcin Kraglak
2014-07-17  8:42 ` [PATCH 6/8] android/gatt: Add GATT_PERM_NONE define Marcin Kraglak
2014-07-17  8:42 ` [PATCH 7/8] android/gatt: Send proper status of read descriptor callback Marcin Kraglak
2014-07-17  8:42 ` [PATCH 8/8] android/gatt: Fix incorrect status in read characteristic cb Marcin Kraglak
2014-07-18  9:15 ` [PATCH 1/8] android/gatt: Fix service class id of built in gatt services Szymon Janc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405586570-16851-3-git-send-email-marcin.kraglak@tieto.com \
    --to=marcin.kraglak@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox