Nordic stack and drivers for the mbed BLE API. Version to work around build bug.

Dependents:   microbit_rubber_ducky microbit_mouse_BLE microbit_mouse_BLE_daybreak_version microbit_presenter

Fork of nRF51822 by Nordic Semiconductor

Revision:
567:e1800bd55a9e
Parent:
566:e425ad9e5d6e
Child:
570:f162898cb6c4
--- a/source/btle/btle.cpp	Mon Jan 11 10:19:18 2016 +0000
+++ b/source/btle/btle.cpp	Mon Jan 11 10:19:19 2016 +0000
@@ -41,6 +41,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);
 
@@ -154,8 +158,8 @@
             const ble_gap_addr_t *own  = &p_ble_evt->evt.gap_evt.params.connected.own_addr;
             nRF5xGap::getInstance().processConnectionEvent(handle,
                                                            role,
-                                                           static_cast<BLEProtocol::AddressType::Type>(peer->addr_type), peer->addr,
-                                                           static_cast<BLEProtocol::AddressType::Type>(own->addr_type),  own->addr,
+                                                           static_cast<Gap::AddressType_t>(peer->addr_type), peer->addr,
+                                                           static_cast<Gap::AddressType_t>(own->addr_type),  own->addr,
                                                            params);
             break;
         }
@@ -183,6 +187,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 = nRF5xGattClient::getInstance();
+            gattClient.characteristicDescriptorDiscoverer().terminate(handle, BLE_ERROR_INVALID_STATE);
+            gattClient.discovery().terminate(handle);
+
             nRF5xGap::getInstance().processDisconnectionEvent(handle, reason);
             break;
         }