This commit is contained in:
Robert Borzutzki 2022-10-18 23:02:28 +02:00
parent 514679a801
commit db57939ad4

View File

@ -19,16 +19,14 @@ logging.basicConfig(level=logging.DEBUG)
Connected = False
def on_connect(client, userdata, flags, rc):
if rc == 0:
print("Connected to MQTT Broker!")
def connect_mqtt() -> mqtt_client:
def on_connect(client, userdata, flags, rc):
if rc == 0:
print("Connected to MQTT Broker!")
global Connected #Use global variable
Connected = True #Signal connection
else:
print("Failed to connect, return code %d\n", rc)
global Connected #Use global variable
Connected = True #Signal connection
else:
print("Failed to connect, return code %d\n", rc)
def on_message(client, userdata, msg):
print(f"Received `{msg.payload.decode()}` from `{msg.topic}` topic")