Added reconnect to ThingsBoard Mqtt
This commit is contained in:
@@ -25,6 +25,8 @@ class Mqtt2ThingBoard:
|
||||
|
||||
#Sent message to MQTT ThingsBoard Gateway
|
||||
def publishTelemetryMsg(self,msg):
|
||||
if self.tb_client.is_connected == False:
|
||||
self.tb_client.connect(self.host_name,self.tb_port)
|
||||
self.tb_client.publish("v1/gateway/telemetry",msg,0,True)
|
||||
|
||||
|
||||
@@ -58,10 +60,7 @@ class Mqtt2ThingBoard:
|
||||
#set up the system: login to MQTT + get all needed data from the BSH
|
||||
def __init__(self):
|
||||
self.publishDebugMsg("Connecting to MQTT Server")
|
||||
ret1 = self.mqtt_client.connect(self.host_name,self.host_port)
|
||||
|
||||
self.publishDebugMsg("Connecting to ThingsBoard Mqtt Gateway")
|
||||
ret2 = self.tb_client.connect(self.host_name,self.tb_port)
|
||||
self.mqtt_client.connect(self.host_name,self.host_port)
|
||||
|
||||
self.publishDebugMsg("Setting up the Environment...")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user