while not wlan.isconnected(): - Infinite Loop

  • 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
    while not wlan.isconnected():
        print('Connecting Wifi attempt-{}'.format(wifi_count))
        wlan.connect('XXXX-NetGear', auth=(WLAN.WPA2, 'booboo@123'), timeout=5000)

    Thanks & regards,
    MK HB

  • @livius Thanks a lot :)

  • no it is not good
    look here for example:

    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
    wlan.ifconfig(config=('', '', '', ''))
    1. Do you have MAC filtering in your router enabled?
      if yes you must add mac of your LoPy

  • 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

Log in to reply

Pycom on Twitter