ble_error_t nRF5xn::shutdown(void) { if (!initialized) { return BLE_ERROR_INITIALIZATION_INCOMPLETE; } /* * Shutdown the SoftDevice first. This is because we need to disable all * interrupts. Otherwise if we clear the BLE API and glue code first there * will be many NULL references and no config information which could lead * to errors if the shutdown process is interrupted. */ #if NRF_SD_BLE_API_VERSION >= 5 if (nrf_sdh_disable_request() != NRF_SUCCESS) { return BLE_STACK_BUSY; } #else if (softdevice_handler_sd_disable() != NRF_SUCCESS) { return BLE_STACK_BUSY; } #endif /* Shutdown the BLE API and nRF51 glue code */ ble_error_t error; if (gattServerInstance != NULL) { error = gattServerInstance->reset(); if (error != BLE_ERROR_NONE) { return error; } } if (securityManagerInstance != NULL) { error = securityManagerInstance->reset(); if (error != BLE_ERROR_NONE) { return error; } } /* S110 does not support BLE client features, nothing to reset. */ #if !defined(TARGET_MCU_NRF51_16K_S110) && !defined(TARGET_MCU_NRF51_32K_S110) error = getGattClient().reset(); if (error != BLE_ERROR_NONE) { return error; } #endif /* Gap instance is always present */ error = gapInstance.reset(); if (error != BLE_ERROR_NONE) { return error; } custom_reset_128bits_uuid_table(); initialized = false; return BLE_ERROR_NONE; }
ble_error_t BLE::shutdown() { if (initialization_status != INITIALIZED) { return BLE_ERROR_INITIALIZATION_INCOMPLETE; } initialization_status = NOT_INITIALIZED; _hci_driver->terminate(); #if BLE_FEATURE_GATT_SERVER getGattServer().reset(); #endif #if BLE_FEATURE_GATT_CLIENT getGattClient().reset(); #endif // BLE_FEATURE_GATT_CLIENT getGap().reset(); _event_queue.clear(); return BLE_ERROR_NONE; }