How detect timeout expired in wlan.connect() function



  • Hi to everyone.

    I have a problem with the function wlan.connect() that does not raise any exception if timeout expires.

    If a user insert a wrong SSID or a wrong Password, how I can dectect this? Also if the timeout expires, the while not wlan.isconnected() keeps on a infinte loop.

    Thx a lot



  • @Innocenzo The latter is easy, I have that in all of my espxxx's main.py:

    wlan = network.WLAN(network.STA)
    for _ in range(10):
        if wlan.isconnected():
            print('\nnetwork config:', wlan.ifconfig())
            break
        print('.', end='')
        time.sleep(1)
    else:
        print("\nCould not connect")
    


Pycom on Twitter