Nano RGB LED mesh
Fork of nRF51822 by
Diff: source/nRF5xn.cpp
- Revision:
- 561:613dbbdeed27
- Parent:
- 549:3f782c64d014
- Child:
- 563:9c4b96f7be8d
--- a/source/nRF5xn.cpp Mon Jan 11 10:19:14 2016 +0000 +++ b/source/nRF5xn.cpp Mon Jan 11 10:19:15 2016 +0000 @@ -104,16 +104,44 @@ return BLE_ERROR_NONE; } +/**************************************************************************/ +/*! + @brief Purge the BLE stack of GATT and GAP state. + + @returns ble_error_t + + @retval BLE_ERROR_NONE + Everything executed properly + + @note When using S110, GattClient::shutdown() will not be called + since Gatt client features are not supported. +*/ +/**************************************************************************/ ble_error_t nRF5xn::shutdown(void) { if (!initialized) { return BLE_ERROR_INITIALIZATION_INCOMPLETE; } + /* Shutdown the SoftDevice */ if(softdevice_handler_sd_disable() != NRF_SUCCESS) { return BLE_STACK_BUSY; } + /* Shutdown the BLE API and nRF51 glue code */ +#if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110) + if (GattServer::shutdown() != BLE_ERROR_NONE || + SecurityManager::shutdown() != BLE_ERROR_NONE || + GattClient::shutdown() != BLE_ERROR_NONE || + Gap::shutdown() != BLE_ERROR_NONE) { +#else + if (GattServer::shutdown() != BLE_ERROR_NONE || + SecurityManager::shutdown() != BLE_ERROR_NONE || + Gap::shutdown() != BLE_ERROR_NONE) { +#endif + return BLE_ERROR_INVALID_STATE; + } + initialized = false; return BLE_ERROR_NONE; }