<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>pstorage store issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3478/pstorage-store-issue</link><description>HI,all! 
 I recently using pstorage to store data 
 and the pstorage_store(); funtion always returns NRF_SUCCESS, but never triggle the cb_handler, is that normal? 
 by the way, i just sucessfully store the data once and never success again.(the loaded</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Aug 2014 07:38:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3478/pstorage-store-issue" /><item><title>RE: pstorage store issue</title><link>https://devzone.nordicsemi.com/thread/12593?ContentTypeID=1</link><pubDate>Thu, 14 Aug 2014 07:38:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0797b9d0-2ae0-42a3-bca1-1e82f5ef835f</guid><dc:creator>kk</dc:creator><description>&lt;p&gt;I tried use the original example project &amp;quot;ble_app_template&amp;quot; and try again, and I successfully get into the cb_handler and load the data successfully, I think it might just because I modified the schedluer or something else in my project to cause the problem. Thank you very much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage store issue</title><link>https://devzone.nordicsemi.com/thread/12594?ContentTypeID=1</link><pubDate>Thu, 14 Aug 2014 06:43:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6bc3b31-8fc3-4794-a1f4-f8924c29338d</guid><dc:creator>kk</dc:creator><description>&lt;p&gt;Thanks again. Just as what you have said, I didn&amp;#39;t store data successfully once because I never get into the example_cb_handler. Actually I didn&amp;#39;t open the system_eve_handler in ble_stack_init();, does this cause the problem? But once I open it ,my code will run out of control, I really don&amp;#39;t konw why.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage store issue</title><link>https://devzone.nordicsemi.com/thread/12592?ContentTypeID=1</link><pubDate>Thu, 14 Aug 2014 05:56:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cc9615a-328e-46ad-879c-4a67a8f97ce4</guid><dc:creator>Nikita</dc:creator><description>&lt;blockquote&gt;
&lt;p&gt;pstorage_store(); funtion always
returns NRF_SUCCESS, but never triggle
the cb_handler, is that normal?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You need to init pstorage callback like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void mypstorage_init(void)
{
...
            p_example_param.cb          = example_cb_handler;
    pstorage_init();
...

void example_cb_handler(pstorage_handle_t *  p_handle,
                              uint8_t              op_code,
                              uint32_t             result,
                              uint8_t *            p_data,
                              uint32_t             data_len)
{
        ;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;by the way, i just sucessfully store
the data once and never success
again.(the loaded data is 0xff)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You are doing it wrong, if you do it like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pstorage_store(&amp;amp;p_block_id,flash2,size,offset);
pstorage_load(myflash2,&amp;amp;p_block_id,size,offset);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then when you call pstorage_store you just send request to store your data to pstorage and when this function will return with NRF_SUCCESS your data won&amp;#39;t be stored in flash yet. It will be stored after a while and then pstorage will report this in callback example_cb_handler. And only after this you can try to load this stored data.&lt;/p&gt;
&lt;p&gt;Read &lt;a href="https://devzone.nordicsemi.com/documentation/nrf51/6.0.0/s110/html/a00018.html"&gt;this&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;UPD:&lt;/p&gt;
&lt;p&gt;What do you mean by running out of control?&lt;/p&gt;
&lt;p&gt;For the proper pstorage functioning you need to set sys events handler like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void sys_evt_dispatch(uint32_t sys_evt)
{
    pstorage_sys_event_handler(sys_evt);
}

static void ble_stack_init(void)
{
...
    // Register with the SoftDevice handler module for SYS events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>