QUERY · ISSUE
network.WLAN(network.STA_IF) will create a access point if connection failed.
bugport-esp8266
I am running MicroPython v1.20.0 on 2023-04-26; ESP module with ESP8266
I put the following code in boot.py and nothing in main.py:
from debugfun import breakpoint, vars
print("Activating network")
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect('ssid', 'password')
if my router power off when esp8266 connected, Then the esp8266 will create a new access point with the same ssid and password as my router. It's DHCP is 192168.4.*.
It will prevent the other devices to reconnect to the router.
CANDIDATE · PULL REQUEST
esp8266/modnetwork.c: Allows AP reconnection without WiFi credentials
There is no automatic reconnect after wlan.active(False);wlan.active(True). This commit provide the possibility to run wlan.connect() without parameter, to reconnect to the previously
connected AP.
@pfalcon This pull request resolve #2493.
I tested it with
wlan=network.WLAN(network.STA_IF)
wlan.isconnected()
wlan.connect()
and
wlan=network.WLAN(network.STA_IF)
wlan.active(False)
wlan.active(True)
wlan.connect()
Both will reconnect to the previously connected AP without providing WiFi credentials.