← index #11636Issue #6969
Related · high · value 1.191
QUERY · ISSUE

network.WLAN(network.STA_IF) will create a access point if connection failed.

openby StreakingJerryopened 2023-05-28updated 2024-09-01
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 · ISSUE

esp2866 restart couldn't stop

closedby vidalouiswangopened 2021-02-27updated 2021-03-11
port-esp8266

`
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.

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