Merge pull request #95 from andresag01/init_checks

Add check for return code of ble_init
This commit is contained in:
Vincent Coubard 2015-12-21 15:02:09 +00:00
commit bb283199db
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 = {