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

pstorage issues

Hi

I'm trying to use pstorage to save some info (device name, and user info). I've found the following links with examples: infocenter.nordicsemi.com/index.jsp

devzone.nordicsemi.com/.../

Which have code that looks rather straightforward. But I'm having issues, where in some cases it either can only write, or only erase and I can't figure out what is the issue. Here is my code:

Init (in main):

retval = pstorage_init();
param.block_size  = 16;
param.block_count = 1;
param.cb          = store_cb_handler;
	
pstorage_register(&param, &handle);
pstorage_block_identifier_get(&handle, 0, &block_handle);

Then at some point manually call read, write and clear functions:

Read:

retval = pstorage_load(tempstr, &block_handle, 16, 0);				
if (retval == NRF_SUCCESS)
{
	ble_nus_string_send(&m_nus, tempstr, 16);
}
else
{
    ble_nus_string_send(&m_nus, "no", 3);
}

Write:

retval =pstorage_store(&block_handle, "Tostertostost000", 16, 0);
			
if (retval == NRF_SUCCESS)
{
    ble_nus_string_send(&m_nus, "ok", 3);
}
else
{
    ble_nus_string_send(&m_nus, "no", 3);
}

Clear:

pstorage_clear(&block_handle, 16);

So if I use &block_handle clear works, and if I put just &handle then store works. What could be the issue here?

Parents
  • I am using the SoftDevice, and I still have not figured out why cant it work. Why sometimes it works, but then 20 minutes later it does not?? The code is simple that it can't be more simple, yet I'm having such issues. Tho that code I linked works perfectly fine even with the SoftDevice. There are more things that don't make much sense with the nrf52 besides this that I had to work around in odd manners.

Reply
  • I am using the SoftDevice, and I still have not figured out why cant it work. Why sometimes it works, but then 20 minutes later it does not?? The code is simple that it can't be more simple, yet I'm having such issues. Tho that code I linked works perfectly fine even with the SoftDevice. There are more things that don't make much sense with the nrf52 besides this that I had to work around in odd manners.

Children
No Data
Related