SenseCAP S2103 decoder

As title, I need a decoder or connector? For the device in the title.

I believe TTN and Datacake cater for this device, is it possible for some smart person to get this working on TagoIO?

We can help you if you mind to share the documentation or existing TTN/Datacake decoder of this device.

TTN decoders are fully compatible with TagoIO, and usually requires just a few adjustments.

Usually it includes a function, like decoder(bytes, port), and you can copy the entire function to TagoIO payload parser.

Then you need to add the following code on the bottom, run it and fix any unexpected behavior.

const payloadRaw = payload.find((data) => data.variable === "payload");
const port = payload.find((data) => data.variable === "port" || data.variable === "fport");

if (payloadRaw && port) {
  const bytes = Buffer.from(payloadRaw.value, "hex");
  const result = decode(bytes, Number(port.value));

  const group = payloadRaw.group || String(Date.now());
  payload = toTagoFormat(result);
}


/**
 * Convert an object to TagoIO object format.
 * Can be used in two ways:
 * toTagoFormat({ myvariable: myvalue , anothervariable: anothervalue... })
 * toTagoFormat({ myvariable: { value: myvalue, unit: 'C', metadata: { color: 'green' }} , anothervariable: anothervalue... })
 *
 * @param {Object} object_item Object containing key and value.
 * @param {String} group Group for the variables
 * @param {String} prefix Add a prefix to the variables name
 */
function toTagoFormat(object_item, group, prefix = "") {
  const result = [];
  for (const key in object_item) {
    if (ignore_vars.includes(key)) continue;

    if (typeof object_item[key] == 'object') {
      result.push({
        variable: object_item[key].variable || `${prefix}${key}`,
        value: object_item[key].value,
        group: object_item[key].group || group,
        metadata: object_item[key].metadata,
        location: object_item[key].location,
        unit: object_item[key].unit,
      });
    } else {
      result.push({
        variable: `${prefix}${key}`,
        value: object_item[key],
        group,
      });
    }
  }

  return result;
}

Hello Martin,

Were you able to get your s2103 on-boarded onto Tago,io platform?

Would you mind sharing the code you used to get it up and running?

Thanks! Appreciate any help