Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
add use broker config to change the main broker link to the platform
Browse files Browse the repository at this point in the history
  • Loading branch information
vboxuser authored and vboxuser committed Apr 10, 2024
1 parent 2bcd8fc commit 8395fa8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion panduza_platform/core/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 8395fa8

Please sign in to comment.