Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

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

    Scheduled Pinned Locked Moved Issues & Bugs
    wifiwlanifconfig
    5 Posts 3 Posters 888 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      martijnthe
      last edited by

      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
      
      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @martijnthe
        last edited by

        @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.

        M 2 Replies Last reply Reply Quote 0
        • M Offline
          martijnthe @jcaron
          last edited by

          @jcaron thanks, I'll try that.

          1 Reply Last reply Reply Quote 0
          • M Offline
            martijnthe @jcaron
            last edited by

            @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.

            P 1 Reply Last reply Reply Quote 0
            • P Offline
              Paul Thornton @martijnthe
              last edited by

              @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.

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • 1 / 1
              • First post
                Last post

              Pycom on Twitter

              Pycom