def on_message(client, userdata, msg):
# print(msg.topic + " " + str(msg.payload))
words = msg.payload.split("\r\n")
# print("\nCount={0}".format(len(words)))
i =0;
for w in words:
if i > 1:
print [tmp for tmp in w]
# print map('{:02x}'.format, [int(i) for i in w])
i+=1
# print ''.join(' {:02x}'.format(x) for x in w)
# print(str(msg.payload).split("\r\n\r\n"))
# print("\x1a\x97&\xb5\x02\x01\x06\x1a\xffL\x00\x02\x15\xb5\xb1\x82\xc7\xea\xb1I\x88\xaa\x99".decode('string-escape').e)
# list = json.loads(msg.payload)
# time= strftime("%Y-%m-%d %H:%M:%S", gmtime())
#
# for key,value in list.iteritems():
# print ("")
# print key, value
The problem is that the enacted of the beacons via ab.gateway I can not read it.
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, rc):
print("Connected with result code " + str(rc))
client.subscribe("/beacons")
# The callback for when a PUBLISH message is received from the server.
def on_message(client, userdata, msg):
# print(msg.topic + " " + str(msg.payload))
words = msg.payload.split("\r\n")
# print("\nCount={0}".format(len(words)))
i =0;
for w in words:
if i > 1:
print [tmp for tmp in w]
# print map('{:02x}'.format, [int(i) for i in w])
i+=1
# print ''.join(' {:02x}'.format(x) for x in w)
# print(str(msg.payload).split("\r\n\r\n"))
# print("\x1a\x97&\xb5\x02\x01\x06\x1a\xffL\x00\x02\x15\xb5\xb1\x82\xc7\xea\xb1I\x88\xaa\x99".decode('string-escape').e)
# list = json.loads(msg.payload)
# time= strftime("%Y-%m-%d %H:%M:%S", gmtime())
#
# for key,value in list.iteritems():
# print ("")
# print key, value
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect("10.1.10.113", 8883, 60)
# 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()