parent
594509ef11
commit
afc69167b1
|
@ -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 on_connect(client, rc, flags):
|
def on_connect(client, userdata, flags, reason_code, properties):
|
||||||
if rc == 0:
|
if reason_code == 0:
|
||||||
print("Connected to MQTT Broker!")
|
print("Connected to MQTT Broker!")
|
||||||
else:
|
else:
|
||||||
print("Failed to connect, return code %d\n", rc)
|
print("Failed to connect, return code %d\n", str(reason_code))
|
||||||
|
|
||||||
def connect_mqtt():
|
def connect_mqtt():
|
||||||
# Set Connecting Client ID
|
# Set Connecting Client ID
|
||||||
client = mqtt.Client("mqtt_client_id")
|
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)
|
||||||
# client.username_pw_set(username, password)
|
# client.username_pw_set(username, password)
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
client.connect("localhost", 1883)
|
client.connect("localhost", 1883)
|
||||||
|
|
Loading…
Reference in New Issue