cannot read nvs_flash

alphasion
Posts: 2
Joined: Fri Apr 16, 2021 2:45 pm

cannot read nvs_flash

Postby alphasion » Sat Apr 17, 2021 10:42 am

in my code ,i first callled
nvs_flash_init()

and write some parameters into nvs

Code: Select all

nvs_handle mHandler;
                  if (nvs_open(WIFI_TAG, NVS_READWRITE, &mHandler) == ESP_OK)
                  {
                     nvs_set_str(mHandler, NVS_SSID, wifi_ssid);
                     nvs_set_str(mHandler, NVS_PASS, wifi_pass);
                     if (nvs_commit(mHandler) == ESP_OK)
                     {
                        i2c_oled_showstr(0, 6, "W");
                     }
                     nvs_close(mHandler);
                  }

but while i try to read this with this code

Code: Select all

nvs_handle mHandler;
   bool ret = false;
   ret = nvs_open(WIFI_TAG, NVS_READONLY, &mHandler);
   ESP_ERROR_CHECK(nvs_get_str(mHandler, NVS_SSID, wifi_ssid, &wifi_ssid_length));
   ESP_ERROR_CHECK(nvs_get_str(mHandler, NVS_PASS, wifi_pass, &wifi_pass_length));
   nvs_close(mHandler);
   return ret;

there is an error :
ESP_ERROR_CHECK failed: esp_err_t 0x110c (ESP_ERR_NVS_INVALID_LENGTH) at 0x40221cd8
could any one tell me where my problem is?thx
btw,my partition table is Single Factory app,no OTA

Her Mary
Posts: 495
Joined: Mon Oct 27, 2014 11:09 am

Re: cannot read nvs_flash

Postby Her Mary » Thu Apr 22, 2021 5:18 pm

Could this example help?https://github.com/espressif/ESP8266_RTOS_SDK/blob/master/components/nvs_flash/test/test_nvs.c

alphasion
Posts: 2
Joined: Fri Apr 16, 2021 2:45 pm

Re: cannot read nvs_flash

Postby alphasion » Thu Apr 22, 2021 10:50 pm

thanks ,maybe i missed some code,it works now.

Who is online

Users browsing this forum: No registered users and 6 guests