From 00f8a3f1e3593baf20643daa4cc02e377e3d8f15 Mon Sep 17 00:00:00 2001 From: Alain Michaud Date: Fri, 1 May 2020 19:22:17 +0000 Subject: [PATCH] shared/gatt-client: Ignore orphaned characteristics The gatt discovery proceedure simplification to discover all characteristics at once has exposed a device side issue where some device implementation reports orphaned characteristics. While this technically shouldn't be allowed, some instances of this were observed (namely on some Android phones). The fix is to simply skip over orphaned characteristics and continue with everything else that is valid. This has been tested as part of the Android CTS tests against an affected platform and was confirmed to have worked around the issue. --- src/shared/gatt-client.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index c4a79eac9..19ff6ab65 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -632,7 +632,13 @@ static bool discover_descs(struct discovery_op *op, bool *discovering) util_debug(client->debug_callback, client->debug_data, "Failed to insert characteristic at 0x%04x", chrc_data->value_handle); - goto failed; + + /* Some devices have been seen reporting orphaned + * characteristics. In order to favor interoperability + * we skip over characteristics in error + */ + free(chrc_data); + continue; } if (gatt_db_attribute_get_handle(attr) != -- 2.47.3