changed connect

Signed-off-by: Ebbe Baß <ebbe.bass>
main
Ebbe Baß 2024-02-13 00:11:47 +01:00
parent 4caaec1fc8
commit a04e6f7753
1 changed files with 3 additions and 3 deletions

View File

@ -98,15 +98,15 @@ def get_eth0_ip():
print(f"Error getting eth0 IP: {e}") print(f"Error getting eth0 IP: {e}")
return None return None
def connect_mqtt(): def connect_mqtt():
def on_connect(client, userdata, flags, rc): def on_connect(client, userdata, flags, rc):
if rc == 0: if rc == 0:
print("Connected to MQTT Broker!") print("Connected to MQTT Broker!")
else: else:
print("Failed to connect to MQTT broker, return code %d\n", rc) print("Failed to connect, return code %d\n", rc)
# Set Connecting Client ID
client = mqtt.Client(mqtt_client_id) client = mqtt.Client(mqtt_client_id)
# client.username_pw_set(username, password)
client.on_connect = on_connect client.on_connect = on_connect
client.connect("localhost", 1883) client.connect("localhost", 1883)
return client return client