Skip to content

Instantly share code, notes, and snippets.

@jamescoxon
Created April 29, 2019 19:34
Show Gist options
  • Select an option

  • Save jamescoxon/af1bb2f94b814af1484670bf60587e4a to your computer and use it in GitHub Desktop.

Select an option

Save jamescoxon/af1bb2f94b814af1484670bf60587e4a to your computer and use it in GitHub Desktop.
#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