diff --git a/.github/workflows/client-test.yml b/.github/workflows/client-test.yml index 18118c4..f91a95d 100644 --- a/.github/workflows/client-test.yml +++ b/.github/workflows/client-test.yml @@ -5,7 +5,7 @@ on: branches: - 'main' paths: - - '*.py' + - '**.py' - '.github/workflows/*.yml' - '.github/workflows/*.json' - '!**/README.md' @@ -19,7 +19,7 @@ on: branches: - 'main' paths: - - '*.py' + - '**.py' - '.github/workflows/*.yml' - '.github/workflows/*.json' - '!**/README.md' diff --git a/src/arduino_iot_cloud/ucloud.py b/src/arduino_iot_cloud/ucloud.py index 2ff31cc..2208a57 100644 --- a/src/arduino_iot_cloud/ucloud.py +++ b/src/arduino_iot_cloud/ucloud.py @@ -7,10 +7,10 @@ import time import sys import logging +import cbor2 from senml import SenmlPack from senml import SenmlRecord from arduino_iot_cloud.umqtt import MQTTClient - import asyncio from asyncio import CancelledError try: @@ -19,6 +19,10 @@ # MicroPython doesn't have this exception class InvalidStateError(Exception): pass +try: + from arduino_iot_cloud._version import __version__ +except (ImportError, AttributeError): + __version__ = "1.3.0" # Server/port for basic auth. _DEFAULT_SERVER = "iot.arduino.cc" @@ -213,6 +217,7 @@ def __init__( password = bytes(password, "utf-8") self.device_topic = b"/a/d/" + device_id + b"/e/i" + self.command_topic = b"/a/d/" + device_id + b"/c/up" # Update RTC from NTP server on MicroPython. self.update_systime() @@ -355,6 +360,10 @@ def poll_discovery(self, aiot=None): lastval_record.add_to_pack(self.senmlpack) self.mqtt.subscribe(self.create_topic("shadow", "i"), qos=1) self.mqtt.publish(self.create_topic("shadow", "o"), self.senmlpack.to_cbor(), qos=1) + + # Push library version and mode. + libv = "%s-%s" % (__version__, "async" if self.async_mode else "sync") + self.mqtt.publish(self.command_topic, cbor2.dumps(cbor2.CBORTag(67328, [libv])), qos=1) logging.info("Device configured via discovery protocol.") if self.async_mode: raise DoneException() diff --git a/tests/ci.py b/tests/ci.py index 9bf3288..41353e3 100644 --- a/tests/ci.py +++ b/tests/ci.py @@ -74,6 +74,7 @@ def on_value_changed(client, value): device_id=os.getenv("DEVICE_ID"), ssl_params={ "pin": "1234", + "use_hsm": True, "keyfile": "pkcs11:token=arduino", "certfile": "pkcs11:token=arduino", "ca_certs": "ca-root.pem",