Skip to content

Commit 370e56e

Browse files
authored
Merge pull request #20 from jerryneedell/jerryn_simpletest
add retry to AP connect for simpletest
2 parents aaa5631 + c2ec50f commit 370e56e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/esp32spi_simpletest.py

Lines changed: 6 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")))

0 commit comments

Comments
 (0)