Problem with read AB BLE Gateway Python mosquitto

Help me

�’;j����L �����I�����Qp� �
�’;j�&��L �����I�����Qp� 2
�! ;j�s��� �G7��T6���bW<��
�( �w3�|I�����1CPeeSEn0B0 Z]��{
�’;j����L �����I�����Qp� �
�’;j����L �����I�����Qp� �
�’;j�&��L �����I�����Qp� 3
�( �w3�|I�����1CPeeSEn0B0 Z]��{
�’;j�ȴ�L �����I�����Qp� �
�’;j����L �����I�����Qp� �

The first line is the meta data of the gateway. The next lines are beacon data. Please check this link for more information.

(Python) The problem is that the second line there is no way I can read it and I want to know if it has anything other than hex decimals.Thanks

We read these lines by the code. Please have a try

words = data.split("\r\n")
print("\nCount={0}".format(len(words)))
for w in words:
    print ''.join(' {:02x}'.format(x) for x in w)

He’s giving me this error back. Thanks for the help

print ‘’.join(’ {:02x}’.format(x) for x in w)
ValueError: Unknown format code ‘x’ for object of type ‘str’

could you please paste the whole code?

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

Please also check the code here. That’s a websocket server example and it works with AB BLE gateway well.

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()

is the mqtt broker SSL enabled? ab gateway doesn’t support ssl yet.

I have not activated ssl

What’s the current status about gateway?

  1. Did you get the data as the picture still?
  2. Is your issue the code can’t run proper?
  3. What’s your python version?