wlan.ifconfig() sometimes not working (AP mode)



  • I'm using ifconfig() to configure the AP mode network.
    Most of the times it works fine, but sometimes, I end up with different settings being applied. I added a call without arguments to ifconfig() to get the actual config again, after attempting to set it, to confirm that it's being set incorrectly (or perhaps being overwritten shortly after by some other subsystem in the firmware?)

    Relevant portion of code that runs early at boot: -- note this runs on another thread than the main thread, don't think it should matter, but perhaps it does.

        ...
        _WLAN = WLAN()
        _WLAN.init(mode=WLAN.AP, ssid=_SSID, auth=(WLAN.WPA2, wifi_password), channel=6)
        _WLAN.ifconfig(id=1, config=('10.0.0.254', '255.255.255.0', '10.0.0.254', '10.0.0.254'))
        print('ifconfig: {}'.format(_WLAN.ifconfig(id=1)))
        print('WiFi up with SSID: {}'.format(_SSID))
    

    Log output:

    Starting the WDT on boot
    Booted in 20 secs
    Pycom MicroPython 1.18.1.r1 [f5d0c68] on 2018-09-06; LoPy with ESP32
    Type "help()" for more information.
    ### Starting Webserver ###
    I (5574) wifi: mode : softAP (24:0a:c4:0a:95:d1)
    I (5575) wifi: sleep disable
    ifconfig: ('192.168.4.1', '255.255.255.0', '192.168.4.1', '10.0.0.254')
    WiFi up with SSID: Testing
    


  • @martijnthe Intresting. my guess would have been a weird thread race between your thread and our code that deals with setting up wifi on boot. But if its still happening with that's disabled I'd guess its something else.

    Ill raise it in tomorrows standup and see if anyone else know's anything about it.



  • @jcaron I had tried setting wifi_on_boot to false but the problem still happens occasionally.
    I ended up with a work-around where I query the config after attempting to set it. If the queried result doesn't match what was attempted to be set, just try again.



  • @jcaron thanks, I'll try that.



  • @martijnthe not sure if that would change anything, but can you try setting wifi_on_boot to false?

    Looks like there’s a conflict between the default WiFi settings and yours, so taking the default out may help.

    You may need to start Server yourself.


Log in to reply
 

Pycom on Twitter