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

    while not wlan.isconnected(): - Infinite Loop

    Scheduled Pinned Locked Moved LoPy
    4 Posts 2 Posters 1.3k Views 2 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
      mkharibalaji
      last edited by

      Hi Team,
      After the latest update

      (sysname='LoPy', nodename='LoPy', release='1.5.0.b2', version='v1.8.6-412-gf55ba50 on 2017-01-28', machine='LoPy with ESP32')

      The below code is entering into an infinite Loop.Is wlan isConnected not working ?

      from network import WLAN
      from time import sleep_ms
      
      wifi_count=1
      while not wlan.isconnected():
          print('Connecting Wifi attempt-{}'.format(wifi_count))
          wlan.connect('XXXX-NetGear', auth=(WLAN.WPA2, 'booboo@123'), timeout=5000)
          sleep_ms(1000)
          wifi_count=wifi_count+1
          pass
      

      Thanks & regards,
      MK HB

      1 Reply Last reply Reply Quote 0
      • M Offline
        mkharibalaji
        last edited by

        Hi Guys,
        If we increase sleep_ms to 5 secs then it works ? Is that the proper way to do this ?

        Thanks & regards,
        MK HB

        1 Reply Last reply Reply Quote 0
        • L Offline
          livius
          last edited by livius

          no it is not good
          look here for example:
          https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/wlan.html

          while not wlan.isconnected():
                      machine.idle() # save power while waiting
          

          and questions:

          1. your router have dhcp enabled?
            if not then try setting fixed ip in your LoPY
            e.g.
          wlan.ifconfig(config=('192.168.1.120', '255.255.255.0', '192.168.1.1', '192.168.1.1'))
          
          1. Do you have MAC filtering in your router enabled?
            if yes you must add mac of your LoPy

          think about people first, then computers

          M 1 Reply Last reply Reply Quote 0
          • M Offline
            mkharibalaji @livius
            last edited by

            @livius Thanks a lot :)

            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