Decoder function

When using TTN’s standard naming convention for the Decoder function, being:

function Decoder(bytes, port) {
    ...

…then bytes is an array of numbers, with each number being 0 to 255. So it seems the above needs to be invoked with something like:

// LSB 32 bits float
var float = Bytes2Float32(bytes[3]<<24 | bytes[2]<<16 | bytes[1]<<8 | bytes[0]);

Alternatively, change the function to read:

function Bytes2Float32(bytes) {
    // better rename this to a new local variable, e.g., bits:
    bytes = bytes[3]<<24 | bytes[2]<<16 | bytes[1]<<8 | bytes[0];
    var sign = (bytes & 0x80000000) ? -1 : 1;
    ....

…and invoke with:

// Take bytes 0 to 4 (not including)
var float = Bytes2Float32(bytes.slice(0, 4));

(When handling a lot of values, use the x+= addition assignment operator and the x++ postfixed increment operator to keep track of the bytes that have been handled.)

As an aside, bytes2short can be written as:

// LSB 16 bits signed number.
// Sign-extend to 32 bits to support negative values, by shifting 24 bits
// (too far) to the left, followed by a sign-propagating right shift:
var signedInteger = bytes[1]<<24>>16 | bytes[0];