forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed as not planned
Closed as not planned
Copy link
Labels
Milestone
Description
Firmware
Adafruit CircuitPython 6.2.0-beta.3 on 2021-03-04; Adafruit MagTag
Code/REPL
Wifi test from guide
import ipaddress
import ssl
import wifi
import socketpool
import adafruit_requests
# URLs to fetch from
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
JSON_QUOTES_URL = "https://www.adafruit.com/api/quotes.php"
JSON_STARS_URL = "https://api.github.com/repos/adafruit/circuitpython"
# Get wifi details and more from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
print("ESP32-S2 WebClient Test")
print("My MAC addr:", [hex(i) for i in wifi.radio.mac_address])
print("Available WiFi networks:")
for network in wifi.radio.start_scanning_networks():
print("\t%s\t\tRSSI: %d\tChannel: %d" % (str(network.ssid, "utf-8"),
network.rssi, network.channel))
wifi.radio.stop_scanning_networks()
print("Connecting to %s"%secrets["ssid"])
wifi.radio.connect(secrets["ssid"], secrets["password"])
print("Connected to %s!"%secrets["ssid"])
print("My IP address is", wifi.radio.ipv4_address)
ipv4 = ipaddress.ip_address("8.8.4.4")
print("Ping google.com: %f ms" % (wifi.radio.ping(ipv4)*1000))
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())
print("Fetching text from", TEXT_URL)
response = requests.get(TEXT_URL)
print("-" * 40)
print(response.text)
print("-" * 40)
print("Fetching json from", JSON_QUOTES_URL)
response = requests.get(JSON_QUOTES_URL)
print("-" * 40)
print(response.json())
print("-" * 40)
print()
print("Fetching and parsing json from", JSON_STARS_URL)
response = requests.get(JSON_STARS_URL)
print("-" * 40)
print("CircuitPython GitHub Stars", response.json()["stargazers_count"])
print("-" * 40)
print("done")
Behavior
Intermittent failure to connect to wifi AP. Behavior began after connecting to a second network and then trying to connect to the first network again. Confirmed "secrets.py" is correct as Wifi sometimes connects. Connection attempt seems to take 2-3 times longer than standard when the error occurs and then the error below appears in the REPL.
Traceback (most recent call last):
File "code.py", line 30, in <module>
ConnectionError: Unknown Failure 205
Additional Info
Not sure whether resetting my router fixed the issue temporarily or it cleared up on its own briefly. Error occurs when using the simpletest above and when using
magtag.network.get_local_time()
Tgeo and ehershey