Skip to content

Commit ecd84e2

Browse files
authored
Merge pull request #2571 from elpekenin/fix/adafruit-metro-esp32-s2/circuitpython-internet-test
[Small bugfix] ESP32 WiFi example
2 parents 900b2f0 + 123a190 commit ecd84e2

File tree

1 file changed

+10
-5
lines changed
  • ESP32_S2_WiFi_Tests/CPy_Native_WiFi_Test

1 file changed

+10
-5
lines changed

ESP32_S2_WiFi_Tests/CPy_Native_WiFi_Test/code.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@
3030
print(f"My IP address: {wifi.radio.ipv4_address}")
3131

3232
ping_ip = ipaddress.IPv4Address("8.8.8.8")
33-
ping = wifi.radio.ping(ip=ping_ip) * 1000
34-
if ping is not None:
35-
print(f"Ping google.com: {ping} ms")
36-
else:
33+
ping = wifi.radio.ping(ip=ping_ip)
34+
35+
# retry once if timed out
36+
if ping is None:
3737
ping = wifi.radio.ping(ip=ping_ip)
38-
print(f"Ping google.com: {ping} ms")
38+
39+
if ping is None:
40+
print("Couldn't ping 'google.com' successfully")
41+
else:
42+
# convert s to ms
43+
print(f"Pinging 'google.com' took: {ping * 1000} ms")
3944

4045
pool = socketpool.SocketPool(wifi.radio)
4146
requests = adafruit_requests.Session(pool, ssl.create_default_context())

0 commit comments

Comments
 (0)