<?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>BLE Advertising module still uses pstorage in SDK 11?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13750/ble-advertising-module-still-uses-pstorage-in-sdk-11</link><description>I&amp;#39;m trying to migrate a BLE peripheral app on nRF51822 from SDK 10 and s110 to SDK 11 and s130. 
 I saw that the new Peer Manager does away with pstorage in favour of fstorage. I&amp;#39;ve migrated most of my code over and notice I&amp;#39;m now going to be very tight</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 13 May 2016 10:37:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13750/ble-advertising-module-still-uses-pstorage-in-sdk-11" /><item><title>RE: BLE Advertising module still uses pstorage in SDK 11?</title><link>https://devzone.nordicsemi.com/thread/52546?ContentTypeID=1</link><pubDate>Fri, 13 May 2016 10:37:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bd9516d-26b4-446e-be05-2cedfda81a5d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Good. Have reported it to the team so it should be fixed in SDK 12&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Advertising module still uses pstorage in SDK 11?</title><link>https://devzone.nordicsemi.com/thread/52545?ContentTypeID=1</link><pubDate>Fri, 13 May 2016 10:34:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3cf31649-6c5e-4908-9b02-f360e2ea6be7</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;Thank you. I&amp;#39;ll patch it for now and hope to see a fix in SDK 12.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Advertising module still uses pstorage in SDK 11?</title><link>https://devzone.nordicsemi.com/thread/52544?ContentTypeID=1</link><pubDate>Fri, 13 May 2016 10:33:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afd98c43-1506-428e-ba43-0e97c0bed968</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Yes, this is a SDK bug.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Advertising module still uses pstorage in SDK 11?</title><link>https://devzone.nordicsemi.com/thread/52543?ContentTypeID=1</link><pubDate>Fri, 13 May 2016 09:00:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05664510-fabb-4f76-930b-9ea20ee4d2d4</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;But it&amp;#39;s not in my code. It&amp;#39;s not even in the example project&amp;#39;s code. It&amp;#39;s your code - it&amp;#39;s in the SDK. It&amp;#39;s ble_advertising.c L185. Are you saying it&amp;#39;s an SDK bug?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Advertising module still uses pstorage in SDK 11?</title><link>https://devzone.nordicsemi.com/thread/52542?ContentTypeID=1</link><pubDate>Fri, 13 May 2016 07:55:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54b67898-bae6-4cb8-af28-e5b43ef3fbc7</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;rewrote my answer, hope it is more clear now. The short answer is that you can remove any reference to pstorage in your code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Advertising module still uses pstorage in SDK 11?</title><link>https://devzone.nordicsemi.com/thread/52541?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 15:42:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb6427da-8936-4c33-90a4-936209531a29</guid><dc:creator>Eliot Stock</dc:creator><description>&lt;p&gt;Not clear, sorry. The BLE advertising module does still use pstorage in SDK 11, yes? So if I want to use the Peer Manager and advertise, I must use both pstorage and pstorage in the one project?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE Advertising module still uses pstorage in SDK 11?</title><link>https://devzone.nordicsemi.com/thread/52540?ContentTypeID=1</link><pubDate>Thu, 12 May 2016 11:28:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a22598f-5744-45b1-89de-4980af0ca3c1</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Pstorage does not need to be linked in when using fstorage, and should have been removed from the SDK examples using peer manager / fstorage (reported as bug internally). The problem lays in the flash_access_in_progress() function which uses both fstorage and pstorage API to check for pending flash operations:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static bool flash_access_in_progress()
{
uint32_t err_code;
uint32_t count = 0;

// Will always return NRF_ERROR_INVALID_STATE since pstorage is not initialized
err_code = pstorage_access_status_get(&amp;amp;count);
if ((err_code != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp; (err_code != NRF_SUCCESS))
{
    ADV_LOG(&amp;quot;[ADV]: pstorage_access_status_get returned %d.\r\n&amp;quot;, err_code);
    return true;
}

if (err_code == NRF_ERROR_INVALID_STATE)
{
    err_code = fs_queued_op_count_get(&amp;amp;count);
    if (err_code != FS_SUCCESS)
    {
        return false;
    }
    ADV_LOG(&amp;quot;[ADV]: fs_queued_op_count_get gives count %d.\r\n&amp;quot;, count);
}

if(count != 0)
{
    return true;
}
else
{
    return false;
}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But the pstorage call won&amp;#39;t have any effect since it is not initialized and therefore safe to remove:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static bool flash_access_in_progress()
{
   uint32_t err_code;
   uint32_t count = 0;

   err_code = fs_queued_op_count_get(&amp;amp;count);
   if (err_code != FS_SUCCESS)
   {
       return false;
   }
   ADV_LOG(&amp;quot;[ADV]: fs_queued_op_count_get gives count %d.\r\n&amp;quot;, count);


  if(count != 0)
  {
      return true;
   }
   else
   {
      return false;
   }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that fstorage and pstorage are not designed to co-exist in the same project so the advertising module should either use pstorage_access_status_get() or fs_queued_op_count_get depending on what module is used in the application, but not both (wasting memory).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>