Fastest WLAN connect with AP fallback

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Posts: 107
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall

Fastest WLAN connect with AP fallback

Postby devnull » Thu Feb 23, 2017 12:41 pm

Does anyone have a faster, more concise, low RAM WLAN connection routine that falls back to AP mode if it can't connect to the wlan ?

Code: Select all

def connect(timeout=10,ssid=None,passkey=None):
   from network import WLAN,STA_IF, AP_IF
   sta = WLAN(STA_IF)
   if not sta.isconnected():
        from time import sleep_ms
        for count in range(timeout*10):
           if sta.isconnected(): break
        if not sta.isconnected():
           sta = WLAN(AP_IF)
   print('Connect msec:',count*100,'ifconfig:',sta.ifconfig())
   return sta

wl = connect(timeout=5,ssid='wlan@mywan',passkey='mypass')

Return to “ESP8266 boards”

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests