Fixed broker forwarder
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user