Add check for return code of ble_init

This commit is contained in:
Andres Amaya Garcia 2015-12-21 09:30:01 +00:00
parent 2850a85809
commit 7f02a2d51f
2 changed files with 18 additions and 4 deletions

View file

@ -118,9 +118,7 @@ error_t btle_init(void)
ASSERT_STATUS( softdevice_ble_evt_handler_set(btle_handler));
ASSERT_STATUS( softdevice_sys_evt_handler_set(sys_evt_dispatch));
btle_gap_init();
return ERROR_NONE;
return btle_gap_init();
}
static void btle_handler(ble_evt_t *p_ble_evt)

View file

@ -95,6 +95,20 @@ const char *nRF5xn::getVersion(void)
return versionString;
}
/**************************************************************************/
/*!
@brief Initialize the BLE stack.
@returns ble_error_t
@retval BLE_ERROR_NONE if everything executed properly and
BLE_ERROR_ALREADY_INITIALIZED if the stack has already
been initialized (possibly through a call to nRF5xn::init().
BLE_ERROR_INTERNAL_STACK_FAILURE is returned if initialization
of the internal stack (SoftDevice) failed.
*/
/**************************************************************************/
ble_error_t nRF5xn::init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> callback)
{
if (initialized) {
@ -109,7 +123,9 @@ ble_error_t nRF5xn::init(BLE::InstanceID_t instanceID, FunctionPointerWithContex
instanceID = instanceID;
/* ToDo: Clear memory contents, reset the SD, etc. */
btle_init();
if (btle_init() != ERROR_NONE) {
return BLE_ERROR_INTERNAL_STACK_FAILURE;
}
initialized = true;
BLE::InitializationCompleteCallbackContext context = {