diff --git a/README.rst b/README.rst index 1589d73..881adeb 100644 --- a/README.rst +++ b/README.rst @@ -64,9 +64,10 @@ wifitest.adafruit.com. import board import busio import digitalio - import adafruit_requests as requests + import adafruit_connection_manager + import adafruit_requests from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K - import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket + import adafruit_wiznet5k.adafruit_wiznet5k_socket as pool print("Wiznet5k WebClient Test") @@ -79,8 +80,9 @@ wifitest.adafruit.com. # Initialize ethernet interface with DHCP eth = WIZNET5K(spi_bus, cs) - # Initialize a requests object with a socket and ethernet interface - requests.set_socket(socket, eth) + # Initialize a requests session + ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, eth) + requests = adafruit_requests.Session(pool, ssl_context) print("Chip Version:", eth.chip) print("MAC Address:", [hex(i) for i in eth.mac_address]) diff --git a/examples/wiznet5k_aio_post.py b/examples/wiznet5k_aio_post.py index 076efcd..0ed0ccf 100644 --- a/examples/wiznet5k_aio_post.py +++ b/examples/wiznet5k_aio_post.py @@ -5,9 +5,10 @@ import board import busio from digitalio import DigitalInOut -import adafruit_requests as requests +import adafruit_connection_manager +import adafruit_requests from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K -import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket +import adafruit_wiznet5k.adafruit_wiznet5k_socket as pool # Get Adafruit.io details from a secrets.py file try: @@ -21,7 +22,9 @@ # Initialize ethernet interface with DHCP eth = WIZNET5K(spi_bus, cs) -requests.set_socket(socket, eth) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, eth) +requests = adafruit_requests.Session(pool, ssl_context) counter = 0 diff --git a/examples/wiznet5k_cheerlights.py b/examples/wiznet5k_cheerlights.py index 507fda1..f2b5921 100755 --- a/examples/wiznet5k_cheerlights.py +++ b/examples/wiznet5k_cheerlights.py @@ -6,12 +6,13 @@ import busio from digitalio import DigitalInOut -import adafruit_requests as requests +import adafruit_connection_manager +import adafruit_requests import neopixel import adafruit_fancyled.adafruit_fancyled as fancy from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K -import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket +import adafruit_wiznet5k.adafruit_wiznet5k_socket as pool cs = DigitalInOut(board.D10) spi_bus = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) @@ -19,8 +20,9 @@ # Initialize ethernet interface with DHCP eth = WIZNET5K(spi_bus, cs) -# Initialize a requests object with a socket and ethernet interface -requests.set_socket(socket, eth) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, eth) +requests = adafruit_requests.Session(pool, ssl_context) DATA_SOURCE = "http://api.thingspeak.com/channels/1417/feeds.json?results=1" DATA_LOCATION = ["feeds", 0, "field2"] diff --git a/examples/wiznet5k_simpletest.py b/examples/wiznet5k_simpletest.py index d16b414..38fdc15 100644 --- a/examples/wiznet5k_simpletest.py +++ b/examples/wiznet5k_simpletest.py @@ -4,9 +4,10 @@ import board import busio import digitalio -import adafruit_requests as requests +import adafruit_connection_manager +import adafruit_requests from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K -import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket +import adafruit_wiznet5k.adafruit_wiznet5k_socket as pool print("Wiznet5k WebClient Test") @@ -22,8 +23,9 @@ # Initialize ethernet interface with DHCP eth = WIZNET5K(spi_bus, cs) -# Initialize a requests object with a socket and ethernet interface -requests.set_socket(socket, eth) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, eth) +requests = adafruit_requests.Session(pool, ssl_context) print("Chip Version:", eth.chip) print("MAC Address:", [hex(i) for i in eth.mac_address]) diff --git a/examples/wiznet5k_simpletest_manual_network.py b/examples/wiznet5k_simpletest_manual_network.py index b7c2650..658f7f8 100644 --- a/examples/wiznet5k_simpletest_manual_network.py +++ b/examples/wiznet5k_simpletest_manual_network.py @@ -4,9 +4,10 @@ import board import busio import digitalio -import adafruit_requests as requests +import adafruit_connection_manager +import adafruit_requests from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K -import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket +import adafruit_wiznet5k.adafruit_wiznet5k_socket as pool TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html" @@ -27,8 +28,9 @@ # Set network configuration eth.ifconfig = (IP_ADDRESS, SUBNET_MASK, GATEWAY_ADDRESS, DNS_SERVER) -# Initialize a requests object with a socket and ethernet interface -requests.set_socket(socket, eth) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, eth) +requests = adafruit_requests.Session(pool, ssl_context) print("Chip Version:", eth.chip) print("MAC Address:", [hex(i) for i in eth.mac_address]) diff --git a/examples/wiznet5k_wsgiserver.py b/examples/wiznet5k_wsgiserver.py index 3d1c604..1cab2dd 100644 --- a/examples/wiznet5k_wsgiserver.py +++ b/examples/wiznet5k_wsgiserver.py @@ -21,10 +21,11 @@ import digitalio import neopixel -import adafruit_requests as requests +import adafruit_connection_manager +import adafruit_requests from adafruit_wsgi.wsgi_app import WSGIApp from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K -import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket +import adafruit_wiznet5k.adafruit_wiznet5k_socket as pool import adafruit_wiznet5k.adafruit_wiznet5k_wsgiserver as server @@ -76,8 +77,9 @@ def get_static_file(filename): # Initialize Ethernet interface with DHCP eth = WIZNET5K(spi_bus, cs, mac=mac) -# Initialize a requests object with a socket and ethernet interface -requests.set_socket(socket, eth) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, eth) +requests = adafruit_requests.Session(pool, ssl_context) # Here we create our application, registering the