QUERY · ISSUE
ESP32 / modnetwork / .status() is not reliable
bugneeds-info
HW: ESP32 device
SW:
>>> os.uname()
(sysname='esp32', nodename='esp32', release='1.19.1', version='v1.19.1 on 2022-06-18', machine='ESP32 module (spiram) with ESP32')
Issue: polling WLAN(STA_IF).status() does not always provide an adequate response. Example:
>>> import socket
>>> s = socket.socket()
>>> s.connect(("192.168.1.136", 33567))
>>> WLAN(STA_IF).status()
1001
>>> s.read(18)
b'NBDMAGICIHAVEOPT\x00\x03'
>>> WLAN(STA_IF).status()
1001
In other words, sockets operate just fine while .status() == 1001 == STAT_CONNECTING. Instead, it should return .status() == 1010 == STAT_CONNECTED. Sniffing the router shows that ESP is, at least, aware of its assigned IP:

I expect that the flag wifi_sta_connected is not set properly.
https://github.com/micropython/micropython/blob/2bcd88d55645f2ea702ff70336b33be4661c97a8/ports/esp32/network_wlan.c#L280-L302
Reproducing: loop over connecting and disconnecting to the same wireless network. At some point the issue pops up.
CANDIDATE · ISSUE
Network Status ESP32
ESP32
version 1.9.4
network.status()
always return None
This was recently implemented here: https://github.com/micropython/micropython/commit/385fa5180663221bbec033c54c37fb38f589579b
@dpgeorge
I checked that
result:
turn off my router
result:
status() e isconnected() not changed.
thanks