<?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 update problem-call back is not getting called</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5549/pstorage-update-problem-call-back-is-not-getting-called</link><description>Hello Everyone ,
I am using ble stack S110 , BATTERY SERVICE , my CUSTOM SERVICE and pstorage module in my application and using SDK 7.0.0 and keil 5.12 IDE .whenever a server writes anything to a client characteristic data sent by a server shud be written</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Dec 2015 14:28:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5549/pstorage-update-problem-call-back-is-not-getting-called" /><item><title>RE: pstorage update problem-call back is not getting called</title><link>https://devzone.nordicsemi.com/thread/19422?ContentTypeID=1</link><pubDate>Fri, 18 Dec 2015 14:28:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cacff1ab-b26d-45b0-9348-2fe8172f357d</guid><dc:creator>Morten Kristiansen</dc:creator><description>&lt;p&gt;I know this is a bit late; but you might experience the same problem as we do. We use SDK 7.1.0 since we use nRF51 V2.&lt;/p&gt;
&lt;p&gt;In pstorage_sys_event_handler it clears m_cmd_queue.flash_access = false regardless of what message it receives. This makes pstorage.c go kawonga and you don&amp;#39;t receive your callback.&lt;/p&gt;
&lt;p&gt;We solved the problem by only invoking pstorage_sys_event_handler for flash events.&lt;/p&gt;
&lt;p&gt;Also, just a stupid thought... Did you remember to declare pstorage_wait_flag volatile?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void sys_evt_dispatch(uint32_t sys_evt)
{
    switch (sys_evt)
    {
    case NRF_EVT_FLASH_OPERATION_SUCCESS:
    case NRF_EVT_FLASH_OPERATION_ERROR:
        pstorage_sys_event_handler(sys_evt);

        break;

    default:
        // No implementation needed.
        break;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage update problem-call back is not getting called</title><link>https://devzone.nordicsemi.com/thread/19421?ContentTypeID=1</link><pubDate>Fri, 13 Feb 2015 05:00:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71a65090-8bcb-46de-9bbe-b2a1ff0c6e75</guid><dc:creator>Bill Siever</dc:creator><description>&lt;p&gt;One approach:&lt;/p&gt;
&lt;p&gt;You could remove the delay loop from pstorage_update_block().
You could change on_write_mode_handler() so it starts a recurring timer with a short delay.
When the timer is completed, it&amp;#39;s callback checks to see that all pending writes are done. If so, it does therapy_parameters_write(), pstorage_update_block(), and cancels the timer. Otherwise it just delays and checks again.&lt;/p&gt;
&lt;p&gt;There are a lot of variations on this approach. I just tried to describe a technique that takes minimal code.&lt;/p&gt;
&lt;p&gt;On a related note, it might be worth looking into the time required for a flash update.  You might be able to show that events will always be far enough apart that all writes will be completed before the next could possibly be requested.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage update problem-call back is not getting called</title><link>https://devzone.nordicsemi.com/thread/19420?ContentTypeID=1</link><pubDate>Fri, 13 Feb 2015 04:07:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5076e092-0e8b-4177-a249-c359747551a0</guid><dc:creator>asma</dc:creator><description>&lt;p&gt;Thanks bill for your reply. according to your 3rd point i shud wait for update or store to complete. is there any other way to know if this operation is complete or not , one way i know is callback handler which is i am using , but its not working as i mentioned . is there any other way out.&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards Asma&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage update problem-call back is not getting called</title><link>https://devzone.nordicsemi.com/thread/19419?ContentTypeID=1</link><pubDate>Thu, 12 Feb 2015 12:46:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6edb5a89-d25c-4db8-acb2-0ebb2be59429</guid><dc:creator>Bill Siever</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure, but I think there&amp;#39;s a chance you&amp;#39;re seeing &amp;quot;starvation&amp;quot; of a shared resource. (Perhaps Petter can quickly confirm/deny).&lt;/p&gt;
&lt;p&gt;From a soft radio callback (on_write_mode_handler()) you&amp;#39;re calling:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void pstorage_update_block(void)
{
    retval = pstorage_block_identifier_get(&amp;amp;handle, 0, &amp;amp;block_0_handle);

    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
    retval = pstorage_update(&amp;amp;block_0_handle, source_data_0, 16, 0);    //update flash block 0

    while(pstorage_wait_flag) { power_manage();}               //Sleep until update operation is finished.
 }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Essentially it is stuck in the callback until pstorage_wait_flag is cleared.  But the pstorage_wait_flag is cleared in another callback (example_cb_handler()). If the initial callback (on_write_mode_handler()) has a higher priority or even if they are resolved in first-come-first-serve order, the example_cb_handler() callback will never get a chance to run and never be able to update the flag that pstorage_update_block() is waiting on.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think there&amp;#39;s any need to do the &amp;quot;while(pstorage_wait_flag) { power_manage();}&amp;quot; in pstorage_update_block(). I think the only reasons you would need to wait are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;If you want to read data and there are pending operations on the same block.&lt;/li&gt;
&lt;li&gt;If the pstorage command queue is full.&lt;/li&gt;
&lt;li&gt;If you want to modify the data buffer that you passed to pstorage_update() or pstorage_store(), you should wait for the update or store to complete.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: pstorage update problem-call back is not getting called</title><link>https://devzone.nordicsemi.com/thread/19418?ContentTypeID=1</link><pubDate>Thu, 12 Feb 2015 11:16:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:863652da-2f62-4b18-ab4e-2f6cec99bac1</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Could you upload your complete project so I can test it here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>