WLAN.config(reconnects) and WLAN.status() doesn't work as intended
Hello!
MicroPython v1.20.0 on ESP8266.
Example:
import network
from time import sleep_ms
sleep_ms(3000)
sta = network.WLAN(network.STA_IF)
sta.active(True)
while not sta.active():
sleep_ms(100)
_wlan_status = sta.status()
sta.config(auto_connect=False, reconnects=0) # Number of reconnect attempts to make (integer, 0=none, -1=unlimited)
sta.connect('MyAPP')
while True:
_wlan_status = sta.status()
if _wlan_status == 0:
print('IDLE')
if _wlan_status == 1:
print('CONNECTING')
if _wlan_status == 2:
print('WRONG PASSWORD')
if _wlan_status == 3:
print('AP NOT FOUND')
if _wlan_status == 4:
print('CONNECTION FAILED')
if _wlan_status == 5:
print('SUCCESS')
sleep_ms(1000)
-
With
sta.config(reconnects=-1)the result isAP NOT FOUND, while withsta.config(reconnects=0)it isCONNECTING. -
When we are connecting to the non-existing AP, we receive
AP NOT FOUND, while connecting with wrong password we getCONNECTION FAILED. -
I am unable to capture
WRONG PASSWORDwhen using wrong password.
PR associated with this is https://github.com/micropython/micropython/pull/9460
PyboardD - Unable to connect to some 2G networks
I have an esp8266 and Pyboard-D side by side, the esp8266 connects but the pyboard does not.
On another 2G network both devices connect successfully.
def wltest():
import time
from network import WLAN
WLAN().disconnect()
WLAN().active(False)
WLAN().active(True)
WLAN().connect('2g@mynet','MYPASS')
while not WLAN().isconnected():
print('waiting...',WLAN().status())
time.sleep(1)
print(WLAN().ifconfig())
ESP8266
wltest()
('192.168.42.153', '255.255.255.0', '192.168.42.1', '192.168.42.1')
>>> state: 5 -> 0 (0)
rm 0
pm close 7
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 7
cnt
connected with xx@xxx, channel 11
dhcp client start...
ip:192.168.42.153,mask:255.255.255.0,gw:192.168.42.1
PYBOARD-D
wltest()
waiting... 1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
waiting... -1
- Wireless (2.4 GHz / eth1)
- MAC Address E4:F4:C6:00:6C:3C
- Wireless Mode Access Point
- Wireless Network Mode Auto
- Interface Status Up (LAN)
- Radio Enabled
- SSID wla@xxxxx
- Broadcast Enabled
- Security WPA Personal (PSK) + AES
- Channel 1 - 2.412 GHz
- Channel Width 40 MHz
- Interference Level Acceptable
- Rate 144mbps
The pyboard continues forever waiting, I have tried setting country to US and GB, wireless is channel width is 40mhz, not sure what other info I can provide ???