determining if the wifi password is wrong
determining if the wifi password is wrong
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
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
Re: determining if the wifi password is wrong
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.
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
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
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
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