ESP8266 stuck in network.STAT_CONNECTING although connected
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)
esp2866 restart couldn't stop
`
def init():
import net
if net.connect('ssid', 'password'):
print("ok")
init()
`
After running this code, esp8266 will reboot itself(hard reset) won't stop.
net.py:
`
import network
def connect(ssid,password=None):
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
import machine
a = scan(ssid)
if a:
wlan.connect(ssid, password)
while not wlan.isconnected():
machine.idle()
return True
def scan(ssid=None):
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if ssid:
a = wlan.scan()
for i in a:
if i[0] == bytes(ssid,"ascii"):
return i
else:
return wlan.scan()
`
Need to erase and flash firmware in esptool will recover.