Cayenne LPP Decoder

Again I’ve not read the LPP documentation, but I’m quite sure you’ll need it for altitude too:

decoded.altitude = (bytes[i++]<<24>>8 | bytes[i++]<<8 | bytes[i++])/100;

Same goes for anything that can be negative, such as temperatures.

And if Cayenne has any 32 bits type that is not signed (unsigned, which cannot be negative) then you actually need to ensure JavaScript does not handle it as a “two’s complement number”. See uint32 in Abeeway Microtracker Decoder for one option to do that.

Also, one of the major selling points of LPP is its support for dynamic length payloads. So, you cannot use fixed array indexes, like bytes[6], in your while(i < bytes.length) loop. Instead, use the postfix-increment in bytes[i++]. (Even for fixed-position payloads, using i++ often makes the code less error prone anyway.)

Another selling point is that it allows for multiple readings of sensors of the same type, so you cannot use decoded.someName = ..., but need to add the “channel” number to the names, like, e.g., decoded['altitude_' + s_ch] = ....

But of course, you don’t need to worry about that when using TTN’s decoder.