test

Dependencies:   nrf51-sdk

Dependents:   microbit-dal

Fork of nRF51822 by Lancaster University

Revision:
277:91705df8495e
Parent:
276:ae6e5129b395
Child:
278:26e3f0ef1e14
diff -r ae6e5129b395 -r 91705df8495e btle/btle_discovery.cpp
--- a/btle/btle_discovery.cpp	Fri Jun 19 15:55:25 2015 +0100
+++ b/btle/btle_discovery.cpp	Fri Jun 19 15:55:26 2015 +0100
@@ -155,7 +155,7 @@
                 terminateCharacteristicDiscovery();
             }
         } else {
-           terminateCharacteristicDiscovery();
+            terminateCharacteristicDiscovery();
         }
     }
 }
@@ -165,14 +165,19 @@
 {
     /* Iterate through the previously discovered services cached in services[]. */
     while (sDiscoveryActive && (serviceIndex < numServices)) {
-        if (serviceCallback) {
-            serviceCallback(services[serviceIndex]);
-        }
+        if ((matchingServiceUUID == ShortUUIDBytes_t(BLE_UUID_UNKNOWN)) ||
+            (matchingServiceUUID == services[serviceIndex].getShortUUID())) {
+            if (serviceCallback) {
+                serviceCallback(services[serviceIndex]);
+            }
 
-        if (sDiscoveryActive && characteristicCallback) { /* characteristic discovery is optional. */
-            launchCharacteristicDiscovery(connHandle, services[serviceIndex].getStartHandle(), services[serviceIndex].getEndHandle());
+            if (sDiscoveryActive && characteristicCallback) {
+                launchCharacteristicDiscovery(connHandle, services[serviceIndex].getStartHandle(), services[serviceIndex].getEndHandle());
+            } else {
+                serviceIndex++;
+            }
         } else {
-            serviceIndex++; /* Progress service index to keep discovery alive. */
+            serviceIndex++;
         }
     }