24 wifi = network.WLAN(network.STA_IF) |
24 wifi = network.WLAN(network.STA_IF) |
25 wifi.active(False) |
25 wifi.active(False) |
26 wifi.active(True) |
26 wifi.active(True) |
27 wifi.connect(secrets.WIFI_SSID, secrets.WIFI_KEY if secrets.WIFI_KEY else None) |
27 wifi.connect(secrets.WIFI_SSID, secrets.WIFI_KEY if secrets.WIFI_KEY else None) |
28 max_wait = 140 |
28 max_wait = 140 |
29 while max_wait: |
29 while max_wait and wifi.status() != network.STAT_GOT_IP: |
30 if wifi.status() < 0 or wifi.status() >= 3: |
|
31 break |
|
32 max_wait -= 1 |
30 max_wait -= 1 |
33 sleep(0.1) |
31 sleep(0.1) |
34 if wifi.isconnected(): |
32 if wifi.isconnected(): |
35 print("WiFi connected:", wifi.ifconfig()) |
33 print("WiFi connected:", wifi.ifconfig()) |
36 else: |
34 else: |