|
7 | 7 |
|
8 | 8 | # NOTE: Make sure you've created your settings.toml file before running this example
|
9 | 9 | # https://learn.adafruit.com/adafruit-pyportal/create-your-settings-toml-file
|
| 10 | +from os import getenv |
| 11 | + |
10 | 12 | import adafruit_connection_manager
|
11 | 13 | import adafruit_requests
|
12 | 14 | import board
|
|
42 | 44 | if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
|
43 | 45 | print("ESP32 found and in idle mode")
|
44 | 46 | 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)) |
46 | 48 |
|
47 | 49 | 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)) |
49 | 51 |
|
50 | 52 | print("Connecting to AP...")
|
51 | 53 | while not esp.is_connected:
|
|
54 | 56 | except RuntimeError as e:
|
55 | 57 | print("could not connect to AP, retrying: ", e)
|
56 | 58 | 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) |
59 | 61 | print("IP lookup adafruit.com: %s" % esp.pretty_ip(esp.get_host_by_name("adafruit.com")))
|
60 | 62 | print("Ping google.com: %d ms" % esp.ping("google.com"))
|
61 | 63 |
|
|
0 commit comments