Is it possible to use payload formmatters to split the message?

It is possible to use payload formmatters to split the message (input) and run the same webhook for each of the split messages ?

For example:

function decodeUplink(input) {
  var payloads = [];
  
  payloads.push({
    data: {
      bytes: input.bytes
    },
    warnings: [],
    errors: []
  });
  
  return payloads;
}

And have the webhook run for each of the payload items.

Thanks

No, you can’t return an array of results - the stack has to be able to read the warnings & errors array so it can act accordingly.

But you can return any data structure you like in the data object - so you can prepare two lots of “data” and then the web hook can pick out the one that it needs.

Or you could just run the web hook and it could do whatever it needs twice.

Excepting that payload formatters aren’t a guaranteed thing**, so if your application needs to be as robust as possible, consider decoding in your webhook.

** If the application server is under load, Javascript processing may exceed the 100ms time limit which is aborted. I see this about ½ - 1% of the time.

Thanks for the reply.

Actually I don’t need to decode the message just to split it.

My Lora device is a gateway/hub for messages from other devices.

And I have a third application that parses those messages but they have to arrive separately.

I can’t think of a way to do that - there can only be one payload formatter for an uplink but you can have multiple web hooks but they can only relay the entire uplink plus what ever is decoded by the payload formatter. The payload formatter can respond with different data structures depending on what’s in the uplink, but it only runs once and effectively you want it to run twice and trigger a web hook each time.

Why do they have to arrive separately - maybe there is something that can be done at that end - or even proxy the uplink back to itself - so it goes to a web hook that then does the split and resends it to the original web hook.

Were you doing this previously in v2 or is this a new design?

Right now I am using it in a Network Lora from Multitech with Node-Red.

// How to use logger -> node.warn("msg.size = " + msg.size);
gweui = msg.gweui;
rssi = msg.rssi;
time = msg.time;
deveui = msg.deveui;

date_time = new Date(time);
timestamp = date_time.getTime() / 1000 | 0;

/*
    In the lora message we can receive several[0-10] messages from the bottles.
    The following code consists in separating it in the independent bottle messages to send them to 'HOBA'.
*/

msg_size_in_bytes = 5;
num_of_msgs = msg.size / msg_size_in_bytes;

var output_msgs = [];
for (var i = 0; i < num_of_msgs; i++) {
  output_msgs.push({
    payload: {
      payload: msg.payload.slice(
        i * msg_size_in_bytes,
        (i * msg_size_in_bytes) + msg_size_in_bytes
      ),
      "time": time,
      "rssi": rssi,
      "deveui": deveui,
      "timestamp": timestamp,
      "gweui": gweui,
    }
  });
}

return [output_msgs];

But of course I would like to centralize and that the Lora/4G gateways work in forwarder mode.

A priori, the other extreme is not prepared to receive a set of messages and decode them in bulk. The maximum size of the subset would not be 10 messages in the event that the hub stack was full.

I will continue to investigate if I can do something.