diff --git a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle.cpp b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle.cpp index 811e715254..029016f9e4 100644 --- a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle.cpp +++ b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle.cpp @@ -51,11 +51,9 @@ extern "C" { } #include "nrf_ble_hci.h" -#include "btle_discovery.h" -#include "nRF5xGattClient.h" -#include "nRF5xServiceDiscovery.h" -#include "nRF5xCharacteristicDescriptorDiscoverer.h" +#include "nRF5XPalGattClient.h" + bool isEventsSignaled = false; @@ -67,23 +65,6 @@ extern "C" void SD_EVT_IRQHandler(void); // export the softdevice event handler static void btle_handler(ble_evt_t *p_ble_evt); -#if 0 -#define CENTRAL_LINK_COUNT (YOTTA_CFG_NORDIC_BLE_CENTRAL_LINKS) /**evt.gap_evt.params.connected.peer_addr; #if (NRF_SD_BLE_API_VERSION <= 2) const ble_gap_addr_t *own = &p_ble_evt->evt.gap_evt.params.connected.own_addr; - + gap.processConnectionEvent(handle, role, static_cast(peer->addr_type), peer->addr, @@ -275,9 +258,7 @@ static void btle_handler(ble_evt_t *p_ble_evt) #if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110) // Close all pending discoveries for this connection - nRF5xGattClient& gattClient = ble.getGattClient(); - gattClient.characteristicDescriptorDiscoverer().terminate(handle, BLE_ERROR_INVALID_STATE); - gattClient.discovery().terminate(handle); + nRF5XGattClient::handle_connection_termination(handle); #endif gap.processDisconnectionEvent(handle, reason); diff --git a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle.h b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle.h index 021dd50513..dfeccef05b 100644 --- a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle.h +++ b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/btle/btle.h @@ -26,6 +26,13 @@ extern "C" { #include "ble_srv_common.h" #include "headers/nrf_ble.h" +#define CENTRAL_LINK_COUNT 3 /**reset(); - if (error != BLE_ERROR_NONE) { - return error; - } + error = getGattClient().reset(); + if (error != BLE_ERROR_NONE) { + return error; } #endif diff --git a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xn.h b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xn.h index 33c7926e0d..154b9e49dc 100644 --- a/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xn.h +++ b/features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xn.h @@ -20,10 +20,10 @@ #include "ble/BLE.h" #include "ble/blecommon.h" #include "ble/BLEInstanceBase.h" +#include "ble/generic/GenericGattClient.h" #include "nRF5xGap.h" #include "nRF5xGattServer.h" -#include "nRF5xGattClient.h" #include "nRF5xSecurityManager.h" #include "btle.h" @@ -77,11 +77,8 @@ public: * * @return A reference to GattClient. */ - virtual nRF5xGattClient &getGattClient() { - if (gattClientInstance == NULL) { - gattClientInstance = new nRF5xGattClient(); - } - return *gattClientInstance; + virtual GattClient &getGattClient() { + return gattClient; } /** @@ -171,10 +168,8 @@ private: * If NULL, then GattServer has not been initialized. * The pointer has been declared as 'mutable' so that * it can be assigned inside a 'const' function. */ - mutable nRF5xGattClient *gattClientInstance; /**< Pointer to the GattClient object instance. - * If NULL, then GattClient has not been initialized. - * The pointer has been declared as 'mutable' so that - * it can be assigned inside a 'const' function. */ + ble::generic::GenericGattClient gattClient; + mutable nRF5xSecurityManager *securityManagerInstance; /**< Pointer to the SecurityManager object instance. * If NULL, then SecurityManager has not been initialized. * The pointer has been declared as 'mutable' so that