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

Advertising won't start when using Pstorage

Hi,

Before starting advertising using advertising_start() function, if pstorage function is used to write data, then it gets stuck at that point as no pstorage handler callback is received and BLE advertising mode never starts. The code is similar to what is mentioned on this thread. devzone.nordicsemi.com/.../

Please let me know the reason why this is happening. I am using S130 and SDK 11.

Parents
  • Hi,

    Issuing a softdevice flash operation should always lead to a system event that tells the application whether the operation succeeded or not. This " system" event is reported to the registered system event handler (softdevice_sys_evt_handler_set()), which should forward it to the pstorage_sys_event_handler(), and then forward it to the pstorage callback you have declared.

    One possible reasons for it the event to not be reported is if the pstorage_sys_event_handler() is not called upon system events. E.g., forgetting to add pstorage_sys_event_handler() here:

    static void sys_evt_dispatch(uint32_t sys_evt)
    {
        pstorage_sys_event_handler(sys_evt);
    }
    

    Another possibility is that if you are using a blocking function like 'while(pstorage_wait_flag)' from an interrupt context. That would stop any new system events from being serviced (flash events has the lowest interrupt priority). In other words, the event will never get through in such case.

  • Have you defined PSTORAGE_NUM_OF_PAGES as '2' or more ? The DM module typically uses around one flash page.

    Reason for the reset may be that you are ending up in the app error handler. Can for instance happen if you attempt to register a new pstorage instance without having allocated enough flash pages. You can debug the application to find the source of a possible assert.

Reply Children
No Data
Related