No changes
Fork of nRF51822 by
Diff: source/nRF5xGattServer.cpp
- Revision:
- 566:e425ad9e5d6e
- Parent:
- 565:cf03471a4ec4
- Child:
- 570:f162898cb6c4
diff -r cf03471a4ec4 -r e425ad9e5d6e source/nRF5xGattServer.cpp --- a/source/nRF5xGattServer.cpp Mon Jan 11 10:19:18 2016 +0000 +++ b/source/nRF5xGattServer.cpp Mon Jan 11 10:19:18 2016 +0000 @@ -20,7 +20,12 @@ #include "common/common.h" #include "btle/custom/custom_helper.h" -#include "nRF5xn.h" +#include "nRF5xGap.h" + +nRF5xGattServer &nRF5xGattServer::getInstance(void) { + static nRF5xGattServer m_instance; + return m_instance; +} /**************************************************************************/ /*! @@ -236,8 +241,7 @@ hvx_params.p_len = &len; if (connectionHandle == BLE_CONN_HANDLE_INVALID) { /* use the default connection handle if the caller hasn't specified a valid connectionHandle. */ - nRF5xGap &gap = (nRF5xGap &) nRF5xn::Instance(BLE::DEFAULT_INSTANCE).getGap(); - connectionHandle = gap.getConnectionHandle(); + connectionHandle = nRF5xGap::getInstance().getConnectionHandle(); } error_t error = (error_t) sd_ble_gatts_hvx(connectionHandle, &hvx_params); if (error != ERROR_NONE) { @@ -276,8 +280,7 @@ ble_error_t nRF5xGattServer::areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP) { /* Forward the call with the default connection handle. */ - nRF5xGap &gap = (nRF5xGap &) nRF5xn::Instance(BLE::DEFAULT_INSTANCE).getGap(); - return areUpdatesEnabled(gap.getConnectionHandle(), characteristic, enabledP); + return areUpdatesEnabled(nRF5xGap::getInstance().getConnectionHandle(), characteristic, enabledP); } ble_error_t nRF5xGattServer::areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP) @@ -309,33 +312,6 @@ /**************************************************************************/ /*! - @brief Clear nRF5xGattServer's state. - - @returns ble_error_t - - @retval BLE_ERROR_NONE - Everything executed properly -*/ -/**************************************************************************/ -ble_error_t nRF5xGattServer::reset(void) -{ - /* Clear all state that is from the parent, including private members */ - if (GattServer::reset() != BLE_ERROR_NONE) { - return BLE_ERROR_INVALID_STATE; - } - - /* Clear derived class members */ - memset(p_characteristics, 0, sizeof(p_characteristics)); - memset(p_descriptors, 0, sizeof(p_descriptors)); - memset(nrfCharacteristicHandles, 0, sizeof(ble_gatts_char_handles_t)); - memset(nrfDescriptorHandles, 0, sizeof(nrfDescriptorHandles)); - descriptorCount = 0; - - return BLE_ERROR_NONE; -} - -/**************************************************************************/ -/*! @brief Callback handler for events getting pushed up from the SD */ /**************************************************************************/