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?

Related