Implementing stuff (I suck at commits sometimes lol)

This commit is contained in:
DSTO\pivatom
2018-12-13 11:00:27 +10:30
parent 750624fe2b
commit 6f0bd56b4a
9 changed files with 146 additions and 19 deletions

25
Messaging/mqttsession.py Normal file
View File

@@ -0,0 +1,25 @@
import paho.mqtt.client as mqtt
client = None
host = None
# Arguably not needed, just want to make the client static, but here anyway.
def connect():
if client is None or host is None:
print("Error: Client and/or host are not initialised.")
else:
client.connect(host, port=1883, keepalive=60, bind_address="")
client.loop_start()
def disconnect():
if client is not None:
client.loop_stop()
client.disconnect()
else:
print("Error: Client is not initialised.")
def Client():
if client is not None:
return mqtt.Client()
else:
return client