Skip to content

Commit a8bf94c

Browse files
authoredMay 23, 2024··
Merge pull request #81 from arduino/libv_mode
ucloud: Push client version and mode.
2 parents e380caa + 41c2e11 commit a8bf94c

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
 

‎.github/workflows/client-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches:
66
- 'main'
77
paths:
8-
- '*.py'
8+
- '**.py'
99
- '.github/workflows/*.yml'
1010
- '.github/workflows/*.json'
1111
- '!**/README.md'
@@ -19,7 +19,7 @@ on:
1919
branches:
2020
- 'main'
2121
paths:
22-
- '*.py'
22+
- '**.py'
2323
- '.github/workflows/*.yml'
2424
- '.github/workflows/*.json'
2525
- '!**/README.md'

‎src/arduino_iot_cloud/ucloud.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import time
88
import sys
99
import logging
10+
import cbor2
1011
from senml import SenmlPack
1112
from senml import SenmlRecord
1213
from arduino_iot_cloud.umqtt import MQTTClient
13-
1414
import asyncio
1515
from asyncio import CancelledError
1616
try:
@@ -19,6 +19,10 @@
1919
# MicroPython doesn't have this exception
2020
class InvalidStateError(Exception):
2121
pass
22+
try:
23+
from arduino_iot_cloud._version import __version__
24+
except (ImportError, AttributeError):
25+
__version__ = "1.3.0"
2226

2327
# Server/port for basic auth.
2428
_DEFAULT_SERVER = "iot.arduino.cc"
@@ -213,6 +217,7 @@ def __init__(
213217
password = bytes(password, "utf-8")
214218

215219
self.device_topic = b"/a/d/" + device_id + b"/e/i"
220+
self.command_topic = b"/a/d/" + device_id + b"/c/up"
216221

217222
# Update RTC from NTP server on MicroPython.
218223
self.update_systime()
@@ -355,6 +360,10 @@ def poll_discovery(self, aiot=None):
355360
lastval_record.add_to_pack(self.senmlpack)
356361
self.mqtt.subscribe(self.create_topic("shadow", "i"), qos=1)
357362
self.mqtt.publish(self.create_topic("shadow", "o"), self.senmlpack.to_cbor(), qos=1)
363+
364+
# Push library version and mode.
365+
libv = "%s-%s" % (__version__, "async" if self.async_mode else "sync")
366+
self.mqtt.publish(self.command_topic, cbor2.dumps(cbor2.CBORTag(67328, [libv])), qos=1)
358367
logging.info("Device configured via discovery protocol.")
359368
if self.async_mode:
360369
raise DoneException()

‎tests/ci.py

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def on_value_changed(client, value):
7474
device_id=os.getenv("DEVICE_ID"),
7575
ssl_params={
7676
"pin": "1234",
77+
"use_hsm": True,
7778
"keyfile": "pkcs11:token=arduino",
7879
"certfile": "pkcs11:token=arduino",
7980
"ca_certs": "ca-root.pem",

0 commit comments

Comments
 (0)
Please sign in to comment.