Fix MQTT connection

This commit is contained in:
2025-12-29 15:10:27 +01:00
parent dd57019c99
commit 0a6081ee6e
4 changed files with 28 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
import os
import uuid
from flask import Flask
@@ -8,21 +9,27 @@ client_id = "1"
app = Flask(__name__)
local_broker_address = os.environ.get("LOCAL_BROKER_ADDRESS", "127.0.0.1")
local_broker_port = int(os.environ.get("LOCAL_BROKER_PORT", 1883))
api_broker_address = os.environ.get("API_BROKER_ADDRESS", "127.0.0.1")
api_broker_port = int(os.environ.get("API_BROKER_PORT", 1883))
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
local_broker = MQTTService(
"127.0.0.1",
1883,
local_broker_address,
local_broker_port,
username="pi-1",
password="hepl",
)
api_broker = MQTTService(
"192.168.15.120",
1883,
api_broker_address,
api_broker_port,
username="rpi",
password="hepl",
)