new
This commit is contained in:
28
mqtt2console.py
Normal file
28
mqtt2console.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
'''
|
||||||
|
Created on 20.05.2015
|
||||||
|
|
||||||
|
@author: wn
|
||||||
|
'''
|
||||||
|
|
||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
def on_message(client, userdata, msg):
|
||||||
|
# print(msg.topic+" "+str(msg.payload))
|
||||||
|
j = json.loads(msg.payload)
|
||||||
|
print(json.dumps(j,indent=4, separators=(',', ': ')))
|
||||||
|
print
|
||||||
|
print
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("Starting client ...")
|
||||||
|
|
||||||
|
client = mqtt.Client()
|
||||||
|
client.on_message = on_message
|
||||||
|
client.connect("172.16.2.15", 1883, 60)
|
||||||
|
client.subscribe("IoT/Measurement/MeterbusHub")
|
||||||
|
|
||||||
|
client.loop_forever()
|
||||||
|
|
Reference in New Issue
Block a user