Closed officiallymarky closed 3 years ago
There needs to be code to include the kind of interface you are using, since there's no OS providing a connection and sockets. In this case, the native networking modules of the ESP32-S2 are needed. There are helper libraries for the MagTag, see: https://learn.adafruit.com/adafruit-magtag/circuitpython-libraries-2 Or, at a low level, use something more like:
import wifi
import socketpool
import ssl
import adafruit_requests
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())
response = requests.get(URL)
Check out the Adafruit Learn Guides and examples for MagTag.
Closing.
You can't use it with magtag.network.connect()?
As I mentioned above, you can use the higher-level helper libraries, like MagTag and PortalBase. I'd suggest looking at some of the MagTag Learn Guides, or go on Discord to ask support questions.
I am trying to do a very basic import requests and query a url and I'm getting an error:
File "adafruit_requests.py", line 692
AttributeError: 'NoneType' object has no attribute 'request'
My code is super simple.
I am using this on a MagTag with the latest stable UF2 loader, and latest adafruit_request.mpy I can find.