Skip to content

Commit 02f6a1a

Browse files
committed
add retry to AP connect for simpletest
1 parent aaa5631 commit 02f6a1a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

examples/esp32spi_simpletest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@
2828
print("\t%s\t\tRSSI: %d" % (str(ap['ssid'], 'utf-8'), ap['rssi']))
2929

3030
print("Connecting to AP...")
31-
esp.connect_AP(b'MY_SSID_NAME', b'MY_SSID_PASSWORD')
31+
while not esp.is_connected:
32+
try:
33+
esp.connect_AP(b'MY_SSID_NAME', b'MY_SSID_PASSWORD')
34+
except RuntimeError as e:
35+
print("could not connect to AP, retrying: ",e)
36+
continue
3237
print("Connected to", str(esp.ssid, 'utf-8'), "\tRSSI:", esp.rssi)
3338
print("My IP address is", esp.pretty_ip(esp.ip_address))
3439
print("IP lookup adafruit.com: %s" % esp.pretty_ip(esp.get_host_by_name("adafruit.com")))
@@ -51,3 +56,4 @@
5156
r.close()
5257

5358
print("Done!")
59+

0 commit comments

Comments
 (0)