Created
April 29, 2019 19:34
-
-
Save jamescoxon/af1bb2f94b814af1484670bf60587e4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Base code from https://www.eclipse.org/paho/clients/python/ lifted on 29/4/19 | |
| import paho.mqtt.client as mqtt | |
| # The callback for when a PUBLISH message is received from the server. | |
| def on_message(client, userdata, msg): | |
| print("{}: {}".format(msg.topic, msg.payload.decode("utf-8") )) | |
| client = mqtt.Client() | |
| client.on_message = on_message | |
| host = "dangilsystem.zapto.org" | |
| client.connect(host, 1883, 60) | |
| client.subscribe("callback/block") | |
| print("Subscribed") | |
| # Blocking call that processes network traffic, dispatches callbacks and | |
| # handles reconnecting. | |
| # Other loop*() functions are available that give a threaded interface and a | |
| # manual interface. | |
| client.loop_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment