Code: Select all
import ipaddress
import wifi
import socketpool
import ssl
import adafruit_requests
print()
print("Connecting to WiFi")
# connect to your SSID
wifi.radio.connect(os.getenv('CIRCUITPY_WIFI_SSID'), os.getenv('CIRCUITPY_WIFI_PASSWORD'))
print("Connected to WiFi")
# prints MAC address to REPL
print("My MAC addr:", [hex(i) for i in wifi.radio.mac_address])
# prints IP address to REPL
print("My IP address is", wifi.radio.ipv4_address)
sslContext = ssl.create_default_context()
#sslContext.check_hostname = False
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, sslContext)
response = requests.get("https://192.168.1.165")
print(response.text)
Code: Select all
Connecting to WiFi
Connected to WiFi
My MAC addr: ['0x28', '0xcd', '0xc1', '0x6', '0xc3', '0xbc']
My IP address is 192.168.1.82
Traceback (most recent call last):
File "adafruit_requests.py", line 534, in _get_socket
OSError: (-9984, 'MBEDTLS_ERR_X509_CERT_VERIFY_FAILED')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "code.py", line 32, in <module>
File "adafruit_requests.py", line 728, in get
File "adafruit_requests.py", line 668, in request
File "adafruit_requests.py", line 515, in _get_socket
RuntimeError: Sending request failed
Code done running.