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

pstorage guide

HI,everyone!

I want to use pstorage to store some data, so I followed the steps given by devzone.nordicsemi.com/.../, but it didn't work. Then I checked ecah function and found out the

pstorage_register (&p_example_param, &m_p_example_id)

return NRF_ERROR_NULL,and I can't find out where the problems come from.

Can someone point out the problem or give me an example for pstorage use?

Thank you very much!

Parents
  • Are you using device manager along with your test psorage? You shouldn't initialize pstorage_init twice if you call example_pstorage_init after device manager init. Or you need to increase maximum number of applications PSTORAGE_MAX_APPLICATIONS in pstorage_platform.h.

    UPD:

    You can read more about pstorage here.

    There is a pstorage example code here

    Example handler:

    // Event Notification Handler.
    static void example_cb_handler(pstorage_handle_t  * handle,
                                    uint8_t              op_code,
                                    uint32_t             result,
                                    uint8_t            * p_data,
                                    uint32_t             data_len)
    {
        switch(op_code)
        {
            case PSTORAGE_LOAD_OP_CODE:
               if (result == NRF_SUCCESS)
               {
                   // Store operation successful.
               }
               else
               {
                   // Store operation failed.
               }
               // Source memory can now be reused or freed.
               break;       
            case PSTORAGE_UPDATE_OP_CODE:
               if (result == NRF_SUCCESS)
               {
                   // Update operation successful.
               }
               else
               {
                   // Update operation failed.
               }
               break;
           case PSTORAGE_CLEAR_OP_CODE:
               if (result == NRF_SUCCESS)
               {
                   // Clear operation successful.
               }
               else
               {
                   // Clear operation failed.
               }
               break;
        }
    }
    
  • thank you for your fast reply!

    Firstly,I did not use the device manager and I am sure the pstorage just be init once. Secondly,I have tried to increase the PSTORAGE_MAX_APPLICATIONS but nothing changed.

    By the way, as the error NRF_ERROR_NULL means 'if NULL parameter has been passed', and I noticed the parameter m_p_example_id is just created without any initialization like this: static pstorage_handle_t m_p_example_id; will this be the problem? Thank you very much!

Reply
  • thank you for your fast reply!

    Firstly,I did not use the device manager and I am sure the pstorage just be init once. Secondly,I have tried to increase the PSTORAGE_MAX_APPLICATIONS but nothing changed.

    By the way, as the error NRF_ERROR_NULL means 'if NULL parameter has been passed', and I noticed the parameter m_p_example_id is just created without any initialization like this: static pstorage_handle_t m_p_example_id; will this be the problem? Thank you very much!

Children
No Data
Related