Setup decoder for a device

Setup decoder for a device


Go to your device (or application) on TTN Console and select Payload formatters and Uplink.

If you registered a Decentlab device with Device Repository (see ðŸ“„ Registering device in TTN EU868), the payload decoder is already available. Just make sure the effective Formatter type is Repository. To test it, you can copy an example payload from the datasheet (https://www.decentlab.com/support) and use the Byte payload field below.

If the device has been registered Manually (see ðŸ“„ Registering device in TTN EU868​),  select Javascript for Formatter type. Take the JavaScript source code from the github payload decoder repository and paste into the Formatter parameter window by overwriting its content. Remove the main() function and its call.

function main() {
    ...
}

main();

Append the following lines.

function decodeUplink(input) {
var errors = [];
var data = {};
var res = decentlab_decoder.decode(input.bytes);
if ("error" in res) {
errors = [res["error"]];
} else {
data = res;
}
return {
data: data,
warnings: [],
errors: errors,
};
}

Additionally, you can Test decoder with an example payload obtained from the datasheet (https://www.decentlab.com/support). Click Save changes.

The uplink messages now include the decoded sensor data.