Skip to contentSkip to conversation

shared/gatt-client: Fix error when no service could be found

PATCH Applied Luiz Augusto von Dentz 1 participant 3 messages Jul 29, 2015 – Jul 30, 2015 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 shared/gatt-client: Fix error when no service could be found

From: Luiz Augusto von Dentz <[email protected]>

In case the remote device has no services available ready callback would be called with success set to false but in fact it has succeeded it just did not find anything.

---
 src/shared/gatt-client.c | 5 +++++
 1 file changed, 5 insertions(+)
src/shared/gatt-client.c +5 -0
index 24aef18..903afa7 100644
@@ -971,6 +971,11 @@ static void discover_primary_cb(bool success, uint8_t att_ecode,
 		util_debug(client->debug_callback, client->debug_data,
 					"Primary service discovery failed."
 					" ATT ECODE: 0x%02x", att_ecode);
+		/* Reset error in case of not found */
+		if (BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND) {
+			success = true;
+			att_ecode = 0;
+		}
 		goto secondary;
 	}
 
Signature · 1 line
2.1.0
author maintainer
#1 lore raw

PATCH 2/2 core/device: Fix not emitting Paired property

From: Luiz Augusto von Dentz <[email protected]>

Even if bt_gatt_client fails to discover services it should still call device_svc_resolved so the Paired propery is updated if pending and the device is properly stored, and at the end it still calls browse_request_complete to free up the resources.

---
 src/device.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
src/device.c +1 -7
index debe201..3dde8b8 100644
@@ -4188,13 +4188,7 @@ static void gatt_client_ready_cb(bool success, uint8_t att_ecode,
 	DBG("status: %s, error: %u", success ? "success" : "failed", att_ecode);
 
 	if (!success) {
-		if (device->browse) {
-			struct browse_req *req = device->browse;
-
-			device->browse = NULL;
-			browse_request_complete(req, device->bdaddr_type, -EIO);
-		}
-
+		device_svc_resolved(device, device->bdaddr_type, -EIO);
 		return;
 	}
 
Signature · 1 line
2.1.0
author maintainer Applied
#2 lore raw
In reply to Luiz Augusto von Dentz

Hi,

Quoted 26 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

In case the remote device has no services available ready callback would be called with success set to false but in fact it has succeeded it just did not find anything.

---
 src/shared/gatt-client.c | 5 +++++
 1 file changed, 5 insertions(+)
src/shared/gatt-client.c +5 -1
index 24aef18..903afa7 100644
@@ -971,6 +971,11 @@ static void discover_primary_cb(bool success, uint8_t att_ecode,
                util_debug(client->debug_callback, client->debug_data,
                                        "Primary service discovery failed."
                                        " ATT ECODE: 0x%02x", att_ecode);
+               /* Reset error in case of not found */
+               if (BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND) {
+                       success = true;
+                       att_ecode = 0;
+               }
                goto secondary;
        }
 
--
Quoted 1 line

2.1.0

Applied.

Signature · 1 line
Luiz Augusto von Dentz