File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change 55adafruit_requests using BytesIO
66"""
77
8- import ssl
98from io import BytesIO
9+ from os import getenv
1010
11+ import adafruit_connection_manager
1112import adafruit_requests as requests
1213import board
1314import displayio
14- import socketpool
1515import wifi
1616
1717import adafruit_imageload
1818
19- # Get wifi details and more from a secrets.py file
20- try :
21- from secrets import secrets
22- except ImportError :
23- print ("WiFi secrets are kept in secrets.py, please add them there!" )
24- raise
19+ # Get WiFi details, ensure these are setup in settings.toml
20+ ssid = getenv ("CIRCUITPY_WIFI_SSID" )
21+ password = getenv ("CIRCUITPY_WIFI_PASSWORD" )
2522
26- wifi .radio .connect (secrets [ " ssid" ], secrets [ " password" ] )
23+ wifi .radio .connect (ssid , password )
2724
2825print ("My IP address is" , wifi .radio .ipv4_address )
2926
30- socket = socketpool .SocketPool (wifi .radio )
31- https = requests .Session (socket , ssl .create_default_context ())
27+ pool = adafruit_connection_manager .get_radio_socketpool (wifi .radio )
28+ ssl_context = adafruit_connection_manager .get_radio_ssl_context (wifi .radio )
29+ https = requests .Session (pool , ssl_context )
3230
3331url = "https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_ImageLoad/main/examples/images/4bit.bmp"
3432
35- print ("Fetching text from %s" % url )
33+ print (f "Fetching text from { url } " )
3634response = https .get (url )
3735print ("GET complete" )
3836
You can’t perform that action at this time.
0 commit comments