QUERY · ISSUE
WLAN.config(reconnects) and WLAN.status() doesn't work as intended
bug
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
CANDIDATE · PULL REQUEST
esp32/network_wlan: Fix network.WLAN.status().
port-esp32
status() can return STAT_NO_AP_FOUND/STAT_WRONG_PASSWORD when ssid/password is wrong.
This hints to users to set the correct credentials.
Fix #12930
Please set the port-esp32 label, the Labels button is not available for me. :(