TTN has a repository of vendor-curated CODECs which is appealing to me, since I don’t have time to reinvent wheels.
I got to ask, are there any plans to allow ChirpStack to use these natively (drop-in)?
Currently, I got TTN code to compile by appending the following to the end (calls Decode function with sample data object - but it’s based on actual data being reported by a Laird RTD sensor, 455-00098):
function Decode(fPort, bytes, variables) {
return decodeUplink(bytes);
}
sensordata =
{
"bytes": [0x0b,0x01,0x00,0x06,0x00,0x13,0x05,0x00,0x00,0x00,0x00],
"fPort": 1
};
console.log(sensordata);
console.log(Decode(1, sensordata, ""));
Which outputs:
Output:
[
11, 1, 0, 3, 0,
12, 5, 0, 0, 0,
0
]
{
data: {
msgType: 'Laird_RTD',
options: [ 'Sensor request for server time' ],
temperature: 12.03,
batteryCapacity: '80-100%',
alarmMsgCount: 0,
backlogMsgCount: 0
}
}
The Protocol Manual agrees with this decoding and, most importantly, this is using stock TTN V3 CODEC!
However, while it compiles and decodes sample data, I can’t get anything on ChirpStack except an error:
// ChirpStack expects different function name
function Decode(fPort, bytes, variables) {
//var sensordata = { "bytes": bytes, "fPort": fPort };
return decodeUplink(bytes); //sensordata);
}
DEVICE DATA error contains:
applicationID:"5"
applicationName:"DSE-App2021"
deviceName:"rs-blue-RTD"
devEUI:"0025ca0a0000f616"
type:"UPLINK_CODEC"
error:"execute js error: js vm error: TypeError: Cannot access member '0' of undefined"
fCnt:1
tags:{} 0 keys
publishedAt:"2021-08-30T20:44:10.160990126Z"
Grr. Does anyone see why this might be?
Note1: My chirpstack is on intranet so I can not use integrations, meaning that my devices need to be decoded inside ChirpStack. Some vendors make this a challenge (I’m looking at you, radiobridge.com), but even for the ones that do release CODECs, there is always the problem of maintaining support for new devices. Thus, it’s always nicer to ‘borrow’ maintained code in these situations, rather than hacking stuff found on the net.
Note2: Don’t know about you, but my knowledge of javascript is very primitive/sucks so THIS online compiler came in very handy when trying to figure out what the somewhat cryptic error message in DEVICE DATA tab meant (e.g., "error:“execute js error: js vm error: TypeError: Cannot access member ‘0’ of undefined”).

I thought I would share this quick and dirty little hack I stumbled across whilst trying to decode some dodgy oem’s undocumented trinkets…
Last week I merged this into the master branch. After cloning the TTN lorawan-devices repo, you can import these devices as “device-profile templates”. You can find the v4 draft documentation here: 