how to reset m_ble_evt_handler?

I'm trying to send a parameter over BLE, but once i've stopped using the BLE stacked (and unininited softdevice) I can't seem to save the parameter recieved with pstorage.

Investigating i've found that if i reset m_ble_evt_handler i can correctly save the parameter with pstorage.

pstorage_update works correctly in normal conditions, but once i use the function softdevice_ble_evt_handler_set(ble_evt_dispatch); pstorage_update no longer works, it just tries to save forever, never ending the process.

With these things in mind, i tried resetting manually m_ble_evt_handler, tried to use pstorage_update after it, and it worked correctly. Now i need to know if there's a "clean" way to reset m_ble_evt_handler because i've done it by adding an extra line in softdevice_handler.c.

The ble_stack_init(); function i'm using is literally copypasted from the ble_uart example from the sdk folder.

/**@brief Function for the S110 SoftDevice initialization.
 *
 * @details This function initializes the S110 SoftDevice and the BLE event interrupt.
 */
static void ble_stack_init(void)
{
    uint32_t err_code;

    // Initialize SoftDevice.
    softdevice_init();

    // Enable BLE stack.
    ble_enable_params_t ble_enable_params;
    memset(&ble_enable_params, 0, sizeof(ble_enable_params));
#if (defined(S130) || defined(S132))
    ble_enable_params.gatts_enable_params.attr_tab_size   = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
#endif
    ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
    err_code = sd_ble_enable(&ble_enable_params);
    APP_ERROR_CHECK(err_code);

    // Subscribe for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
}

I'm using sdk v10 with s110, and it's not currently a possibility to update to v11 or v12.

Related