Skip to content

Commit

Permalink
Merge pull request #25 from justmobilize/update-legacy-set-socket-exa…
Browse files Browse the repository at this point in the history
…mples

Update legacy set_socket examples
  • Loading branch information
dhalbert authored Mar 1, 2024
2 parents c343347 + 2de1fa6 commit 052b539
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions examples/aws_iot_shadows.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import busio
from digitalio import DigitalInOut
import neopixel
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_aws_iot import MQTT_CLIENT

Expand Down Expand Up @@ -134,11 +135,15 @@ def message(client, topic, msg):
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)

# Set up a new MiniMQTT Client
client = MQTT.MQTT(broker=secrets["broker"], client_id=secrets["client_id"])
client = MQTT.MQTT(
broker=secrets["broker"],
client_id=secrets["client_id"],
socket_pool=pool,
ssl_context=ssl_context,
)

# Initialize AWS IoT MQTT API Client
aws_iot = MQTT_CLIENT(client)
Expand Down
13 changes: 9 additions & 4 deletions examples/aws_iot_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import busio
from digitalio import DigitalInOut
import neopixel
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_aws_iot import MQTT_CLIENT

Expand Down Expand Up @@ -131,11 +132,15 @@ def message(client, topic, msg):
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)

# Set up a new MiniMQTT Client
client = MQTT.MQTT(broker=secrets["broker"], client_id=secrets["client_id"])
client = MQTT.MQTT(
broker=secrets["broker"],
client_id=secrets["client_id"],
socket_pool=pool,
ssl_context=ssl_context,
)

# Initialize AWS IoT MQTT API Client
aws_iot = MQTT_CLIENT(client)
Expand Down

0 comments on commit 052b539

Please sign in to comment.