Page 1 of 1

WPS not working correctly

Posted: Thu Jan 20, 2022 2:51 pm
by sm9ai1
Hi,

I have an issue getting WPS to work correctly on an ESP32-C3 demo board running ESP-IDF v4.3.2

I am using unmodified demo code (Examples/WiFi/WPS)

If I put the router into WPS, then start the demo it will connect to the router correctly. :)

If I start the demo, then put the router into WPS it will not connect and WPS will timeout. :(
At the end of the timeout, the demo restarts the WPS procedure again, and it then connects.

I don't believe this is correct behavior, as it shouldn't have to wait for the timeout before connecting.
I also don't think restarting the WPS connection after timeout is a good idea.

Does anyone else experience this? Or is there a setting that is missing :?:

Re: WPS not working correctly

Posted: Mon Sep 19, 2022 1:35 pm
by toljatyr
I also faced the same problem and believe it is not correct behavior.
Furthermore, I believe that in order for WPS to be of practical use, it should provide credentials for further connection to the same router, however, the example doesn't provide any. It is said in the code

Code: Select all

/*
  * If only one AP credential is received from WPS, there will be no event data and
  * esp_wifi_set_config() is already called by WPS modules for backward compatibility
  * with legacy apps. So directly attempt connection here.
*/
So I wonder whether it is possible at all to obtain credentials for the AP in order to be able to reconnect to it after reboot or disconnect?

Re: WPS not working correctly

Posted: Mon Sep 19, 2022 1:46 pm
by toljatyr
finally, I found answer to my question.
So 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);
}