generic_nvsflash

An ESP-IDF component for Physical Computing

Purpose

Read and write data in non-volatile flash storage on ESP32 systems.

This data is still available after the device is restarted.

How it is done

You need to include generic_nvsflash.hpp.

Then you define an instance of class GenericNvsFlash.

In the constructor of the class you state the namespace to use and whether you want to read and write or only to read the values from NVS flash.

Now you can use the setter and getter methods of the class to set or get the values of stored keys.

With method EraseKey you can delete keys from the namespace.

Changes to key values are uncommitted until the instance ist deleted. In the destructor the changes are committed to the namespace.

Where to find it

generic_nvsflash is published on the ESP Registry at https://components.espressif.com/components/elrebo-de/generic_nvsflash.

The source code can be found at https://github.com/elrebo-de/generic_nvsflash.

How to use it

As an ESP-IDF component generic_nvsflash must be included into idf_component.yml as a dependency. As usual this can be done by executing this command:

idf.py add-dependency "elrebo-de/generic_nvsflash^1.0.11"

In CMakeLists.txt "elrebo-de__generic_nvsflash" has to be added as a requirement.

Now you can include generic_nvsflash.hpp and use the GenericNvsFlash class in your program.

With this code snippet the value of a parameter is stored in an NVS namespace:


Comments

One response to “generic_nvsflash”

  1. […] elrebo-de/generic_nvsflash – to store/retrieve values in non volatile flash storage […]

Leave a Reply

Your email address will not be published. Required fields are marked *