← index #10913Issue #11325
Related · high · value 0.803
QUERY · ISSUE

ESP32 / modnetwork / .status() is not reliable

openby pulkinopened 2023-03-03updated 2024-09-01
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:
image
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 codes/constants not unified across ports

openby msetinaopened 2023-04-24updated 2023-11-10
bug

Working with latest builds (20230422-unstable-v1.19.1-1019) of micropython I found some discrepancies:
ESP32 generic does not have STAT_CONNECT_FAIL in network module.
I noticed that status code value for connecting is 1 in rp2w and 1001 in ESP32.
If we should use constants from documentation then they should be implemented in all ports (please).

Some examples use codes (which is bad) that means they do not work correctly over ports

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