Skip to content

Commit

Permalink
Merge pull request #244 from sparks-baird/rmse
Browse files Browse the repository at this point in the history
ussl to ssl
  • Loading branch information
sgbaird authored Jun 5, 2024
2 parents 38062db + b23ec18 commit a90126f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/public_mqtt_sdl_demo/lib/mqtt_as.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions src/public_mqtt_sdl_demo/lib/umqtt/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions src/public_mqtt_sdl_demo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions src/public_mqtt_sdl_demo/main_liquid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions src/public_mqtt_sdl_demo/scripts/mqtt_basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import ssl
from secrets import (
DEVICE_NICKNAME,
HIVEMQ_HOST,
Expand All @@ -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
Expand Down Expand Up @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions src/public_mqtt_sdl_demo/scripts/mqtt_data_logging_debug.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import ssl
from secrets import (
HIVEMQ_HOST,
HIVEMQ_PASSWORD,
Expand All @@ -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
Expand Down Expand Up @@ -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,
},
Expand Down

0 comments on commit a90126f

Please sign in to comment.