diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..30a9338 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +argparse==1.2.1 +paho-mqtt==1.2 +wsgiref==0.1.2 diff --git a/scripts/sup.py b/scripts/sup.py new file mode 100644 index 0000000..74968ff --- /dev/null +++ b/scripts/sup.py @@ -0,0 +1,29 @@ +import paho.mqtt.client as mqtt +import ssl +import re + +client = mqtt.Client() + +MQTT_HOST = 'localhost' + +client.tls_set('/etc/ssl/private/ca.crt', + certfile='/etc/ssl/certs/localhost.crt', + keyfile='/etc/ssl/private/localhost.ckey', + cert_reqs=ssl.CERT_REQUIRED, + tls_version=ssl.PROTOCOL_TLSv1) + + +def on_message(client, userdata, message): + if re.match(r'^sup?', message.lower()): + client.publish('not much.') + + +def on_connect(client, userdata, flags, rc): + client.subscribe("#") + client.publish('Hello mqtt') + + +client.on_connect = on_connect +client.on_message = on_message + +client.connect(MQTT_HOST)