Last active
August 29, 2015 14:21
-
-
Save braitom/770d38402457e585f10f to your computer and use it in GitHub Desktop.
MQTT subscribe sample
This file contains 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
# -*- coding: utf-8 -*- | |
import paho.mqtt.client as mqtt | |
def on_connect(client, userdata, flags, rc): | |
print("Connected with result code " + str(rc)) | |
client.subscribe("test/iOS") | |
def on_message(client, userdata, msg): | |
print(msg.topic + " " + str(msg.payload)) | |
if __name__ == '__main__': | |
client = mqtt.Client() | |
client.on_connect = on_connect | |
client.on_message = on_message | |
client.connect("10.12.0.244", 1883, keepalive=60) | |
client.loop_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment