determining if the wifi password is wrong

Xials007
Posts: 1
Joined: Thu Sep 07, 2017 9:41 pm

determining if the wifi password is wrong

Postby Xials007 » Thu Sep 07, 2017 9:57 pm

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?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: determining if the wifi password is wrong

Postby kolban » Wed Sep 27, 2017 3:30 am

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.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32


patakil
Posts: 8
Joined: Thu Apr 12, 2018 11:32 am

Re: determining if the wifi password is wrong

Postby patakil » Tue Jul 03, 2018 3:59 pm

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.

Pibbotley
Posts: 45
Joined: Fri Feb 16, 2018 7:06 pm

Re: determining if the wifi password is wrong

Postby Pibbotley » Thu Jul 05, 2018 11:20 am

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.

patakil
Posts: 8
Joined: Thu Apr 12, 2018 11:32 am

Re: determining if the wifi password is wrong

Postby patakil » Fri Aug 31, 2018 6:24 pm

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

Who is online

Users browsing this forum: No registered users and 103 guests