Drop downlink data message: no payload when using downlink payload formatters

We are using a selfhosted ttn-stack-v3. Everything seems to be working well, except when we try to send a downlink using the Downlink payload formatters.

If we use the example of Downlink Encoder function from: TTN docs

We can push a download message via MQTT using

  {"downlinks": [{
    "f_port":15,
    "confirmed":false,
    "priority": "NORMAL",
    "frm_payload": "AQ=="
  }]
}

However, if we send the object:

  {"downlinks": [{
    "f_port":15,
    "confirmed":false,
    "priority": "NORMAL",
    "payload_fields": {
    "led": true
  }
  }]
}

Following the examples in TTN it should run the Downlink payload formatters, however we get this error code:

{
  "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
  "namespace": "pkg/applicationserver",
  "name": "no_payload",
  "message_format": "no payload",
  "code": 2
}

This error code is received also if we change the object ā€œpayload_fieldsā€ to any other, for example ā€œfields_payloadsā€. This is why I think we are not using the right object.

Ā· Which object must be sent to execute the Downlink payload formatters?
Ā· Are the Downlink payload formatters a functionality not ready yet?

Thank you very much.

Solved

By deeply searching in the github I arrived till this page where there are a lot of examples, so I could find the right object was ā€œdecoded_payloadā€.

  {"downlinks": [{
    "f_port":15,
    "confirmed":false,
    "priority": "NORMAL",
    "**decoded_payload**": {
    "led": true
  }
  }]
}

It might be useful to give more visibility to these examples in the documentation

3 Likes

I am actually getting this error in the application if I do not include the frame payload:

Error cause
{
  "name": "TypeError",
  "message": "e is undefined",
  "cause": "vc"
}

If I publish this with MQTT:

{
      "downlinks": [
        {
          "f_port": 15,
          "decoded_payload": {
            "object_123": 123,
          },
          "priority": "NORMAL"
        }
      ]
    }

It works normally if I include the "frm_payload": "vu8=" as in the examples.
Any clue why? I thought the frame would be optional, but perhaps it isnā€™t?

For future reference, you have the info here: https://www.thethingsindustries.com/docs/the-things-stack/concepts/data-formats/

Wild guess: if you (only) provide decoded_payload then V3 will use your Decoder. which has an error that, in your case, throws "e is undefined". But when (also) providing frm_payload then thereā€™s no need to run the Decoder, so all is fine as far as V3 is concerned.

Iā€™d say: check your Decoder, or show its code here.

Ignore this post and read the comment below. It can stay as a reference to a wrongly written Encoder.


I was referring to the encoder, since itā€™s for a downlink. With the encoder:

function Encoder(payload, f_port) {
  var bytes = [];
  bytes[0] = payload.object_123;
  
  return bytes;
}

it gives the error from before and also this one:

drop downlink data message - invalid output of type float64

{
  "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
  "namespace": "pkg/messageprocessors/javascript",
  "name": "output_type",
  "message_format": "invalid output of type `{type}`",
  "attributes": {
    "type": "float64"
  },
  "code": 2
}

The overview picture of a downlink without the frame and the next with a frame:
downlinks

ok, nevermind the invalid output of type float64.

bytes[0] = (payload.object_123 & 0x00FF);

and it encodes properly.


As you mention @arjanvanb if using a frm_payload the rest of the payload is ignored and all is fine.

However, if the frm_payload is not in the mqtt message, in the V3 console the first error still occurs

and I tested and the downlink is still sent correctly to the device! :grin:

Did you find the solution to the TypeError?
Iā€™m running into the same issue. My encoder function is similar to yours, first getting the drop downlink data message - invalid output of type float64 error. That was fixed by adding & 0x00FF to each value in the byte array. Now console error is

Something went wrong when displaying this event
arrow_drop_down
Show raw payload
Error cause
{
ā€œnameā€: ā€œTypeErrorā€,
ā€œmessageā€: ā€œundefined is not an object (evaluating ā€˜e.replaceā€™)ā€,
ā€œcauseā€: ā€œvcā€
}

Any idea what cause ā€œvcā€ is? I ran the encoder function through the debugger and it didnā€™t find any errors.

This topic was automatically closed after 30 days. New replies are no longer allowed.