Skip to content

Commit 0274f09

Browse files
committed
Fix example
1 parent 2dd55a7 commit 0274f09

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/pyportal_internet_json_fetching.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
# NOTE: Make sure you've created your settings.toml file before running this example
99
# https://learn.adafruit.com/adafruit-pyportal/create-your-settings-toml-file
10+
from os import getenv
11+
1012
import adafruit_connection_manager
1113
import adafruit_requests
1214
import board
@@ -42,10 +44,10 @@
4244
if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
4345
print("ESP32 found and in idle mode")
4446
print("Firmware vers.", esp.firmware_version)
45-
print("MAC addr:", [hex(i) for i in esp.MAC_address])
47+
print("MAC addr:", ":".join("%02X" % byte for byte in esp.MAC_address))
4648

4749
for ap in esp.scan_networks():
48-
print("\t%s\t\tRSSI: %d" % (str(ap["ssid"], "utf-8"), ap["rssi"]))
50+
print("\t%-23s RSSI: %d" % (ap.ssid, ap.rssi))
4951

5052
print("Connecting to AP...")
5153
while not esp.is_connected:
@@ -54,8 +56,8 @@
5456
except RuntimeError as e:
5557
print("could not connect to AP, retrying: ", e)
5658
continue
57-
print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi)
58-
print("My IP address is", esp.pretty_ip(esp.ip_address))
59+
print("Connected to", esp.ap_info.ssid, "\tRSSI:", esp.ap_info.rssi)
60+
print("My IP address is", esp.ipv4_address)
5961
print("IP lookup adafruit.com: %s" % esp.pretty_ip(esp.get_host_by_name("adafruit.com")))
6062
print("Ping google.com: %d ms" % esp.ping("google.com"))
6163

0 commit comments

Comments
 (0)