Skip to contentSkip to conversation

shared/gatt-client: Omit valid errors for primary discovery

PATCH Applied Luiz Augusto von Dentz 1 participant 4 messages Mar 14, 2018 – Mar 15, 2018 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/3 shared/gatt-client: Omit valid errors for primary discovery

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

BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND shall not cause anything to be printed since it is a valid response and just mark the end of primary discovery.

---
 src/shared/gatt-client.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
src/shared/gatt-client.c +3 -3
index 1285c37ef..d61668df7 100644
@@ -1023,9 +1023,6 @@ static void discover_primary_cb(bool success, uint8_t att_ecode,
 	discovery_req_clear(client);
 
 	if (!success) {
-		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 */
 		switch (att_ecode) {
 		case BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND:
@@ -1033,6 +1030,9 @@ static void discover_primary_cb(bool success, uint8_t att_ecode,
 			att_ecode = 0;
 			goto secondary;
 		default:
+			util_debug(client->debug_callback, client->debug_data,
+					"Primary service discovery failed."
+					" ATT ECODE: 0x%02x", att_ecode);
 			goto done;
 		}
 	}
Signature · 1 line
2.14.3
author maintainer
#1 lore raw

PATCH 2/3 shared/gatt-client: Fix secondary service discovery

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

If the error returned is either BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND or BT_ATT_ERROR_UNSUPPORTED_GROUP_TYPE the discovery shall be marked as successful and no error shall be printed.

---
 src/shared/gatt-client.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
src/shared/gatt-client.c +5 -3
index d61668df7..c369ccb40 100644
@@ -933,14 +933,16 @@ static void discover_secondary_cb(bool success, uint8_t att_ecode,
 	discovery_req_clear(client);
 
 	if (!success) {
-		util_debug(client->debug_callback, client->debug_data,
-					"Secondary service discovery failed."
-					" ATT ECODE: 0x%02x", att_ecode);
 		switch (att_ecode) {
 		case BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND:
 		case BT_ATT_ERROR_UNSUPPORTED_GROUP_TYPE:
+			success = true;
+			att_ecode = 0;
 			goto next;
 		default:
+			util_debug(client->debug_callback, client->debug_data,
+					"Secondary service discovery failed."
+					" ATT ECODE: 0x%02x", att_ecode);
 			goto done;
 		}
 	}
Signature · 1 line
2.14.3
author maintainer
#2 lore raw

PATCH 3/3 shared/gatt-client: Fix attempting to discovery with handle 0

In reply to Luiz Augusto von Dentz

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

If a service was removed an no other service was added it may happen that pending_svc has not empty but first_svc and last_svc has not been set causing the following request:

< ACL Data TX: Handle 76 flags 0x00 dlen 11

      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0000-0x0000
        Attribute type: Include (0x2802)
---
 src/shared/gatt-client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/shared/gatt-client.c +1 -1
index c369ccb40..e1d489d32 100644
@@ -988,7 +988,7 @@ static void discover_secondary_cb(bool success, uint8_t att_ecode,
 	}
 
 next:
-	if (queue_isempty(op->pending_svcs))
+	if (queue_isempty(op->pending_svcs) || !op->svc_first)
 		goto done;
 
 	client->discovery_req = bt_gatt_discover_included_services(client->att,
Signature · 1 line
2.14.3
author maintainer Applied
#3 lore raw
In reply to Luiz Augusto von Dentz

Hi,

Quoted 33 lines · Luiz Augusto von Dentz

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

BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND shall not cause anything to be printed since it is a valid response and just mark the end of primary discovery.

---
 src/shared/gatt-client.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
src/shared/gatt-client.c +3 -4
index 1285c37ef..d61668df7 100644
@@ -1023,9 +1023,6 @@ static void discover_primary_cb(bool success, uint8_t att_ecode,
        discovery_req_clear(client);
 
        if (!success) {
-               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 */
                switch (att_ecode) {
                case BT_ATT_ERROR_ATTRIBUTE_NOT_FOUND:
@@ -1033,6 +1030,9 @@ static void discover_primary_cb(bool success, uint8_t att_ecode,
                        att_ecode = 0;
                        goto secondary;
                default:
+                       util_debug(client->debug_callback, client->debug_data,
+                                       "Primary service discovery failed."
+                                       " ATT ECODE: 0x%02x", att_ecode);
                        goto done;
                }
        }
--
Quoted 1 line

2.14.3

Applied.

Signature · 1 line
Luiz Augusto von Dentz