How can I decode my data from the gateway logfile?

Hello,

I am trying to find a way to decode my payload from a gateway logfile.
The original payload is 0x1100000000
Can you give an example to decode the received payload and check the received MIC?

[2018-01-16 00:54:55.019] NOTIC [01] UP: {“regionid”:1000,“upinfo”:{“rtt”:[648,801,1229],“xtime”:2547708460,“rxtime”:1516064095.018607,“rssi”:-95,“snr”:0.250000},“Freq”:868300000,“DR”:0,“msgtype”:“updf”,“MHdr”:128,“DevAddr”:3008000,“FCtrl”:0,“FCnt”:76,“FOpts”:"",“FPort”:1,“FRMPayload”:“57D158A390”,“MIC”:-935445030,“RefTime”:1516064094.674192}

NwkSKeyUp: 1a409101f7d478605f5505163acbd8d3

Many thanks for your help.

For uplinks, the value of FRMPayload is encrypted using the AppSKey, not the NwkSKey.

Encryption also uses meta data such as the DevAddr, FCnt and direction; see

If this is just for debugging, then it’s much easier to just use the full packet (like copied from the gateway’s Traffic page in TTN Console) along with, e.g., aforementioned https://github.com/anthonykirby/lora-packet or an online version at https://runkit.io/avbentem/lorawan-packet-decoder/branches/master

In your case, the full packet is hexadecimal 0x80 00E62D00 00 4C00 01 57D158A390 DA3D3EC8, and the online decoder shows its MIC is indeed valid. (To properly decrypt FRMPayload specify the true AppSKey; with the wrong AppSKey you get wrong results without any warning.)

Beware that your log file seems to show mostly decimal values. Like:

  • Decimal "MHdr":128 yields hexadecimal 0x80.
  • "DevAddr": 3008000 is 0x002DE600, which in the packet is transmitted Least Significant Byte first (LSB), being the reversed bytes 00E62D00.
  • "FCnt":76 is 0x004C, or 4C00 LSB.
  • The MIC shows as a negative number, being 0xC83E3DDA, shown as DA3D3EC8 in the full packet.

Hi arjanvanb,
many thanks for the detailed explanations to assemble the hex-encoded lora packet.

Perfect answert!!!

Cheers Buddy

Hello,

I am working on a project where I have to send some senso data from Arduino to a Raspberry Pi 3.
When I follow the tutorial for the single channel gateway, the communication is working and I can see data on the website.

I do receive the data on my RPi as you can see on the picture.
But I’m trying to get these same data without the encryption on the raspberry and save them locally on the RPi.
gw_encryption

I know the encryption is related to these settings : NwkSKey, AppSKey, AppKey but I don’t know how to disable the encryption when I receive data on the RPi.

Does someone know how to do that?

Besr regards,

you can’t direct… only through TTN if that’s what you asked

Indeed I can decrypt and then read data from the TTN console as you said but I wanted to read these data directly from the RPi :frowning:

Thank you for your answer. !!

I wouldn’t even try to have the Raspberry Pi only handle the data it has received itself. Instead, set up an MQTT client (easily done in the Pi’s Node-RED) connected to the node’s application. That way, you even get the data on the Pi when the node’s transmission is received by another gateway.

See https://www.thethingsnetwork.org/docs/applications/mqtt/ and https://www.thethingsnetwork.org/docs/applications/nodered/ (and other posts on this forum).

I need to create an offline application for the RPI gateway that I am mounting. Can you get a graphical message to connect and disconnect the PC (connected to the gateway), offline?