The value holds the number of ESP32 module restarts. Since it is written to NVS, the value is preserved between restarts.
-Example also shows how to check if read / write operation was successful, or certain value is not initialized in NVR. Diagnostic is provided in plain text to help track program flow and capture any issues on the way.
+Example also shows how to check if read / write operation was successful, or certain value is not initialized in NVS. Diagnostic is provided in plain text to help track program flow and capture any issues on the way.
-Check another example *08_nvs_rw_blob*, that shows how to read and write a blob (binary large object).
+Check another example *08_nvs_rw_blob*, that shows how to read and write variable length binary data (blob).
Detailed functional description of NVS and API is provided in [documentation](http://esp-idf.readthedocs.io/en/latest/api/nvs_flash.html).
-#
-# Main Makefile. This is basically the same as a component makefile.
-#
-# This Makefile should, at the very least, just include $(SDK_PATH)/make/component_common.mk. By default,
-# this will take the sources in the src/ directory, compile them and link them into
-# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
-# please read the ESP-IDF documents if you need to do this.
-#
include $(IDF_PATH)/make/component_common.mk
err = nvs_set_i32(my_handle, "restart_conter", restart_counter);
printf((err != ESP_OK) ? "Failed!\n" : "Done\n");
- // Commit
+ // Commit written value.
+ // After setting any values, nvs_commit() must be called to ensure changes are written
+ // to flash storage. Implementations may write to storage at other times,
+ // but this is not guaranteed.
printf("Committing updates in NVS ... ");
err = nvs_commit(my_handle);
printf((err != ESP_OK) ? "Failed!\n" : "Done\n");
-#
-# Main Makefile. This is basically the same as a component makefile.
-#
-# This Makefile should, at the very least, just include $(SDK_PATH)/make/component_common.mk. By default,
-# this will take the sources in the src/ directory, compile them and link them into
-# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
-# please read the ESP-IDF documents if you need to do this.
-#
include $(IDF_PATH)/make/component_common.mk
err = nvs_set_i32(my_handle, "restart_conter", restart_counter);
if (err != ESP_OK) return err;
- // Commit
+ // Commit written value.
+ // After setting any values, nvs_commit() must be called to ensure changes are written
+ // to flash storage. Implementations may write to storage at other times,
+ // but this is not guaranteed.
err = nvs_commit(my_handle);
if (err != ESP_OK) return err;