Skip to content

Commit 17808c3

Browse files
committed
examples: Update WiFi connect code.
1 parent 1879edd commit 17808c3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/micropython.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ def wifi_connect():
8787

8888
wlan = network.WLAN(network.STA_IF)
8989
wlan.active(True)
90-
wlan.connect(WIFI_SSID, WIFI_PASS)
91-
while (not wlan.isconnected()):
90+
while not wlan.isconnected():
91+
try:
92+
wlan.connect(WIFI_SSID, WIFI_PASS)
93+
except Exception as e:
94+
logging.error(f"Failed to connect to WiFi: {e}.")
9295
logging.info("Trying to connect. Note this may take a while...")
9396
time.sleep_ms(500)
9497
logging.info("WiFi Connected ", wlan.ifconfig())

0 commit comments

Comments
 (0)