Shuta Nakamae / nRF51822

Fork of nRF51822 by Nordic Semiconductor

Revision:
233:0b15e714801b
Parent:
232:102cf741f177
Child:
234:80732a210425
diff -r 102cf741f177 -r 0b15e714801b btle/btle_gattc.cpp
--- a/btle/btle_gattc.cpp	Fri Jun 19 15:55:20 2015 +0100
+++ b/btle/btle_gattc.cpp	Fri Jun 19 15:55:20 2015 +0100
@@ -101,6 +101,11 @@
         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 @@
         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,