From e661130651cc3bddceab43002bb120c646e24650 Mon Sep 17 00:00:00 2001 From: Jurnell Cockhren Date: Sat, 6 Aug 2016 00:35:27 -0500 Subject: [PATCH 1/2] simple python example using paho --- scripts/sup.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 scripts/sup.py 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) From d6cee3958951ed8dc5a32332a24737143177e6b1 Mon Sep 17 00:00:00 2001 From: Jurnell Cockhren Date: Tue, 16 Aug 2016 12:43:47 -0500 Subject: [PATCH 2/2] Added requirements file --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 requirements.txt 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