None

Dependencies:   nrf51-sdk

Dependents:   microbit-dal

Fork of nRF51822 by Lancaster University

Revision:
280:cbaa4cb83548
Parent:
279:6e5e79f1fb61
Child:
284:29fb6af6671d
--- a/btle/btle_discovery.h	Fri Jun 19 15:55:26 2015 +0100
+++ b/btle/btle_discovery.h	Fri Jun 19 15:55:26 2015 +0100
@@ -39,8 +39,14 @@
     void setupDiscoveredCharacteristics(const ble_gattc_evt_char_disc_rsp_t *response);
 
     void terminateServiceDiscovery(void) {
+        bool wasActive = isActive();
+
         sDiscoveryActive = false;
         cDiscoveryActive = false;
+
+        if (wasActive && onTerminationCallback) {
+            onTerminationCallback(connHandle);
+        }
     }
 
     void terminateCharacteristicDiscovery(void) {
@@ -53,6 +59,10 @@
         return (sDiscoveryActive || cDiscoveryActive);
     }
 
+    void setOnTermination(TerminationCallback_t callback) {
+        onTerminationCallback = callback;
+    }
+
 private:
     void resetDiscoveredServices(void) {
         numServices  = 0;
@@ -99,6 +109,8 @@
     DiscoveredService        services[BLE_DB_DISCOVERY_MAX_SRV];  /**< Information related to the current service being discovered.
                                                                    *  This is intended for internal use during service discovery. */
     DiscoveredCharacteristic characteristics[BLE_DB_DISCOVERY_MAX_CHAR_PER_SRV];
+
+    TerminationCallback_t onTerminationCallback;
 };
 
 #endif /*_BTLE_DISCOVERY_H_*/
\ No newline at end of file