Properly checking for errors during a WiFi connection?
Posted: Sun Oct 20, 2019 2:47 pm
Hello, MicroPython forums! I'm trying to connect to a network on a ESP32 while telling the status and the reason for an error, if it occurs. Since there is no WLAN irq for the ESP32 port, I thought that initializing a timer when connecting, for checking the status every half a second and counting it up to a given timeout, is quite adequate. Or is there any more recommended way to do that? Also, it seems to stay for well over 10 seconds in the 1001 status (connecting) and never goes to the error status messages. So how do I find out when it resulted in an incorrect password or any other error?
I cannot find any propper documentation for the WLAN.status() numbers. The ones I found so far are:
Lastly, when I worked with AT firmware on the ESP32 before trying out MicroPython, I could get a response when the module was connecting to a network, and another when it had already connected and was getting an IP. MicroPython seems to skip the "getting IP" step and only go from 1001 (connecting) immediately after issuing the connect command to 1010 (connected and got IP). Is it just incomplete so far or is there another way of checking for that?
TL;DR:
I cannot find any propper documentation for the WLAN.status() numbers. The ones I found so far are:
- 200: BEACON_TIMEOUT
- 201: NO_AP_FOUND
- 202: WRONG_PASSWORD
- 203: ASSOC_FAIL
- 204: HANDSHAKE_TIMEOUT
- 1000: IDLE
- 1001: CONNECTING
- 1010: GOT_IP
Lastly, when I worked with AT firmware on the ESP32 before trying out MicroPython, I could get a response when the module was connecting to a network, and another when it had already connected and was getting an IP. MicroPython seems to skip the "getting IP" step and only go from 1001 (connecting) immediately after issuing the connect command to 1010 (connected and got IP). Is it just incomplete so far or is there another way of checking for that?
TL;DR:
- How to properly retrieve the error status of a connection (wrong password or timeout) or how to access the WLAN irq on ESP32?
- What are all the WLAN.status() codes?
- Can I check for when the module is connected but still getting the IP, before the connection is fully established?