Checking Wifi NVS data
Posted: Fri Dec 25, 2020 8:23 am
Here is my case :
Wifi NVS FLash is enabled. I am using esp_wifi_get_config to find out whether wifi configuration is saved in NVS. My code is :
It worked as expected. Then I erased and then initialized my nvs using nvs_flash_erase(); nvs_flash_init(); before the above written code. Now my output is
Expected output is:
Is my approach right? If not, then what is the correct way to check Wifi nvs data before configuring wifi?
Wifi NVS FLash is enabled. I am using esp_wifi_get_config to find out whether wifi configuration is saved in NVS. My code is :
Code: Select all
wifi_config_t conf;
ret = esp_wifi_get_config(ESP_IF_WIFI_STA, &conf);
if (ret == ESP_OK)
{
ESP_LOGI(TAG, "Wifi configuration already stored in flash partition called NVS");
ESP_LOGI(TAG, "%s" ,conf.sta.ssid);
ESP_LOGI(TAG, "%s" ,conf.sta.password);
}
else
{
ESP_LOGI(TAG, "Wifi configuration not found in flash partition called NVS.");
configure_wifi();
}
Code: Select all
I (697) Wifi station: Wifi configuration already stored in flash partition called NVS
I (707) Wifi station:
I (707) Wifi station:
Code: Select all
Wifi configuration not found in flash partition called NVS