diff --git a/src/public_mqtt_sdl_demo/lib/mqtt_as.py b/src/public_mqtt_sdl_demo/lib/mqtt_as.py index 8cc2cc9..2be2cb5 100644 --- a/src/public_mqtt_sdl_demo/lib/mqtt_as.py +++ b/src/public_mqtt_sdl_demo/lib/mqtt_as.py @@ -284,9 +284,9 @@ async def _connect(self, clean): await asyncio.sleep_ms(_DEFAULT_MS) self.dprint("Connecting to broker.") if self._ssl: - import ussl + import ssl - self._sock = ussl.wrap_socket(self._sock, **self._ssl_params) + self._sock = ssl.wrap_socket(self._sock, **self._ssl_params) premsg = bytearray(b"\x10\0\0\0\0\0") msg = bytearray(b"\x04MQTT\x04\0\0\0") # Protocol 3.1.1 diff --git a/src/public_mqtt_sdl_demo/lib/umqtt/simple.py b/src/public_mqtt_sdl_demo/lib/umqtt/simple.py index cf98b81..5d09230 100644 --- a/src/public_mqtt_sdl_demo/lib/umqtt/simple.py +++ b/src/public_mqtt_sdl_demo/lib/umqtt/simple.py @@ -66,9 +66,12 @@ def connect(self, clean_session=True): addr = socket.getaddrinfo(self.server, self.port)[0][-1] self.sock.connect(addr) if self.ssl: - import ussl + # replaced ussl with ssl due to deprecation in MicroPython 1.23.0 + # (not PR'd on source repo, but I'm using mqtt_as in my workflows + # instead, anyway) + import ssl - self.sock = ussl.wrap_socket(self.sock, **self.ssl_params) + self.sock = ssl.wrap_socket(self.sock, **self.ssl_params) premsg = bytearray(b"\x10\0\0\0\0\0") msg = bytearray(b"\x04MQTT\x04\x02\0\0") diff --git a/src/public_mqtt_sdl_demo/main.py b/src/public_mqtt_sdl_demo/main.py index 66e2422..837dde9 100644 --- a/src/public_mqtt_sdl_demo/main.py +++ b/src/public_mqtt_sdl_demo/main.py @@ -3,11 +3,11 @@ import gc import json import os +import ssl from secrets import HIVEMQ_HOST, HIVEMQ_PASSWORD, HIVEMQ_USERNAME, PASSWORD, SSID from time import sleep import ntptime -import ussl from as7341_sensor import Sensor from data_logging import initialize_sdcard, log_to_mongodb from machine import PWM, Pin, reset, unique_id @@ -277,7 +277,7 @@ def callback(topic, msg, retain=None, dup=None): "server_side": False, "key": None, "cert": None, - "cert_reqs": ussl.CERT_REQUIRED, + "cert_reqs": ssl.CERT_REQUIRED, "cadata": cacert, "server_hostname": HIVEMQ_HOST, }, diff --git a/src/public_mqtt_sdl_demo/main_liquid.py b/src/public_mqtt_sdl_demo/main_liquid.py index 246d585..af0f3d5 100644 --- a/src/public_mqtt_sdl_demo/main_liquid.py +++ b/src/public_mqtt_sdl_demo/main_liquid.py @@ -3,11 +3,11 @@ import gc import json import os +import ssl from secrets import HIVEMQ_HOST, HIVEMQ_PASSWORD, HIVEMQ_USERNAME, PASSWORD, SSID from time import sleep import ntptime -import ussl from as7341_sensor import Sensor from data_logging import initialize_sdcard, log_to_mongodb from machine import PWM, Pin, reset, unique_id @@ -345,7 +345,7 @@ def callback(topic, msg, retain=None, dup=None): "server_side": False, "key": None, "cert": None, - "cert_reqs": ussl.CERT_REQUIRED, + "cert_reqs": ssl.CERT_REQUIRED, "cadata": cacert, "server_hostname": HIVEMQ_HOST, }, diff --git a/src/public_mqtt_sdl_demo/scripts/mqtt_basic.py b/src/public_mqtt_sdl_demo/scripts/mqtt_basic.py index 7879ae2..043006e 100644 --- a/src/public_mqtt_sdl_demo/scripts/mqtt_basic.py +++ b/src/public_mqtt_sdl_demo/scripts/mqtt_basic.py @@ -1,4 +1,5 @@ import json +import ssl from secrets import ( DEVICE_NICKNAME, HIVEMQ_HOST, @@ -10,7 +11,6 @@ from time import sleep import ntptime -import ussl from data_logging import get_traceback from netman import connectWiFi from sdl_demo_utils import get_onboard_led, heartbeat, sign_of_life @@ -56,7 +56,7 @@ def callback(topic, msg, retain=None, dup=None): "server_side": False, "key": None, "cert": None, - "cert_reqs": ussl.CERT_REQUIRED, + "cert_reqs": ssl.CERT_REQUIRED, "cadata": cacert, "server_hostname": HIVEMQ_HOST, }, diff --git a/src/public_mqtt_sdl_demo/scripts/mqtt_data_logging_debug.py b/src/public_mqtt_sdl_demo/scripts/mqtt_data_logging_debug.py index 91d9515..d94b98a 100644 --- a/src/public_mqtt_sdl_demo/scripts/mqtt_data_logging_debug.py +++ b/src/public_mqtt_sdl_demo/scripts/mqtt_data_logging_debug.py @@ -1,4 +1,5 @@ import json +import ssl from secrets import ( HIVEMQ_HOST, HIVEMQ_PASSWORD, @@ -13,7 +14,6 @@ from time import sleep import ntptime -import ussl from data_logging import get_traceback, log_to_mongodb from netman import connectWiFi from sdl_demo_utils import get_onboard_led, heartbeat, sign_of_life @@ -89,7 +89,7 @@ def callback(topic, msg, retain=None, dup=None): "server_side": False, "key": None, "cert": None, - "cert_reqs": ussl.CERT_REQUIRED, + "cert_reqs": ssl.CERT_REQUIRED, "cadata": cacert, "server_hostname": HIVEMQ_HOST, },