I am running the WIFI/WPS Example on my ESP32C3U.
While this does get me an IP address, and makes my μcontroller ping-able on my network, I would like to store the result of the WPS on the device (I am using the M5Stack STAMP-C3U μcontroller.)
NOTE: I use the push-button on my router to connect.
Any advice, or example-code on how to make a WPS result permanent, so that it can be reused after power-loss? Does the esp_wps system actually receive the wifi password? Or does it only receive a pin? How can this info be reused?
Saving SSID+passwd after WPS procedure.
Re: Saving SSID+passwd after WPS procedure.
Ah, Ok, I managed to do this. You can access credentials (after connecting) as:
And I write them to flash, using the SPIFFS interface.
Code: Select all
WiFi.SSID();
WiFi.psk();
Re: Saving SSID+passwd after WPS procedure.
or you can use this way:
the SSID and password are stored in the config and given to esp_wifi_set_config, after WPS has finished, you can just use the getter function again by calling
and you can then find the SSID and password in that struct again.
the SSID and password are stored in the config and given to esp_wifi_set_config, after WPS has finished, you can just use the getter function again by calling
Code: Select all
wifi_config_t config;
esp_err_t err = esp_wifi_get_config(WIFI_IF_STA, &config);
if (err == ESP_OK) {
printf("SSID: %s, PW: %s\n", (char*) config.sta.ssid, (char*) config.sta.password);
} else {
printf("Couldn't get config: %d\n", (int) err);
}
Re: Saving SSID+passwd after WPS procedure.
This no longer work with esp-idf-5.0+ unless you patch the esp-idf by yourself.toljatyr wrote: ↑Mon Sep 19, 2022 2:21 pmor you can use this way:
the SSID and password are stored in the config and given to esp_wifi_set_config, after WPS has finished, you can just use the getter function again by callingand you can then find the SSID and password in that struct again.Code: Select all
wifi_config_t config; esp_err_t err = esp_wifi_get_config(WIFI_IF_STA, &config); if (err == ESP_OK) { printf("SSID: %s, PW: %s\n", (char*) config.sta.ssid, (char*) config.sta.password); } else { printf("Couldn't get config: %d\n", (int) err); }
https://github.com/espressif/esp-idf/issues/10339
Who is online
Users browsing this forum: No registered users and 75 guests