99from paho .mqtt import client as mqtt
1010from paho .mqtt .client import Client
1111from paho .mqtt .enums import CallbackAPIVersion
12- from paho .mqtt .packettypes import PacketTypes
1312from paho .mqtt .properties import Properties
1413from paho .mqtt .reasoncodes import ReasonCode
1514
1615from isar .config .settings import settings
17- from robot_interface .telemetry .mqtt_client import MqttClientInterface , MQTTQueueMessage
18-
19-
20- def props_expiry (seconds : int ) -> Properties :
21- p = Properties (PacketTypes .PUBLISH )
22- p .MessageExpiryInterval = seconds
23- return p
16+ from robot_interface .telemetry .mqtt_client import MQTTQueueMessage
2417
2518
2619def _on_success (data : Details ) -> None :
@@ -43,7 +36,7 @@ def _on_giveup(data: Details) -> None:
4336 )
4437
4538
46- class MqttClient ( MqttClientInterface ) :
39+ class MqttClient :
4740 def __init__ (self , mqtt_queue : Queue [MQTTQueueMessage ]) -> None :
4841 self .logger = logging .getLogger ("mqtt_client" )
4942 self .logger .setLevel ("INFO" )
@@ -97,7 +90,8 @@ def run(self) -> None:
9790 except Empty :
9891 continue
9992
100- self .publish (
93+ self .logger .debug ("Publishing message to topic: %s" , item .topic )
94+ self .client .publish (
10195 topic = item .topic ,
10296 payload = item .payload ,
10397 qos = item .qos ,
@@ -137,16 +131,3 @@ def connect(self, host: str, port: int) -> None:
137131 self .logger .info ("Attempting to connect to MQTT Broker" )
138132 self .logger .info ("Host: %s, Port: %s" , host , port )
139133 self .client .connect (host = host , port = port )
140-
141- def publish (
142- self ,
143- topic : str ,
144- payload : str ,
145- qos : int = 0 ,
146- retain : bool = False ,
147- properties : Properties | None = None ,
148- ) -> None :
149- self .logger .debug ("Publishing message to topic: %s" , topic )
150- self .client .publish (
151- topic = topic , payload = payload , qos = qos , retain = retain , properties = properties
152- )
0 commit comments