Sending same payload, receiving different ones

Hello! This is my first post here. I am developing a device to test the system reliability. I want to send an increasing number to the TTN gateway from a Lopy inserted in a pytrack module and monitor if any packet is lost. I have used the example provided by Lopy, modified to send 200 packets. I set constant payload (0x01,0x02,0x03) but the payload I receive in TTN is allways different. I have tried to change payload size, adding more bytes, and I see that the byte number in the payload shown by TTN changes and matches the number of bytes I send.
I upgraded Lopy firmware to last version.
¿ does anyone have the same problem ? ¿ any suggestions to solve it?payload%20received

This is my code:

# join a network using ABP (Activation By Personalization)
lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey))

# create a LoRa socket
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)

# set the LoRaWAN data rate
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)

for i in range (200):
    # make the socket blocking
    # (waits for the data to be sent and for the 2 receive windows to expire)

    # send some data
    s.send(bytes([0x01, 0x02, 0x03]))

    # make the socket non-blocking
    # (because if there's no data received it will block forever...)

    # get any data received (if any...)
    data = s.recv(64)

Check the AppSKey in the node. If the software requires you to define a sequence of bytes (like {0x11, 0x22, 0x33, ...} rather than some string "112233...") then also ensure you use the 0x prefix to tell it that the bytes are shown as hexadecimal. Maybe the software also requires you to reverse the order?

Why? As TTN is forwarding the data to the expected application, the gateway, NwkSKey and DevAddr are okay; see How does a network know a received packet is for them? But the payload itself is encrypted based on the AppSKey. Decrypting using a different key will simply show different results without any error. The encryption also takes the frame counter into account, which is why you see different values for different counter values. If you’d reset the node to make it start at zero again (and also reset the counters in TTN Console, or disable security there) then you’d see the very same sequences.

Thank you very much arjanvanb, you pointed me to the right direction. Encription and decription keys were different.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.