← index #5261PR #9460
Related · medium · value 0.872
QUERY · ISSUE

ESP8266 stuck in network.STAT_CONNECTING although connected

openby kevinkk525opened 2019-10-26updated 2019-10-27
port-esp8266

Somehow between multiple soft resets I was able to get the esp8266 stuck in a state where sta.isconnect() returns False and s.status() returns network.STAT_CONNECTING forever.
However it was perfectly connected and I could use the webrepl.
Only a disconnect followed by a connect fixed that.

I know that without a reproducable testcase this issue might be worthless, in which case feel free to close it. But maybe someone familiar with the esp8266 network code can see a possibility for this to happen now that he has the information.

(Well I can "reproduce" it by doing multiple resets in a wdt interrupt routine and repl reconnects but I can't provide a real testcase at the moment)

CANDIDATE · PULL REQUEST

ports/esp8266: Add auto_connect & reconnects options to WLAN.config().

openby glenn20opened 2022-09-29updated 2023-06-19
port-esp8266

Adds support for:

  • disabling/enabling the wifi auto-connect "feature" of the esp8266 (WLAN.config(auto_connect=True/False)); and
  • setting the reconnect policy for the esp8266 after disconnecting from wifi (WLAN.config(reconnects=xx)).

Motivation
The auto-connect feature is regarded by some as a mis-feature of the esp8266 and is one source of incompatible behaviour for code running on esp32 and esp8266. The auto_connect=False option allows users to ensure their esp8266 device's behaviour is deterministically derived from startup code. The reconnects option provides similar (but not the same) functionality to the reconnects opton on ESP32.

The semantics of the reconnects option differ from the esp32 in important ways:

  • reconnects=0:
    • ESP32 and ESP8266: No attempt is made to reconnect after disconnection from AP
  • reconnects>=1:
    • ESP32: Sets the maximum number of times the device will attempt to reconnect to AP
    • ESP8266: Sets the number of times device will attempt to retry dhcp after disconnecting.

Note: WLAN.config("reconnects") is not supported since the esp8266 SDK provide no mechanism for querying the current settings.

This PR adds:

  • WLAN.config(auto_connect=True/False) to enable/disable the ESP8266 from automatically connecting to wifi networks after WLAN.active(True).
  • WLAN.config(reconnects=xx) where xx is an integer to limit the number of times to attempt to reconnect after becoming disconnected from a wifi access point.

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