diff --git a/panduza_platform/core/platform.py b/panduza_platform/core/platform.py index 2704375..d50aa72 100644 --- a/panduza_platform/core/platform.py +++ b/panduza_platform/core/platform.py @@ -140,6 +140,18 @@ async def local_service_discovery(self): # --- + def load_broker_info(self): + """Go look address and port of the broker in network.json + """ + network_conf = open("/etc/panduza/network.json") + json_network_conf = json.load(network_conf) + + + network_conf.close() + return json_network_conf["brokers"]["broker_address"], json_network_conf["brokers"]["broker_port"] + + # --- + async def mount_client(self, name, host_addr, host_port): """Mount a mqtt client """ @@ -297,8 +309,12 @@ async def __idle_task(self): # Connect the local discovery server await self.local_service_discovery() + # Get broker info + broker_address, broker_port = self.load_broker_info() + # Connect to primary broker - await self.mount_client("primary", "localhost", 1883) + # await self.mount_client("primary", "localhost", 1883) + await self.mount_client("primary", broker_address, int(broker_port)) # Mount the device interfaces of the server await self.mount_device("primary", "server",