From 1aef33c9a8357cc219341c9d520d6db85454cfcf Mon Sep 17 00:00:00 2001 From: Rohit Grover Date: Fri, 1 May 2015 11:44:29 +0100 Subject: [PATCH] account for the limitation on the number of [SC] we can handle at a time within setupDiscovered*() --- btle/btle_gattc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/btle/btle_gattc.cpp b/btle/btle_gattc.cpp index f5c16d0..64a1a54 100644 --- a/btle/btle_gattc.cpp +++ b/btle/btle_gattc.cpp @@ -101,6 +101,11 @@ struct DiscoveryStatus { currSrvInd = 0; srvCount = response->count; + /* Account for the limitation on the number of discovered services we can handle at a time. */ + if (srvCount > BLE_DB_DISCOVERY_MAX_SRV) { + srvCount = BLE_DB_DISCOVERY_MAX_SRV; + } + for (unsigned serviceIndex = 0; serviceIndex < srvCount; serviceIndex++) { services[serviceIndex].setup(response->services[serviceIndex].uuid.uuid, response->services[serviceIndex].handle_range.start_handle, @@ -112,6 +117,11 @@ struct DiscoveryStatus { currCharInd = 0; charCount = response->count; + /* Account for the limitation on the number of discovered characteristics we can handle at a time. */ + if (charCount > BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV) { + charCount = BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV; + } + for (unsigned charIndex = 0; charIndex < charCount; charIndex++) { characteristics[charIndex].setup(response->chars[charIndex].uuid.uuid, response->chars[charIndex].char_props,