<?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 handle never called</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5776/pstorage-handle-never-called</link><description>Hello everybody, 
 I&amp;#39;m trying to use pstorage module but it seems that the example_cb_handler function is never called when I try to store data. 
 I noticed similar issues in the forum and read pstorage documentation but It still doesn&amp;#39;t work... 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 22 Nov 2015 04:32:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5776/pstorage-handle-never-called" /><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20192?ContentTypeID=1</link><pubDate>Sun, 22 Nov 2015 04:32:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c016883-93c2-4b7a-b68c-2222f183c4d2</guid><dc:creator>kimbring2</dc:creator><description>&lt;p&gt;I solve it by adding the 100ms delay after the store function. It works well to me.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pstorage_store(&amp;amp;block_0_handle, source_data_0, 16, 0); 
nrf_delay_ms(100);
while(pstorage_wait_flag) { 
    //simple_uart_putstring((const uint8_t *)&amp;quot; \n\r Wait \n\r&amp;quot;);
    //nrf_delay_ms(10);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Please don&amp;#39;t forget to register the sys_evt_dispatch() to the ble_stack_init().
I spent a lot of my time to find my fault.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void sys_evt_dispatch(uint32_t sys_evt) {
    pstorage_sys_event_handler(sys_evt);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20191?ContentTypeID=1</link><pubDate>Sat, 20 Jun 2015 16:36:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:255c5c44-9801-4b73-b2e2-e861fabde14c</guid><dc:creator>joc</dc:creator><description>&lt;p&gt;I searched a lot. Only your solution works for me. Thank you! Also, nordic should make these pstorage functions use scheduler by default, maybe.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20190?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2015 13:35:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4eb7796-ecd1-4f68-b06e-c2a57e828071</guid><dc:creator>Alev</dc:creator><description>&lt;p&gt;Had the same problem. Just have solved it by moving erase/store calls from the event context to the main loop. So, as I see, &lt;strong&gt;one should not use this time-costs functions in the  BLE event handler or other interrupt context&lt;/strong&gt;. Maybe will useful for somebody.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20189?ContentTypeID=1</link><pubDate>Wed, 11 Mar 2015 17:59:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3438ed0-236d-462a-9c13-bffbb18e290a</guid><dc:creator>damien5606</dc:creator><description>&lt;p&gt;ok I see, thank you I&amp;#39;ll follow your advices !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20188?ContentTypeID=1</link><pubDate>Wed, 11 Mar 2015 11:20:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b09a8731-5da6-41d5-8bf6-68d009bacc30</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Damien: As you can find in our examples in the SDK v7.x+. We have a check for pending flash operation before starting advertising. The reason for that is we may miss a connect request when we are doing a flash operation (and advertise). So my suggestion is to stop advertising when you do a flash operation and start it back again after that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20187?ContentTypeID=1</link><pubDate>Wed, 11 Mar 2015 07:32:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:298545d0-502e-4d83-9fe7-7c6c1e5ba8ac</guid><dc:creator>damien5606</dc:creator><description>&lt;p&gt;Hi, thank you for your answer !&lt;/p&gt;
&lt;p&gt;I actually solved my problem a few days ago, At this time I didn&amp;#39;t know that the time to store data to the flash is approximately 23ms, so it takes to much time to do it when we are in communication with a central.
So I store the data after the communication, while I&amp;#39;m advertising (with an advertising interval&amp;gt;23ms) and it works !&lt;/p&gt;
&lt;p&gt;Regards,
Damien&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20186?ContentTypeID=1</link><pubDate>Mon, 09 Mar 2015 17:00:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3eb5db0-bde0-4069-9919-d5bcd825f80e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Damien,&lt;/p&gt;
&lt;p&gt;Could you try and test this example.&lt;/p&gt;
&lt;p&gt;I modified the ble_app_template and added some simple pstorage operation such as erase, write and read. You can find the 16 byte data written into flash is readout and added in the advertising packet (scan response packet) and also the LED1 will blink when the pstorage call back is called.&lt;/p&gt;
&lt;p&gt;Please notice that you need to added pstorage_sys_event_handler() in sys_evt_dispatch(). Also you need to align the address of the input data to 32bit word address.&lt;/p&gt;
&lt;p&gt;The example is from SDK v7.2 and tested on PCA100028 board, S110 v7.1&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_template-_2D00_-pstorage.zip"&gt;ble_app_template - pstorage.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20184?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2015 12:22:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfa6f710-5508-4a92-beff-107e4a373f59</guid><dc:creator>Kyu</dc:creator><description>&lt;p&gt;I debugged  this again. it doesn&amp;#39;t call cmd_process() because m_cmd_queue.flash_access is not false.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20179?ContentTypeID=1</link><pubDate>Fri, 27 Feb 2015 08:27:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b2551df-95e3-48f2-9362-456bc4dee6a8</guid><dc:creator>damien5606</dc:creator><description>&lt;p&gt;Bill, yes it&amp;#39;s a NRF_SUCCESS but it doesn&amp;#39;t mean that the data is stored and that you can read it, you&amp;#39;ve to wait a while, when the storage is finish it should call the handler (but in my case it doesn&amp;#39;t), then you&amp;#39;re sure that the operation is done.
asma, yes I guess we can just add delays, but I don&amp;#39;t know if it&amp;#39;s the best way to do it, I really don&amp;#39;t know why pstorage_store doesn&amp;#39;t call the handler
Anyway, thank you for your anwsers !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20185?ContentTypeID=1</link><pubDate>Fri, 27 Feb 2015 07:18:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de6ecf01-f249-4529-92b7-14e7ff30eafd</guid><dc:creator>asma</dc:creator><description>&lt;p&gt;I also have same problem. To resolve it i just add for loop like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pstorage_block_identifier_get(&amp;amp;handle, 0, &amp;amp;block_0_handle);
pstorage_clear(&amp;amp;block_0_handle, 16);                     //Clear 48 bytes		
pstorage_wait_handle = block_0_handle.block_id;    //Specify which pstorage handle to wait for
pstorage_wait_flag = 1;                        //Set the wait flag. Cleared in the example_cb_handler

		//Store data to block. Wait for the last store operation to finish before reading out the data.
pstorage_store(&amp;amp;block_0_handle, source_data_0, 16, 0);     //Write to flash, only one block is allowed for each pstorage_store command
//while(pstorage_wait_flag) { power_manage(); }              //Sleep until store operation is finished.
for(i=0; i &amp;lt; 1000;i++)
	{
	}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;its just a work around.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20183?ContentTypeID=1</link><pubDate>Fri, 27 Feb 2015 02:34:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f1d3031-27a7-425e-9d4e-a0a3a92bb1ca</guid><dc:creator>Bill Siever</dc:creator><description>&lt;p&gt;Is the return value on pstorage_store NRF_SUCCESS?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20181?ContentTypeID=1</link><pubDate>Fri, 27 Feb 2015 02:04:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32ea4425-d690-4139-8695-b4f9108b376e</guid><dc:creator>damien5606</dc:creator><description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;When I initialize my led I turn it on, &amp;quot;nrf_gpio_pin_set(LED_4);&amp;quot; turn my led off,
So my led turn off when pstorage failed to initialize or when the handler is called successfully, both of those events never happens.&lt;/p&gt;
&lt;p&gt;Like you Kyu, pstorage_load function call the handler but not pstorage_store...
I need the handler call to be sure that the store operation is done...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20182?ContentTypeID=1</link><pubDate>Fri, 27 Feb 2015 00:42:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5c5cd2d-7f9d-4166-82a5-16c018f9e658</guid><dc:creator>Bill Siever</dc:creator><description>&lt;p&gt;I&amp;#39;m assuming that &amp;quot;set&amp;quot; of LED_4 turns it on. Is that correct?&lt;/p&gt;
&lt;p&gt;The code above seems to set LED_4 when there is an error. Have you tried using a debugger (or commenting out one of the two places that turn it on) to identify where/why it comes on?&lt;/p&gt;
&lt;p&gt;Also, the example_cb_handler above sets LED_4 as well. There doesn&amp;#39;t appear to be any place that clears it. So there isn&amp;#39;t anything to distinguish an error from successful completion.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage handle never called</title><link>https://devzone.nordicsemi.com/thread/20180?ContentTypeID=1</link><pubDate>Thu, 26 Feb 2015 23:43:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7513f4d2-8b61-43b0-b310-22f2f28cc530</guid><dc:creator>Kyu</dc:creator><description>&lt;p&gt;me too.&lt;/p&gt;
&lt;p&gt;I enter the pstorage callback handler when I do pstorage_load function.
However, if I do pstorage_store and clear function, it is not call the call_back_handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>