ESP32C3 Connecting to wifi with wrong password will not feedback STAT_WRONG_PASSWORD status
I'm building firmware with idf v4.4.4 and master branch pulled yesterday, in my issue I given a wrong password to connect to wifi, but checking network.status() will print logs like below instead of STAT_WRONG_PASSWORD
I (15944) wifi: STA_DISCONNECTED, reason:15
I (18354) wifi: STA_DISCONNECTED, reason:205
According to the document Wi-Fi Reason Code, the reason:205 description is Espressif-specific Wi-Fi reason code: the connection to the AP has failed. and code name is CONNECTION_FAIL
In MicroPython documentation we can find a constant named STAT_CONNECT_FAIL, but it's definition only can found in esp8266 port, I think there must be a connection between CONNECTION_FAIL and STAT_CONNECT_FAIL
esp32: Add missing network.STAT_CONNECT_FAIL constant.
Summary
The esp32 port had network.STAT_ASSOC_FAIL for the same purpose, but this is undocumented and different to all other ports which use the documented STAT_CONNECT_FAIL. This PR deprecates STAT_ASSOC_FAIL for removal in MicroPython 2.0.
Closes #13167
This work was funded through GitHub Sponsors.
Testing
Flashed ESP32 port, checked that both constants exist and have the same numeric value.
Trade-offs and Alternatives
Having two STAT_ constants with the same numeric value might break someone's code if they're building a lookup table with reflection (for example), but I think this is preferable to either having to document port-specific statuses, or removing STAT_ASSOC_FAIL which will definitely break someone's code.
Future work
I see that a bunch of ESP32-specific constants have been added (STAT_NO_AP_FOUND_IN_RSSI_THRESHOLD, STAT_NO_AP_FOUND_IN_AUTHMODE_THRESHOLD, etc.) These are undocumented and make it hard to write portable code using the WLAN interface.
Suggest in a future PR to remove these (return STAT_NO_AP_FOUND for these cases), and add a wlan.status('verbose') or similar that can return additional port-specific details like this as a short string.