Faster Wifi Startup?



  • Coming from the ESP8266 I'm used to fast startup times where it seemed like the wifi connection was maintained between uPy soft reboots. When uploading to the WiPy (ESP32) it takes much longer for the wifi to start.

    Is there a configuration option that allows wifi to be saved between soft reboots? Faster the better - less time waiting to test new code that relies on WiFi.



  • @livius Thanks for the Chrono snippet. I'm always glad to find these nicely packaged design patterns.



  • @ssmith
    yes, but this is only example.
    i self use different code

    wasTimeout = 0
    chrono = Timer.Chrono()
    		chrono.start()
    		while not wlan.isconnected():
    			machine.idle()
    			if chrono.read()>30: #30 sedcond timeout
                                    wasTimeout = 1
    				break
    

    but as discussed somewhere on the forum, this is only "missed timeout feature".
    It should be passed to connect.



  • @ssmith, yes, but that's true with any contrived example.



  • @livius said in Faster Wifi Startup?:

    @semireg
    If you look into docs there is example

    if machine.reset_cause() != machine.SOFT_RESET:
        wlan.init(mode=WLAN.STA)
        # configuration below MUST match your home router settings!!
        wlan.ifconfig(config=('192.168.178.107', '255.255.255.0', '192.168.178.1', '8.8.8.8'))
    
    if not wlan.isconnected():
        # change the line below to match your network ssid, security and password
        wlan.connect('mywifi', auth=(WLAN.WPA2, 'mywifikey'), timeout=5000)
        while not wlan.isconnected():
            machine.idle() # save power while waiting
    

    Doesn't the while loop freeze the board if the WiFi doesn't connect?



  • Thanks for the replies. I'm using both of these techniques but upon sync via Atom (Pymakr plugin) the wlan is no longer connected.

    >>>
    Uploading project (src)...
    Reading file status
    [1/1] Writing file main.py
    Upload done, resetting board...
    ets Jun  8 2016 00:22:57
    
    rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:1
    load:0x3fff9028,len:8
    load:0x3fff9030,len:1060
    load:0x4009fa00,len:0
    ho 12 tail 0 room 4
    load:0x4009fa00,len:15072
    entry 0x400a063c
    Starting
    WLAN Not Connected
    


  • @semireg Like the example below, you can test at boot time whether the device is already connected (using wlan.isconnected()), and reconnect only if not. That works fine for me.



  • @semireg
    If you look into docs there is example

    if machine.reset_cause() != machine.SOFT_RESET:
        wlan.init(mode=WLAN.STA)
        # configuration below MUST match your home router settings!!
        wlan.ifconfig(config=('192.168.178.107', '255.255.255.0', '192.168.178.1', '8.8.8.8'))
    
    if not wlan.isconnected():
        # change the line below to match your network ssid, security and password
        wlan.connect('mywifi', auth=(WLAN.WPA2, 'mywifikey'), timeout=5000)
        while not wlan.isconnected():
            machine.idle() # save power while waiting
    


  • I find wifi connection fairly fast but i have found that on my netgear..it fails to connect for an unknown reason.


Log in to reply
 

Pycom on Twitter