@@ -110,16 +110,24 @@ def run(self):
110
110
if self .cloudClient .mqttClient .connected == False :
111
111
info ('WriterThread mqttClient not connected' )
112
112
continue
113
+ got_packet = False
113
114
topic , message = self .cloudClient .DequeuePacket ()
114
- if message :
115
- # debug('WriterThread, topic: {} {}'.format(topic, message))
116
- if not isinstance (message , str ):
117
- message = dumps (message )
118
- self .cloudClient .mqttClient .publish_packet (topic , message )
119
- message = None
120
- self .cloudClient .writeQueue .task_done ()
115
+ if topic or message :
116
+ got_packet = True
117
+ try :
118
+ if message :
119
+ # debug('WriterThread, topic: {} {}'.format(topic, message))
120
+ if not isinstance (message , str ):
121
+ message = dumps (message )
122
+ self .cloudClient .mqttClient .publish_packet (topic , message )
123
+ message = None
124
+ except :
125
+ exception ("WriterThread publish packet error" )
126
+ finally :
127
+ if got_packet :
128
+ self .cloudClient .writeQueue .task_done ()
121
129
except :
122
- exception ("WriterThread Unexpected error" )
130
+ exception ("WriterThread unexpected error" )
123
131
return
124
132
125
133
def stop (self ):
@@ -405,6 +413,7 @@ def ProcessPowerCommand(self, message):
405
413
cayennemqtt .DataChannel .add (data , message ['channel' ], value = 1 )
406
414
self .EnqueuePacket (data )
407
415
self .writeQueue .join ()
416
+ info ('Calling execute: {}' .format (commands [message ['channel' ]]))
408
417
output , result = executeCommand (commands [message ['channel' ]])
409
418
debug ('ProcessPowerCommand: {}, result: {}, output: {}' .format (message , result , output ))
410
419
if result != 0 :
0 commit comments