Created
October 17, 2015 13:17
-
-
Save laclefyoshi/13934655b006ffdde42d to your computer and use it in GitHub Desktop.
MQTTブローカからのメッセージを表示
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import paho.mqtt.client as mqtt_client | |
topic = "MESHBLU_ACTION_UUID" | |
def on_connect(client, userdata, flags, rc): | |
print("connected with result code" + str(rc)) | |
client.subscribe(topic) | |
def on_message(client, userdata, msg): | |
print("received message: " + str(msg.payload) + " from " + msg.topic) | |
client = mqtt_client.Client() | |
client.on_connect = on_connect | |
client.on_message = on_message | |
client.username_pw_set("MESHBLU_ACTION_UUID", "MESHBLU_ACTION_PASS") | |
client.connect("MESHBLU", 1883, 60) | |
client.loop_forever() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment