test

Dependencies:   nrf51-sdk

Dependents:   microbit-dal

Fork of nRF51822 by Lancaster University

Revision:
592:f9574772b816
Parent:
591:266079a50c20
Child:
615:65ea2acfc6a2
--- a/source/btle/btle.cpp	Mon Jan 11 10:19:32 2016 +0000
+++ b/source/btle/btle.cpp	Mon Jan 11 10:19:33 2016 +0000
@@ -39,6 +39,10 @@
 #include "ble_hci.h"
 #include "btle_discovery.h"
 
+#include "nRF5xGattClient.h"
+#include "nRF5xServiceDiscovery.h"
+#include "nRF5xCharacteristicDescriptorDiscoverer.h"
+
 extern "C" void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name);
 void            app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name);
 
@@ -184,6 +188,12 @@
                     reason = static_cast<Gap::DisconnectionReason_t>(p_ble_evt->evt.gap_evt.params.disconnected.reason);
                     break;
             }
+
+            // Close all pending discoveries for this connection
+            nRF5xGattClient& gattClient = ble.getGattClient();
+            gattClient.characteristicDescriptorDiscoverer().terminate(handle, BLE_ERROR_INVALID_STATE);
+            gattClient.discovery().terminate(handle);
+
             gap.processDisconnectionEvent(handle, reason);
             break;
         }