#nvs can someone clarify how to traverse NVS? #nvs

Ruben Kertesz

I would like to use the NVS with the nrf9160 for remote logging. Specifically I don't understand how to track latest read and latest write at the same time.

I want to be able to write 5 values (time stamp and four readings) to a ring buffer in flash each time we take a measurement. I was thinking that the way to do this is to use 5 IDs and then use an index to track the latest successful read + upload. When I am connected to the internet I will read all five IDs for each measurement interval and send them to the server . The issue is that I don't want to send all of the recorded data to the server if for example the first hundred records that are stored in the ring buffer were already successfully uploaded and there are only 20 remaining measurement intervals that need to be uploaded. 

Am I going about this the wrong way? Does anybody have any expertise that they can offer in terms of how to index the saved measurements and then the traverse the index using something like a read pointer and a right pointer?

Speaking of, the point of all of this is that I know the sensor will sometimes be configured to log locally and only upload data every hour, 2 hours, 3 hours, etc. I would rather not clear out the buffer every time I upload data in the event that something else goes wrong, like data loss on the server. it's nice to be able to go to the physical device and retrieve locally logged data if needed

Join users@lists.zephyrproject.org to automatically receive all group messages.