From db57939ad4dfde365298119bf5055db3fbaf4000 Mon Sep 17 00:00:00 2001 From: Robert Borzutzki Date: Tue, 18 Oct 2022 23:02:28 +0200 Subject: [PATCH] u --- examples/mqtt.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/mqtt.py b/examples/mqtt.py index 5003461..cfb703a 100644 --- a/examples/mqtt.py +++ b/examples/mqtt.py @@ -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")