Add telemetry database insertion
This commit is contained in:
@@ -41,19 +41,18 @@ class MQTTService:
|
||||
self._connected = False
|
||||
|
||||
def connect(self):
|
||||
if self._connected: return
|
||||
|
||||
print(f"Connecting to {self.address}...")
|
||||
self.client.connect(self.address, self.port)
|
||||
self.client.loop_start()
|
||||
timeout = 5
|
||||
start = time.time()
|
||||
while not self._connected and time.time() - start < timeout:
|
||||
time.sleep(0.1)
|
||||
if not self._connected:
|
||||
print(f"Connecting to {self.address}...")
|
||||
self.client.connect(self.address, self.port)
|
||||
self.client.loop_start()
|
||||
timeout = 5
|
||||
start = time.time()
|
||||
while not self._connected and time.time() - start < timeout:
|
||||
time.sleep(0.1)
|
||||
if not self._connected:
|
||||
raise ConnectionError(f"Cannot connect to MQTT broker at {self.address}:{self.port}")
|
||||
print(f"Successfully connected to {self.address}")
|
||||
else :
|
||||
print(f"Already connected to {self.address}...")
|
||||
raise ConnectionError(f"Cannot connect to MQTT broker at {self.address}:{self.port}")
|
||||
print(f"Successfully connected to {self.address}")
|
||||
|
||||
def disconnect(self):
|
||||
if self._connected:
|
||||
|
||||
Reference in New Issue
Block a user