2015-06-06 07:23:27 -07:00
|
|
|
'''
|
|
|
|
Created on 20.05.2015
|
|
|
|
|
|
|
|
@author: wn
|
|
|
|
'''
|
|
|
|
|
|
|
|
import paho.mqtt.client as mqtt
|
|
|
|
import json
|
|
|
|
import pymongo
|
|
|
|
import datetime
|
|
|
|
import sys
|
|
|
|
|
|
|
|
def on_message(client, userdata, msg):
|
|
|
|
j = json.loads(msg.payload)
|
|
|
|
print(json.dumps(j, indent=2, separators=(',',':')))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
print("Starting client ...")
|
|
|
|
|
|
|
|
client = mqtt.Client()
|
|
|
|
client.on_message = on_message
|
2016-06-25 15:44:13 +02:00
|
|
|
client.connect("172.16.2.15", 1883, 60)
|
2015-06-06 07:23:27 -07:00
|
|
|
for i in sys.argv[1:]:
|
|
|
|
client.subscribe(i)
|
|
|
|
|
|
|
|
client.loop_forever()
|
|
|
|
|