No changes

Fork of nRF51822 by Nordic Semiconductor

Revision:
544:9e3d053ad4ec
Parent:
543:53215259c0d2
Child:
545:d834e6591aee
--- a/source/nRF5xCharacteristicDescriptorDiscoverer.cpp	Mon Jan 11 10:19:03 2016 +0000
+++ b/source/nRF5xCharacteristicDescriptorDiscoverer.cpp	Mon Jan 11 10:19:04 2016 +0000
@@ -3,8 +3,6 @@
 #include "mbed-drivers/mbed_error.h"
 #include "ble/DiscoveredCharacteristicDescriptor.h"
 
-
-
 namespace { 
     void emptyDiscoveryCallback(const CharacteristicDescriptorDiscovery::DiscoveryCallbackParams_t*) { }
     void emptyTerminationCallback(const CharacteristicDescriptorDiscovery::TerminationCallbackParams_t*) { }
@@ -111,8 +109,10 @@
     if(!discovery) { 
         error("logic error in nRF5xCharacteristicDescriptorDiscoverer::process !!!");
     }
-    discovery->terminate(err);
-    removeDiscovery(discovery);
+
+    Discovery tmp = *discovery;
+    *discovery = Discovery();
+    tmp.terminate(err);
 }
 
 nRF5xCharacteristicDescriptorDiscoverer::Discovery* 
@@ -137,8 +137,9 @@
 
 nRF5xCharacteristicDescriptorDiscoverer::Discovery* 
 nRF5xCharacteristicDescriptorDiscoverer::findRunningDiscovery(uint16_t handle) {
-    for(size_t i = 0; i < maximumConcurrentConnectionsCount; ++i) { 
-        if(discoveryRunning[i].characteristic.getConnectionHandle() == handle) { 
+    for(size_t i = 0; i < maximumConcurrentConnectionsCount; ++i) {
+        if(discoveryRunning[i].characteristic.getConnectionHandle() == handle && 
+           discoveryRunning[i] != Discovery()) {
             return &discoveryRunning[i];
         }
     }