MCPcopy Create free account
hub / github.com/Mrinank-Bhowmick/python-beginner-projects / connectMqtt

Function connectMqtt

projects/MQTT Client/MqttClient.py:17–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15
16# Create a client to interact with MQTT
17def connectMqtt() -> mqtt_client:
18 def on_connect(client, userdata, flags, rc):
19 if rc == 0:
20 print("[MQTT] Connected to server.")
21 else:
22 print("[MQTT] Failure to connect.")
23
24 client = mqtt_client.Client(CLIENT_ID)
25 client.username_pw_set(USER, PASS)
26 client.on_connect = on_connect
27 client.connect(BROKER, PORT)
28
29 return client
30
31
32# Receiving messages sendings with MQTT

Callers 1

MqttClient.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected