MQTT data send in downlink is different than in frame-log

I tried sending Base64 encoded data using MQTT but receiving some other text in downlink payload on the portal. This just confused me if what I am trying to send was actually not sent.
So, what type (i.e. text, hex string, Base64 encoded…) of data do we need to send in downlink.

Downlink - application/[applicationID]/node/[devEUI]/tx

{
“reference”: “abcd1234”, // reference which will be used on ack or error (this can be a random string)
“confirmed”: true, // whether the payload must be sent as confirmed data down or not
“fPort”: 10, // FPort to use (must be > 0)
“data”: “…” // base64 encoded data (plaintext, will be encrypted by LoRa Server)
}

What is the relation between data in above json and payload shown on the portal?

Please note that base64 is an encoding to present one or multiple bytes as text. It is perfectly valid that you see two different strings representing exactly the same bytes. E.g. one string could be encoded using base64, the other HEX.

Could you let me know what you mean with the portal? In case you mean the LoRa App Server web-interface it is correct that it presents different data. The frame-log in LoRa App Server shows you the RAW frames as sent and received by the network (and potentially could be seen by others). As all LoRaWAN payloads are encrypted before transmission, the payload that is displayed in the LoRa App Server log is the encrypted version of what you published to the MQTT topic.

1 Like

Dear @brocaar. I’ve already registered a parking sensor in the application server. After turning the sensor on, it starts to send data to the server. I’ve gathered sensor data from the broker but unfortunately received data is not correct.
I also registered sensor in LORIOT server and gathered Its generated data from there. According to the sensor manual, the gathered data using LORIOT is correct.
Could you please help me? Is this a bug? or have I missed something?

Following are some of the data gathered from your application server and LORIOT server:

*** Brocaar Application server:
base64: +gABAAcmEA==
decoded: a001 00 07 26 10
Corresponding data gathered from Loriot server: fa 00 01 08 07 e6 17

base64: +gABCRaqABQQAQEAARP////////LQQ==
decode: a001 09 16 a014 10 01 01 00 01 13 ffff ffff 2c1
Corresponding data gathered from Loriot server: fa 00 01 09 16 aa 00 13 10 01 01 00 01 15 ff ff ff ff ff ff 8c 2c

Hello,

I have a couple of questions:
How do you decode the base64 data?
Are you sure your sensor is sending exactly the same data to Brocaar’s app and Loriot? (Are you using a poly packet forwarder?)

Regards,

I decode payload.data using java script “Buffer(msg.payload.data, ‘base64’)” function.
Regarding the second question, parking sensor sends predefined messages in different situations. On power on it sends <fa 00 01 00 07 26 10>. When the parking place is occupied it sends <fa 00 01 09 16 aa 00 13 10 01 01 00 01 15 ff ff ff ff ff ff 8c 2c> to the server. according to my previous topic, some bytes are exactly same as the sensor data but some bytes are different. I tested the system with LORIOT system and received correct data.

Hello,

There are two things that make no sense (at least to me) in the data you quote:

  1. base64 +gABAAcmEA== is FA 00 01 00 07 26 10 in HEX, which is almost what you got (except the missing _‘F’_in the beginning of the HEX string) and with the F at the beginning it is exactly what you expected. Therefore it seems that in this case, the Loriot data is wrong.

  2. in the second case, the ‘F’ is again missing from the beginning of the HEX string, so there must be a problem with the conversion as well. What is weird here is that the decoded HEX and the Loriot HEX is only different in four bytes:

fa 00 01 09 16 aa 00 13 10 01 01 00 01 15 ff ff ff ff ff ff 8c 2c
fa 00 01 09 16 aa 00 14 10 01 01 00 01 13 ff ff ff ff ff ff cb 41

Isn’t it possible that these four bytes are some kind of variable data like battery status, temperature, etc?

Regards,

Dear @glederer007,
Thank you very much for your useful response. My problem solved by changing in the base64 decoder.

HI,
I am still not clear how to get the expected data. As, I am getting different value of data for the same data transmitted in the API
My sensor is transmitting
HEX data - 1a4532120322
base64 data - GkUyEgMi
But with every data received I see different value in frmPayload field
data received are - 2u6ey76a, I4DmB5X1, kwaRU5E2.
Please help me figure out what I am missing or doing wrong here.

Please take a look at https://docs.loraserver.io/lora-app-server/integrate/data/ for receiving decrypted data.

The frame-log data is for debugging purpose only (I will add some comments around this, as it is confusing a lot of people) and is encrypted. In order to decrypt this data, take a look at https://godoc.org/github.com/brocaar/lorawan#example-PHYPayload--Decode. However, you probably want to use the first link to get the decrypted data :slight_smile:

Thanks for clearing the confusion.

Hi @brocaar,

as to avoid this confusion i recommend to put a disclaimer on the administration page for everyone to know that the frame log data is encrypted.