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

unable to use pstorage to persist data

I'm wrote a simple test to persist data using pstorage.

But I'm unable to load the stored data.

I'm using gcc and debugging with gdb. So I can see that storage_cb_handler is called correctly (op_code = 2, result = 0).

I compile using sdk 5.1 and softdevice 6.0.0

What I'm doing wrong ?

main.c

Parents
  • When using pstorage, it's important to understand that this module and its API are asynchronous. This means that the write hasn't actually been done before you get the success callback with your store opcode. You should therefore make sure to wait for that before trying to read out the data again if you want to verify that it has been written.

    Also, this is a pretty scary program; once the nRF51822 comes to the end of main(), more or less anything can happen, and this should hence be avoided. Always have an infinite loop in main, unless you know exactly what you're doing.

Reply
  • When using pstorage, it's important to understand that this module and its API are asynchronous. This means that the write hasn't actually been done before you get the success callback with your store opcode. You should therefore make sure to wait for that before trying to read out the data again if you want to verify that it has been written.

    Also, this is a pretty scary program; once the nRF51822 comes to the end of main(), more or less anything can happen, and this should hence be avoided. Always have an infinite loop in main, unless you know exactly what you're doing.

Children
No Data
Related