@@ -57,7 +57,7 @@ def __init__(self, board, deviceID, port, apiKey, debug=True):
5757
5858 if self .mode == LiveObjects .BoardsInterface .PYTHON :
5959 self .__mqtt = paho .Client (deviceID )
60- else :
60+ elif self . mode == LiveObjects . BoardsInterface . MICROPYTHON :
6161 self .ssl = port == 8883
6262 self .__mqtt = MQTTClient (deviceID , self .__server , self .__port , "json+device" ,
6363 self .__apiKey , 0 , self .ssl , {'server_hostname' : self .__server })
@@ -72,7 +72,7 @@ def __onMessage(self, client="", userdata="", msg=""):
7272 self .__parameterManager (msg )
7373 elif msg .topic == "dev/cmd" :
7474 self .__commandManager (msg )
75- else :
75+ elif self . mode == LiveObjects . BoardsInterface . MICROPYTHON :
7676 if client == b"dev/cfg/upd" :
7777 self .__parameterManager (userdata )
7878 elif client == b"dev/cmd" :
@@ -96,7 +96,7 @@ def __onConnect(self, client="", userdata="", flags="", rc=""):
9696 #else:
9797 #self.outputDebug(ERROR,"Unknown error while connecting,quitting...")
9898 #sys.exit()
99- else :
99+ elif self . mode == LiveObjects . BoardsInterface . MICROPYTHON :
100100 self .outputDebug (INFO , "Connected, sending config" )
101101 if len (self .__commands ) > 0 :
102102 self .outputDebug (INFO , "Subscribing commands" )
@@ -117,7 +117,7 @@ def connect(self):
117117 self .__mqtt .tls_set (filename )
118118 self .__mqtt .connect (self .__server , self .__port , 60 )
119119 self .__mqtt .loop_start ()
120- else :
120+ elif self . mode == LiveObjects . BoardsInterface . MICROPYTHON :
121121 self .__mqtt .set_callback (self .__onMessage )
122122 self .__mqtt .connect ()
123123 time .sleep (1 )
@@ -141,7 +141,7 @@ def __commandManager(self, msg):
141141 if self .mode == LiveObjects .BoardsInterface .PYTHON :
142142 msgDict = json .loads (msg .payload )
143143 self .outputDebug (INFO , "Received message:\n " , json .dumps (msgDict , sort_keys = True , indent = 4 ))
144- else :
144+ elif self . mode == LiveObjects . BoardsInterface . MICROPYTHON :
145145 msgDict = json .loads (msg )
146146 self .outputDebug (INFO , "Received message:" , json .dumps (msgDict ))
147147 outputMsg = {}
@@ -166,10 +166,11 @@ def __parameterManager(self, msg):
166166 self .outputDebug (INFO , "Received message: " )
167167 self .outputDebug (INFO , json .loads (msg .payload ))
168168 params = json .loads (msg .payload )
169- else :
169+ elif self . mode == LiveObjects . BoardsInterface . MICROPYTHON :
170170 self .outputDebug (INFO , "Received message: " )
171171 self .outputDebug (INFO , json .loads (msg ))
172172 params = json .loads (msg )
173+
173174 for param in params ["cfg" ]:
174175 if params ["cfg" ][param ]["t" ] == "i32" :
175176 self .__parameters [param ].type = INT
@@ -245,7 +246,7 @@ def __publishMessage(self, topic, msg):
245246
246247 if self .mode == LiveObjects .BoardsInterface .PYTHON :
247248 self .outputDebug (INFO , "\n " , json .dumps (msg , sort_keys = True , indent = 4 ))
248- else :
249+ elif self . mode == LiveObjects . BoardsInterface . MICROPYTHON :
249250 self .outputDebug (INFO , json .dumps (msg ))
250251
251252 self .__mqtt .publish (topic , json .dumps (msg ))
0 commit comments