← index #11625PR #16270
Related · high · value 0.299
QUERY · ISSUE

ESP32C3 Connecting to wifi with wrong password will not feedback STAT_WRONG_PASSWORD status

openby walklinewangopened 2023-05-25updated 2023-11-10
bug

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

CANDIDATE · PULL REQUEST

esp32: Add missing network.STAT_CONNECT_FAIL constant.

mergedby projectgusopened 2024-11-20updated 2025-01-17
port-esp32

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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied