import utime
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
try:
wlan.connect("Abhinav J iPhone", "Ee31508105002")
except OSError as error:
print(f'error is {error}')
max_wait = 10
while max_wait > 0:
"""
0 STAT_IDLE -- no connection and no activity,
1 STAT_CONNECTING -- connecting in progress,
-3 STAT_WRONG_PASSWORD -- failed due to incorrect password,
-2 STAT_NO_AP_FOUND -- failed because no access point replied,
-1 STAT_CONNECT_FAIL -- failed due to other problems,
3 STAT_GOT_IP -- connection successful.
"""
if wlan.status() < 0 or wlan.status() >= 3:
break
max_wait -= 1
print('waiting for connection... ' + str(max_wait))
utime.sleep(1)
print(wlan.isconnected())