File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 7
7
import time
8
8
import sys
9
9
import logging
10
+ import cbor2
10
11
from senml import SenmlPack
11
12
from senml import SenmlRecord
12
13
from arduino_iot_cloud .umqtt import MQTTClient
13
-
14
14
import asyncio
15
15
from asyncio import CancelledError
16
16
try :
19
19
# MicroPython doesn't have this exception
20
20
class InvalidStateError (Exception ):
21
21
pass
22
+ try :
23
+ from arduino_iot_cloud ._version import __version__
24
+ except (ImportError , AttributeError ):
25
+ __version__ = "1.3.0"
22
26
23
27
# Server/port for basic auth.
24
28
_DEFAULT_SERVER = "iot.arduino.cc"
@@ -355,6 +359,11 @@ def poll_discovery(self, aiot=None):
355
359
lastval_record .add_to_pack (self .senmlpack )
356
360
self .mqtt .subscribe (self .create_topic ("shadow" , "i" ), qos = 1 )
357
361
self .mqtt .publish (self .create_topic ("shadow" , "o" ), self .senmlpack .to_cbor (), qos = 1 )
362
+
363
+ # Push library version and mode.
364
+ libv = "%s-%s" % (__version__ , "async" if self .async_mode else "sync" )
365
+ command_topic = b"/a/d/" + device_id + b"/c/up"
366
+ self .mqtt .publish (command_topic , cbor2 .dumps (cbor2 .CBORTag (67328 , [libv ])), qos = 1 )
358
367
logging .info ("Device configured via discovery protocol." )
359
368
if self .async_mode :
360
369
raise DoneException ()
You can’t perform that action at this time.
0 commit comments