This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why there is no call back after calling pstorage_clear?

Hello,

I am testing the sample project under \nrf6310\s310\ble_ant_app_hrm.

I just made one modification to bond_manager_init function in main.c: static void bond_manager_init(void) { uint32_t err_code; ble_bondmngr_init_t bond_init_data; bool bonds_delete;

bonds_delete = true;	//***force to clear any bonding information***

..... }

Then I set 2 breakpoints in ble_bondmngr.c and run the program.

BP1: uint32_t ble_bondmngr_init(ble_bondmngr_init_t * p_init) { ... // Erase all stored centrals if specified. if (m_bondmngr_config.bonds_delete) { err_code = flash_pages_erase(); //BP1 if (err_code != NRF_SUCCESS) { return err_code; } ...

BP2: static void bm_pstorage_cb_handler(pstorage_handle_t * handle, uint8_t op_code, uint32_t result, uint8_t * p_data, uint32_t data_len) { if (result != NRF_SUCCESS) //BP2 { m_bondmngr_config.error_handler(result); } }

I found that the program broke at bp1, but not bp2, is that normal?

I also tried to step through each line in the flash_pages_erase function and did not find any problem. static uint32_t flash_pages_erase(void) { uint32_t err_code;

err_code = pstorage_clear(&mp_flash_bond_info, MAX_BONDS_IN_FLASH);

if (err_code == NRF_SUCCESS)
{
    err_code = pstorage_clear(&mp_flash_sys_attr, MAX_BONDS_IN_FLASH);
}

return err_code;

}

When the program is in free run mode, I can detect the advertising signals from the test unit, so I am sure the softdevice is working correctly. Please advise.

Thank you! Joseph

Parents
  • Hi Joseph,

    Could you add following code and confirm the changes work for you? I see that system events are not being passed on to pstorage module in S310 example in SDK 5.1.0.

    
    /**@brief Function for dispatching a system event to interested modules.
     *
     * @details This function is called from the System event interrupt handler after a system
     *          event has been received.
     *
     * @param[in]   sys_evt   System stack event.
     */
    static void sys_evt_dispatch(uint32_t sys_evt)
    {
        pstorage_sys_event_handler(sys_evt);
    }
    
    /**@brief BLE + ANT stack initialization.
     *
     * @details Initializes the SoftDevice and the stack event interrupt.
     */
    static void ble_ant_stack_init(void)
    {
        // Initialize SoftDevice
        SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
        
        // Subscribe for BLE events.
        uint32_t err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
        APP_ERROR_CHECK(err_code);
            
        // Subscribe for ANT events.
        err_code = softdevice_ant_evt_handler_set(on_ant_evt);
        APP_ERROR_CHECK(err_code);
    
       // Register with the SoftDevice handler module for BLE events.
        err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
        APP_ERROR_CHECK(err_code);
    }
    
    

    This should hopefully fix the problem for you, and will be fixed in subsequent SDK release as well.

Reply Children
No Data
Related