diff --git a/examples/adafruit_io_http/adafruit_io_analog_in.py b/examples/adafruit_io_http/adafruit_io_analog_in.py index 7aafb8b..1ed52a3 100644 --- a/examples/adafruit_io_http/adafruit_io_analog_in.py +++ b/examples/adafruit_io_http/adafruit_io_analog_in.py @@ -8,9 +8,10 @@ import busio from analogio import AnalogIn from digitalio import DigitalInOut -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_connection_manager +import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi -import adafruit_requests as requests +import adafruit_requests from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError # Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and @@ -45,8 +46,9 @@ continue print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) -socket.set_interface(esp) -requests.set_socket(socket, esp) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +requests = adafruit_requests.Session(pool, ssl_context) # Set your Adafruit IO Username and Key in secrets.py # (visit io.adafruit.com if you need to create an account, diff --git a/examples/adafruit_io_http/adafruit_io_digital_out.py b/examples/adafruit_io_http/adafruit_io_digital_out.py index c8b1d82..1453688 100644 --- a/examples/adafruit_io_http/adafruit_io_digital_out.py +++ b/examples/adafruit_io_http/adafruit_io_digital_out.py @@ -7,9 +7,10 @@ import board import busio from digitalio import DigitalInOut, Direction -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_connection_manager +import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi -import adafruit_requests as requests +import adafruit_requests from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError # Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and @@ -44,8 +45,9 @@ continue print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) -socket.set_interface(esp) -requests.set_socket(socket, esp) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +requests = adafruit_requests.Session(pool, ssl_context) # Set your Adafruit IO Username and Key in secrets.py # (visit io.adafruit.com if you need to create an account, diff --git a/examples/adafruit_io_http/adafruit_io_feeds.py b/examples/adafruit_io_http/adafruit_io_feeds.py index 160a540..37bdcf9 100644 --- a/examples/adafruit_io_http/adafruit_io_feeds.py +++ b/examples/adafruit_io_http/adafruit_io_feeds.py @@ -7,9 +7,10 @@ import board import busio from digitalio import DigitalInOut -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_connection_manager +import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi -import adafruit_requests as requests +import adafruit_requests from adafruit_io.adafruit_io import IO_HTTP # Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and @@ -44,8 +45,9 @@ continue print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) -socket.set_interface(esp) -requests.set_socket(socket, esp) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +requests = adafruit_requests.Session(pool, ssl_context) # Set your Adafruit IO Username and Key in secrets.py # (visit io.adafruit.com if you need to create an account, diff --git a/examples/adafruit_io_http/adafruit_io_groups.py b/examples/adafruit_io_http/adafruit_io_groups.py index daefd1e..6e31580 100644 --- a/examples/adafruit_io_http/adafruit_io_groups.py +++ b/examples/adafruit_io_http/adafruit_io_groups.py @@ -7,9 +7,10 @@ import board import busio from digitalio import DigitalInOut -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_connection_manager +import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi -import adafruit_requests as requests +import adafruit_requests from adafruit_io.adafruit_io import IO_HTTP @@ -45,8 +46,9 @@ continue print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) -socket.set_interface(esp) -requests.set_socket(socket, esp) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +requests = adafruit_requests.Session(pool, ssl_context) # Set your Adafruit IO Username and Key in secrets.py # (visit io.adafruit.com if you need to create an account, diff --git a/examples/adafruit_io_http/adafruit_io_metadata.py b/examples/adafruit_io_http/adafruit_io_metadata.py index 7bfb933..5d913b3 100644 --- a/examples/adafruit_io_http/adafruit_io_metadata.py +++ b/examples/adafruit_io_http/adafruit_io_metadata.py @@ -6,9 +6,10 @@ import board import busio from digitalio import DigitalInOut -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_connection_manager +import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi -import adafruit_requests as requests +import adafruit_requests from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError # Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and @@ -43,8 +44,9 @@ continue print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) -socket.set_interface(esp) -requests.set_socket(socket, esp) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +requests = adafruit_requests.Session(pool, ssl_context) # Set your Adafruit IO Username and Key in secrets.py # (visit io.adafruit.com if you need to create an account, diff --git a/examples/adafruit_io_http/adafruit_io_randomizer.py b/examples/adafruit_io_http/adafruit_io_randomizer.py index d68f2e5..b838d20 100644 --- a/examples/adafruit_io_http/adafruit_io_randomizer.py +++ b/examples/adafruit_io_http/adafruit_io_randomizer.py @@ -7,9 +7,10 @@ import board import busio from digitalio import DigitalInOut -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_connection_manager +import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi -import adafruit_requests as requests +import adafruit_requests from adafruit_io.adafruit_io import IO_HTTP # Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and @@ -44,8 +45,9 @@ continue print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) -socket.set_interface(esp) -requests.set_socket(socket, esp) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +requests = adafruit_requests.Session(pool, ssl_context) # Set your Adafruit IO Username and Key in secrets.py # (visit io.adafruit.com if you need to create an account, diff --git a/examples/adafruit_io_http/adafruit_io_simpletest_esp32spi.py b/examples/adafruit_io_http/adafruit_io_simpletest_esp32spi.py index fb80f1a..656b67d 100644 --- a/examples/adafruit_io_http/adafruit_io_simpletest_esp32spi.py +++ b/examples/adafruit_io_http/adafruit_io_simpletest_esp32spi.py @@ -6,9 +6,10 @@ import board import busio from digitalio import DigitalInOut -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_connection_manager +import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi -import adafruit_requests as requests +import adafruit_requests from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError # Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and @@ -43,8 +44,9 @@ continue print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) -socket.set_interface(esp) -requests.set_socket(socket, esp) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +requests = adafruit_requests.Session(pool, ssl_context) # Set your Adafruit IO Username and Key in secrets.py # (visit io.adafruit.com if you need to create an account, diff --git a/examples/adafruit_io_http/adafruit_io_temperature.py b/examples/adafruit_io_http/adafruit_io_temperature.py index b779a50..9ed8893 100644 --- a/examples/adafruit_io_http/adafruit_io_temperature.py +++ b/examples/adafruit_io_http/adafruit_io_temperature.py @@ -7,9 +7,10 @@ import board import busio from digitalio import DigitalInOut -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_connection_manager +import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi -import adafruit_requests as requests +import adafruit_requests import adafruit_adt7410 from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError @@ -45,8 +46,9 @@ continue print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) -socket.set_interface(esp) -requests.set_socket(socket, esp) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +requests = adafruit_requests.Session(pool, ssl_context) # Set your Adafruit IO Username and Key in secrets.py # (visit io.adafruit.com if you need to create an account, diff --git a/examples/adafruit_io_http/adafruit_io_weather.py b/examples/adafruit_io_http/adafruit_io_weather.py index e65c654..aad86da 100644 --- a/examples/adafruit_io_http/adafruit_io_weather.py +++ b/examples/adafruit_io_http/adafruit_io_weather.py @@ -6,9 +6,10 @@ import board import busio from digitalio import DigitalInOut -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_connection_manager +import adafruit_esp32spi.adafruit_esp32spi_socket as pool from adafruit_esp32spi import adafruit_esp32spi -import adafruit_requests as requests +import adafruit_requests from adafruit_io.adafruit_io import IO_HTTP # Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and @@ -43,8 +44,9 @@ continue print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi) -socket.set_interface(esp) -requests.set_socket(socket, esp) +# Initialize a requests session +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) +requests = adafruit_requests.Session(pool, ssl_context) # Set your Adafruit IO Username and Key in secrets.py # (visit io.adafruit.com if you need to create an account, diff --git a/examples/adafruit_io_mqtt/adafruit_io_feed_callback.py b/examples/adafruit_io_mqtt/adafruit_io_feed_callback.py index 2f083dc..aa9a1d2 100644 --- a/examples/adafruit_io_mqtt/adafruit_io_feed_callback.py +++ b/examples/adafruit_io_mqtt/adafruit_io_feed_callback.py @@ -6,9 +6,10 @@ import board import busio from digitalio import DigitalInOut +import adafruit_connection_manager from adafruit_esp32spi import adafruit_esp32spi from adafruit_esp32spi import adafruit_esp32spi_wifimanager -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_esp32spi.adafruit_esp32spi_socket as pool import neopixel import adafruit_minimqtt.adafruit_minimqtt as MQTT from adafruit_io.adafruit_io import IO_MQTT @@ -94,8 +95,7 @@ def on_battery_msg(client, topic, message): wifi.connect() print("Connected!") -# Initialize MQTT interface with the esp interface -MQTT.set_socket(socket, esp) +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) # Initialize a new MQTT Client object mqtt_client = MQTT.MQTT( @@ -103,6 +103,8 @@ def on_battery_msg(client, topic, message): port=1883, username=secrets["aio_username"], password=secrets["aio_key"], + socket_pool=pool, + ssl_context=ssl_context, ) # Initialize an Adafruit IO MQTT Client diff --git a/examples/adafruit_io_mqtt/adafruit_io_groups.py b/examples/adafruit_io_mqtt/adafruit_io_groups.py index 753c263..5b912c6 100755 --- a/examples/adafruit_io_mqtt/adafruit_io_groups.py +++ b/examples/adafruit_io_mqtt/adafruit_io_groups.py @@ -9,9 +9,10 @@ import board import busio from digitalio import DigitalInOut +import adafruit_connection_manager from adafruit_esp32spi import adafruit_esp32spi from adafruit_esp32spi import adafruit_esp32spi_wifimanager -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_esp32spi.adafruit_esp32spi_socket as pool import neopixel import adafruit_minimqtt.adafruit_minimqtt as MQTT from adafruit_io.adafruit_io import IO_MQTT @@ -85,8 +86,7 @@ def message(client, feed_id, payload): wifi.connect() print("Connected!") -# Initialize MQTT interface with the esp interface -MQTT.set_socket(socket, esp) +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) # Initialize a new MQTT Client object mqtt_client = MQTT.MQTT( @@ -94,6 +94,8 @@ def message(client, feed_id, payload): port=1883, username=secrets["aio_username"], password=secrets["aio_key"], + socket_pool=pool, + ssl_context=ssl_context, ) # Initialize an Adafruit IO MQTT Client diff --git a/examples/adafruit_io_mqtt/adafruit_io_location.py b/examples/adafruit_io_mqtt/adafruit_io_location.py index 09c9291..20aef53 100755 --- a/examples/adafruit_io_mqtt/adafruit_io_location.py +++ b/examples/adafruit_io_mqtt/adafruit_io_location.py @@ -7,9 +7,10 @@ import board import busio from digitalio import DigitalInOut +import adafruit_connection_manager from adafruit_esp32spi import adafruit_esp32spi from adafruit_esp32spi import adafruit_esp32spi_wifimanager -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_esp32spi.adafruit_esp32spi_socket as pool import neopixel @@ -85,8 +86,7 @@ def message(client, feed_id, payload): wifi.connect() print("Connected!") -# Initialize MQTT interface with the esp interface -MQTT.set_socket(socket, esp) +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) # Initialize a new MQTT Client object mqtt_client = MQTT.MQTT( @@ -94,6 +94,8 @@ def message(client, feed_id, payload): port=1883, username=secrets["aio_username"], password=secrets["aio_key"], + socket_pool=pool, + ssl_context=ssl_context, ) # Initialize an Adafruit IO MQTT Client diff --git a/examples/adafruit_io_mqtt/adafruit_io_pubsub_rp2040.py b/examples/adafruit_io_mqtt/adafruit_io_pubsub_rp2040.py index db15278..7742c8f 100644 --- a/examples/adafruit_io_mqtt/adafruit_io_pubsub_rp2040.py +++ b/examples/adafruit_io_mqtt/adafruit_io_pubsub_rp2040.py @@ -6,9 +6,10 @@ import board import busio from digitalio import DigitalInOut +import adafruit_connection_manager from adafruit_esp32spi import adafruit_esp32spi from adafruit_esp32spi import adafruit_esp32spi_wifimanager -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_esp32spi.adafruit_esp32spi_socket as pool import adafruit_minimqtt.adafruit_minimqtt as MQTT from adafruit_io.adafruit_io import IO_MQTT @@ -70,8 +71,7 @@ def on_led_msg(client, topic, message): wifi.connect() print("Connected!") -# Initialize MQTT interface with the esp interface -MQTT.set_socket(socket, esp) +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) # Initialize a new MQTT Client object mqtt_client = MQTT.MQTT( @@ -79,6 +79,8 @@ def on_led_msg(client, topic, message): port=1883, username=secrets["aio_username"], password=secrets["aio_key"], + socket_pool=pool, + ssl_context=ssl_context, ) # Initialize an Adafruit IO MQTT Client diff --git a/examples/adafruit_io_mqtt/adafruit_io_simpletest_cellular.py b/examples/adafruit_io_mqtt/adafruit_io_simpletest_cellular.py index 1514e37..bfe565b 100644 --- a/examples/adafruit_io_mqtt/adafruit_io_simpletest_cellular.py +++ b/examples/adafruit_io_mqtt/adafruit_io_simpletest_cellular.py @@ -12,9 +12,10 @@ import busio import digitalio +import adafruit_connection_manager from adafruit_fona.adafruit_fona import FONA from adafruit_fona.adafruit_fona_gsm import GSM -import adafruit_fona.adafruit_fona_socket as cellular_socket +import adafruit_fona.adafruit_fona_socket as pool import adafruit_minimqtt.adafruit_minimqtt as MQTT from adafruit_io.adafruit_io import IO_MQTT @@ -82,8 +83,7 @@ def message(client, feed_id, payload): print("Feed {0} received new value: {1}".format(feed_id, payload)) -# Initialize MQTT interface with the ethernet interface -MQTT.set_socket(cellular_socket, fona) +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, fona) # Initialize a new MQTT Client object mqtt_client = MQTT.MQTT( @@ -91,6 +91,8 @@ def message(client, feed_id, payload): port=1883, username=secrets["aio_username"], password=secrets["aio_key"], + socket_pool=pool, + ssl_context=ssl_context, ) # Initialize an Adafruit IO MQTT Client diff --git a/examples/adafruit_io_mqtt/adafruit_io_simpletest_eth.py b/examples/adafruit_io_mqtt/adafruit_io_simpletest_eth.py index d0dee85..0d6a988 100755 --- a/examples/adafruit_io_mqtt/adafruit_io_simpletest_eth.py +++ b/examples/adafruit_io_mqtt/adafruit_io_simpletest_eth.py @@ -12,8 +12,9 @@ import busio from digitalio import DigitalInOut +import adafruit_connection_manager 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_minimqtt.adafruit_minimqtt as MQTT from adafruit_io.adafruit_io import IO_MQTT @@ -67,8 +68,7 @@ def message(client, feed_id, payload): print("Feed {0} received new value: {1}".format(feed_id, payload)) -# Initialize MQTT interface with the ethernet interface -MQTT.set_socket(socket, eth) +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, eth) # Initialize a new MQTT Client object mqtt_client = MQTT.MQTT( @@ -76,6 +76,8 @@ def message(client, feed_id, payload): port=1883, username=secrets["aio_username"], password=secrets["aio_key"], + socket_pool=pool, + ssl_context=ssl_context, ) # Initialize an Adafruit IO MQTT Client diff --git a/examples/adafruit_io_mqtt/adafruit_io_time.py b/examples/adafruit_io_mqtt/adafruit_io_time.py index 2fe544c..3babf9c 100755 --- a/examples/adafruit_io_mqtt/adafruit_io_time.py +++ b/examples/adafruit_io_mqtt/adafruit_io_time.py @@ -8,9 +8,10 @@ import board import busio from digitalio import DigitalInOut +import adafruit_connection_manager from adafruit_esp32spi import adafruit_esp32spi from adafruit_esp32spi import adafruit_esp32spi_wifimanager -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_esp32spi.adafruit_esp32spi_socket as pool import neopixel import adafruit_minimqtt.adafruit_minimqtt as MQTT @@ -99,8 +100,7 @@ def message(client, feed_id, payload): wifi.connect() print("Connected!") -# Initialize MQTT interface with the esp interface -MQTT.set_socket(socket, esp) +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) # Initialize a new MQTT Client object mqtt_client = MQTT.MQTT( @@ -108,6 +108,8 @@ def message(client, feed_id, payload): port=1883, username=secrets["aio_username"], password=secrets["aio_key"], + socket_pool=pool, + ssl_context=ssl_context, ) # Initialize an Adafruit IO MQTT Client diff --git a/examples/adafruit_io_simpletest.py b/examples/adafruit_io_simpletest.py index 206cb0d..2733305 100755 --- a/examples/adafruit_io_simpletest.py +++ b/examples/adafruit_io_simpletest.py @@ -12,9 +12,10 @@ import board import busio from digitalio import DigitalInOut +import adafruit_connection_manager from adafruit_esp32spi import adafruit_esp32spi from adafruit_esp32spi import adafruit_esp32spi_wifimanager -import adafruit_esp32spi.adafruit_esp32spi_socket as socket +import adafruit_esp32spi.adafruit_esp32spi_socket as pool import neopixel import adafruit_minimqtt.adafruit_minimqtt as MQTT from adafruit_io.adafruit_io import IO_MQTT @@ -97,8 +98,7 @@ def message(client, feed_id, payload): wifi.connect() print("Connected!") -# Initialize MQTT interface with the esp interface -MQTT.set_socket(socket, esp) +ssl_context = adafruit_connection_manager.create_fake_ssl_context(pool, esp) # Initialize a new MQTT Client object mqtt_client = MQTT.MQTT( @@ -106,6 +106,8 @@ def message(client, feed_id, payload): port=1883, username=secrets["aio_username"], password=secrets["aio_key"], + socket_pool=pool, + ssl_context=ssl_context, )