Fixed broker forwarder

This commit is contained in:
2025-12-29 13:03:30 +01:00
parent 239bd1035b
commit 4110e6823b
2 changed files with 8 additions and 4 deletions

View File

@@ -15,11 +15,14 @@ class MQTTForwarder:
self.local_broker = local_mqtt
self.central_broker = central_mqtt
def start(self):
self.local_broker.subscribe("board-mate/", self.__forward)
def start(self, src_topic : str, dst_topic : str) -> None:
def handler(msg:str):
self.__forward(msg, dst_topic)
def __forward(self, msg: str):
self.central_broker.publish(self.client_id, f"/board-mate/${self.client_id}/telemetry", msg)
self.local_broker.subscribe(src_topic, handler)
def __forward(self, msg: str, dst_topic) -> None:
self.central_broker.publish(self.client_id, dst_topic, msg)
"""def start(self):
self.local.subscribe("board-mate/+/telemetry", self.handle_message)