]> granicus.if.org Git - esp-idf/commitdiff
example: init nvs in iperf example
authorLiu Zhi Fu <liuzhifu@espressif.com>
Fri, 20 Oct 2017 01:52:58 +0000 (09:52 +0800)
committerLiu Zhi Fu <liuzhifu@espressif.com>
Fri, 20 Oct 2017 02:39:56 +0000 (10:39 +0800)
Need to call nvs_flash_init in iperf example

examples/wifi/iperf/main/main.c

index 66af23493b83b2ea11e9b91103ece1812ee73e5d..9553d6db0bb3d55bf1d1f8edf45c4dfe8694b638 100644 (file)
@@ -14,6 +14,7 @@
 #include "esp_wifi.h"
 #include "esp_log.h"
 #include "esp_err.h"
+#include "nvs_flash.h"
 
 #include "esp_console.h"
 #include "esp_vfs_dev.h"
@@ -69,6 +70,13 @@ static void initialize_console()
 
 void app_main(void)
 {
+    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 );
     initialise_wifi();
     initialize_console();