<?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>Logging realtime sensor data to flash</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6595/logging-realtime-sensor-data-to-flash</link><description>I would like to know if it is possible to log realtime sensor data to flash while advertising. I would like to have a device which transmits real time ECG data over ble UART to an android device when in range and once out of range, should start logging</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 29 Apr 2015 06:48:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6595/logging-realtime-sensor-data-to-flash" /><item><title>RE: Logging realtime sensor data to flash</title><link>https://devzone.nordicsemi.com/thread/23062?ContentTypeID=1</link><pubDate>Wed, 29 Apr 2015 06:48:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aeeaf5f3-f8e1-4891-8407-bcdee4e659ce</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Yes, you are correct, it is not possible to store data in flash 100 times per second and advertise at the same time. What you could do is to store the data in RAM instead, i.e. in a variable. If you have bonded with the central device (Android device) then the peripheral should have all information about the central device. Then you could periodically perform direct advertising (ADV_DIRECT_IND), which will take maximum 1.28 seconds. It will try to connect directly with a specific central. For those 1.28 seconds, you can store ECG data in RAM. If the device has not connected after 1.28 seconds, you can store the RAM data in flash in order to preserve RAM space before advertising again. You could also advertise normally (ADV_IND slower advertising interval) and include only the specific central address in a whitelist for the advertising.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging realtime sensor data to flash</title><link>https://devzone.nordicsemi.com/thread/23061?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2015 13:24:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d8b49c5-94e4-46a9-82f2-36054d64214d</guid><dc:creator>augustio</dc:creator><description>&lt;p&gt;Ok.  How then can I implement this feature such that data is not lost when a remote device is not in range. The idea here is that I have a peripheral that transmits ECG data 100 times per second to an android device. When the connected android device goes out of range, the connection is lost and then the peripheral, which is nrf51822 should start saving the data to flash while at the same time waiting for the android device to reconnect. Is it possible for the android device, which already has the address of the peripheral from the former connection, to reconnect without the peripheral advertising? If not, how do I implement this feature? Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging realtime sensor data to flash</title><link>https://devzone.nordicsemi.com/thread/23060?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2015 13:12:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ecce556-499c-4d64-9256-ff8d74dedf54</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;You should not do advertising and perform flash operation at the same time. This is ensured in i.e. the ble_app_hrs example in nRF51 SDK 6.1.0, see the advertising_start in main.c. Also in nRF51 SDK 8.0.0, see ble_advertising_start.&lt;/p&gt;
&lt;p&gt;So if you want to flash application data, then stop advertising, perform the flash operations and then restart advertising again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging realtime sensor data to flash</title><link>https://devzone.nordicsemi.com/thread/23058?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2015 13:06:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a85d499c-8531-43be-b420-85088fb47346</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;@Kosidinma   There is a &lt;a href="https://devzone.nordicsemi.com/question/15271/how-can-i-write-10kb-of-data-to-internal-flash/?answer=17300#post-id-17300"&gt;pstorage example here&lt;/a&gt; that uses 1.5 pages in flash (the pstorage_test_multipage_page_aligned function). I think the general rule to follow is to have blocks alligned with pages, i.e. to have block size e.g. 128 or 1024 bytes. Also note the two notes in the pstorage documentation:&lt;/p&gt;
&lt;p&gt;*- In case blocks span across multiple flash pages update and clear of blocks might not work as expected&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Loading, storing, updating and clearing of each block is supported. A single operation can not be requested for multiple blocks. However, clear is permitted on requested blocks. This is the only exception.*&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging realtime sensor data to flash</title><link>https://devzone.nordicsemi.com/thread/23057?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2015 12:22:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34559218-46e6-4439-be61-cdf771fc15ec</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Sorry, I&amp;#39;ve never had to implement anything like this so I do not have an example. If you search this forum there are discussions touching on pstorage usage when the data spans more than one page.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging realtime sensor data to flash</title><link>https://devzone.nordicsemi.com/thread/23059?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2015 23:26:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2a696f1-cc0e-4d1a-b77c-526a9f180cd4</guid><dc:creator>Kosidinma</dc:creator><description>&lt;p&gt;Hi, please could you give a pstorage example code showing this? I need to write at least 20kb sensor data as the value changes, read and periodically send said values on instruction and then clear the flash on system off. Thank you, this would be very helpful as most of the code i&amp;#39;ve seen show storage of predefined data of small size( 10 blocks of 16 bytes of known value)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Logging realtime sensor data to flash</title><link>https://devzone.nordicsemi.com/thread/23056?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2015 12:15:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b0018cb-d600-4eae-896d-62e21e5219ee</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Yes, that is certainly possible. You will have to decide on your approach as there are several ways to crack this nut. If you want to manage the flash yourself there are sd_flash_xxxxxx functions for writing, reading and erasing flash. If you want some abstraction and help managing the flash access you can use the pstorage utility and its API. I also believe there may be a higher level of abstraction through use of a device manager facility but I am not familiar with that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>