Page 1 of 1

determining if the wifi password is wrong

Posted: Thu Sep 07, 2017 9:57 pm
by Xials007
So I want to be able to determine if the credentials a user sets for the wifi password are invalid. The only way to do that would to have the esp32 tell me that it tried to connect but got a bad password error. So far the only think I saw that *might* do that is esp_wifi_set_config() but that doesn't appear to work how I think it should. Any ideas?

Re: determining if the wifi password is wrong

Posted: Wed Sep 27, 2017 3:30 am
by kolban
To validate the password for an access point is correct, then you would attempt to connect to the access point. Using the API called esp_wifi_connect() seems like it should work. That is an asynchronous call (I believe) so you will have to register an event handler to be asynchronously informed of the outcome. If all you want to do is test that the password is the one expected by the access point, then after a successful connect, you would then disconnect again.

Re: determining if the wifi password is wrong

Posted: Wed Sep 27, 2017 4:09 am
by WiFive

Re: determining if the wifi password is wrong

Posted: Tue Jul 03, 2018 3:59 pm
by patakil
Is there any news about this?

As I understand according to the documentation, if the password is wrong then SYSTEM_EVENT_STA_DISCONNECTED raised with WIFI_REASON_AUTH_FAIL(=202) reason code.
When I am testing the reason code is 0.

In another case, if the SSID is not found then it works well, I get WIFI_REASON_NO_AP_FOUND.

Is it a bug or just I misunderstood something?

Thanks in advance for any help.

Re: determining if the wifi password is wrong

Posted: Thu Jul 05, 2018 11:20 am
by Pibbotley
Maybe the library you are using does not pass on that reason code so you have to use a lower level function - check the source code of the library you are using.

Re: determining if the wifi password is wrong

Posted: Fri Aug 31, 2018 6:24 pm
by patakil
Hi
Thanks for your answer.
I am using only the ESP-IDF.

Here is how I have tested:
Create a hotspot with your computer.
Set the wrong pw in the 'scan' example.
Put this row into the SYSTEM_EVENT_STA_DISCONNECTED event:
printf("reason: %d\n",event->event_info.disconnected.reason);

If you get the result of the fist some connection attempt, restart the chip and check the next test.

- You will see, that many times the reason code is 0 in every attempt.
- In some other tests, the code first is 2 which is correct, but after that always 0.

If you have an example that how you determine surely the wrong pw I could really appreciate that.

Thanks