Add some comments

This commit is contained in:
DSTO\pivatom
2018-12-18 10:15:04 +10:30
parent 663f6a8c49
commit 50ea321f66

View File

@@ -3,8 +3,13 @@ import paho.mqtt.client as mqtt
client = None
host = None
"""
Wrapper module for paho mqtt library, providing a singleton instance of the client to be used.
"""
# Arguably not needed, just want to make the client static, but here anyway.
def connect():
global client
if client is None or host is None:
print("Error: Client and/or host are not initialised.")
else:
@@ -12,6 +17,7 @@ def connect():
client.loop_start()
def disconnect():
global client
if client is not None:
client.loop_stop()
client.disconnect()
@@ -19,7 +25,8 @@ def disconnect():
print("Error: Client is not initialised.")
def Client():
if client is not None:
return mqtt.Client()
else:
return client
global client
if client is None:
client = mqtt.Client()
return client