Attempting to publish a tree
Fork of nRF51822 by
Diff: source/nRF5xGattServer.cpp
- Revision:
- 575:7023a8204a1b
- Parent:
- 571:bbf6410b6a89
- Child:
- 578:78f69f1be114
diff -r 7a531ae7a53c -r 7023a8204a1b source/nRF5xGattServer.cpp --- a/source/nRF5xGattServer.cpp Mon Jan 11 10:19:23 2016 +0000 +++ b/source/nRF5xGattServer.cpp Mon Jan 11 10:19:24 2016 +0000 @@ -20,12 +20,7 @@ #include "common/common.h" #include "btle/custom/custom_helper.h" -#include "nRF5xGap.h" - -nRF5xGattServer &nRF5xGattServer::getInstance(void) { - static nRF5xGattServer m_instance; - return m_instance; -} +#include "nRF5xn.h" /**************************************************************************/ /*! @@ -241,7 +236,8 @@ 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. */ - connectionHandle = nRF5xGap::getInstance().getConnectionHandle(); + nRF5xGap &gap = (nRF5xGap &) nRF5xn::Instance(BLE::DEFAULT_INSTANCE).getGap(); + connectionHandle = gap.getConnectionHandle(); } error_t error = (error_t) sd_ble_gatts_hvx(connectionHandle, &hvx_params); if (error != ERROR_NONE) { @@ -280,7 +276,8 @@ ble_error_t nRF5xGattServer::areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP) { /* Forward the call with the default connection handle. */ - return areUpdatesEnabled(nRF5xGap::getInstance().getConnectionHandle(), characteristic, enabledP); + nRF5xGap &gap = (nRF5xGap &) nRF5xn::Instance(BLE::DEFAULT_INSTANCE).getGap(); + return areUpdatesEnabled(gap.getConnectionHandle(), characteristic, enabledP); } ble_error_t nRF5xGattServer::areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP) @@ -312,6 +309,33 @@ /**************************************************************************/ /*! + @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 */ /**************************************************************************/