]> granicus.if.org Git - esp-idf/commitdiff
udp_perf/tcp_perf examples: Erase NVS if no more free pages
authorAngus Gratton <angus@espressif.com>
Mon, 20 Nov 2017 05:07:52 +0000 (16:07 +1100)
committerAngus Gratton <gus@projectgus.com>
Mon, 20 Nov 2017 05:07:52 +0000 (16:07 +1100)
Follows same pattern as other examples.

Amendment to https://github.com/espressif/esp-idf/pull/1279

examples/performance/tcp_perf/main/tcp_main.c
examples/performance/udp_perf/main/udp_main.c

index c96b0d02b476c2c3ac714e3811051ae7cce924c5..000ed6d42a467e1bdb105932b1687483c5708250 100644 (file)
@@ -124,7 +124,13 @@ static void tcp_conn(void *pvParameters)
 
 void app_main(void)
 {
-    nvs_flash_init();
+    esp_err_t ret = nvs_flash_init();
+    if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
+        ESP_ERROR_CHECK(nvs_flash_erase());
+        ret = nvs_flash_init();
+    }
+    ESP_ERROR_CHECK( ret );
+
 #if EXAMPLE_ESP_WIFI_MODE_AP
     ESP_LOGI(TAG, "EXAMPLE_ESP_WIFI_MODE_AP");
     wifi_init_softap();
index cad32a813470d2059f86b682d58edc1119e81c59..8bbd05ff0f84496bbdd4162a6f9eb4bf9f4b1f1e 100644 (file)
@@ -103,7 +103,13 @@ static void udp_conn(void *pvParameters)
 
 void app_main(void)
 {
-    nvs_flash_init();
+    esp_err_t ret = nvs_flash_init();
+    if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
+        ESP_ERROR_CHECK(nvs_flash_erase());
+        ret = nvs_flash_init();
+    }
+    ESP_ERROR_CHECK( ret );
+
 #if EXAMPLE_ESP_WIFI_MODE_AP
     ESP_LOGI(TAG, "EXAMPLE_ESP_WIFI_MODE_AP");
     wifi_init_softap();