Does the payload decoder actually modify the payload forwarded to an application?

I am using Node-red to decode the payload from my FiPy device. This is 52 bytes of data with all my values packed into 2-byte pairs. All working well.

But it would be nice to see this data in the TTN portal. If I write a payload decoder there, does it the foul up what gets sent on to my node-red application (using MQTT)?
Thanks

Simon

If you look in the JSON form TTN that MQTT receives your undecode payload is in payload.uplink_message.frm_payload

If you decode the payload in TTN it simply adds payload.uplink_message.decoded_payload with the decoded payload in it.

{"topic":"v3/em300-mcs@ttn/devices/eui-xxxxxxxx/up","payload":{"end_device_ids":{"device_id":"eui-xxxxxxx","application_ids":{"application_id":"em300-mcs"},"dev_eui":"xxxxx","join_eui":"24E124C0002A0001","dev_addr":"xxxxxxxx"},"correlation_ids":["as:up:01FV4AENGMD1PDDNFMD1V9FTFE","gs:conn:01FTZQHMAS38W7QTGM4W43TCRM","gs:up:host:01FTZQHMB1VTQTPYA4FVP68VRM","gs:uplink:01FV4AENA4YP64KCQ7CBAWHP3T","ns:uplink:01FV4AENA6ZWS8CDECQ3EJ5937","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FV4AENA66JV4TSNB4FXCFQJW","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FV4AENGM7HH26WX4Q7HC4N6W"],"received_at":"2022-02-05T06:51:56.821687979Z","uplink_message":{"session_key_id":"AXxHrcleFlsv5uDdBJTJlg==","f_port":85,"f_cnt":18132,"frm_payload":"A2fiAARolQYAAQ==","decoded_payload":{"door":1,"humidity":74.5,"temperature":22.6},"rx_metadata":[{"gateway_ids":{"gateway_id":"xxxxxxxxx","eui":"xxxxxxx"},"time":"2022-02-05T06:51:56.499006Z","timestamp":3516405212,"rssi":-116,"channel_rssi":-116,"snr":-4.75,"location":{"latitude":-xxxxxxx,"longitude":xxxxxx,"altitude":950,"source":"SOURCE_REGISTRY"},"uplink_token":"CiUKIwoXdGVjaDUtYWx2ZXJzdG9uZS0wMi1kYm4SCDEzMDdOAFkAENyr4IwNGgwIjL34jwYQyuiWpAIg4MbV0Kv6IyoMCIy9+I8GELD0+O0B","channel_index":7}],"settings":{"data_rate":{"lora":{"bandwidth":125000,"spreading_factor":9}},"coding_rate":"4/5","frequency":"867900000","timestamp":3516405212,"time":"2022-02-05T06:51:56.499006Z"},"received_at":"2022-02-05T06:51:56.614811179Z","consumed_airtime":"0.205824s","network_ids":{"net_id":"000013","tenant_id":"ttn","cluster_id":"ttn-eu1"}}},"qos":0,"retain":false,"_msgid":"c523713946d42cd2"}
1 Like

Thank Johan
I have an upload payload formatter as such:

function Decoder(bytes, port) {
  // Decode plain text; for testing only 
  return {
      data: bytes
  };
}

As far as I can see it does nothing, but without it I get encrypted data only in my MQTT message (something very similar to your “frm_payload”:“A2fiAARolQYAAQ==”).

This at least provides me with payload.uplink_message.decoded_payload which contains my packed bytes.

Is it possible to decrypt in node-red if I don’t use this payload formatter? It seems I am transmitting unencrypted data to my ‘application’ and via MQTT to my node-red.

kind regards

Simon

Yes, this will be the unencrypted payload (Your key were used buy the TTN server to decrypt it).

I have not seen a option where you have a choice for the server not to decrypt it.

Here is a example of how to use Node-Red to decode your payload.
https://github.com/JohanScheepers/TTN-Node-Red-Decoder

1 Like

Nope, not encrypted, encoded. The frm_payload is base64 encoded for efficient transport of binary data in an ascii container. (The same uplink message needs to ‘survive’ http posts if you select the http integration)

Think I have it sorted

There is indeed the option to do that!

In the Application layer settings for the device and general settings for the Application.

Anyone else finding this and trying it out, please read the LoRaWAN spec and learn cryptography 101 before asking questions and don’t expect a blizzard of replies.

1 Like