The TTN code uses:
…which says:
Otto targets ES5. ES6 features (eg: Typed Arrays) are not supported.
And some other TTN code documents:
// Decoder is a JavaScript function that accepts the payload as byte array and
// returns an object containing the decoded values
...
// Converter is a JavaScript function that accepts the data as decoded by
// Decoder and returns an object containing the converted values
...
More browsing shows that the first parameter is a Go []byte
, which will become a JavaScript array of numbers. (JavaScript does not have bytes.) That is confirmed by a Decoder that prints it, just to investigate a bit:
function Decoder(bytes, port) {
return {
bytes: {
toString: Object.prototype.toString.call(bytes),
typeof: typeof bytes
},
item: {
toString: Object.prototype.toString.call(bytes[0]),
typeof: typeof bytes[0]
}
};
}
…which yields:
{
"bytes": {
"toString": "[object Array]",
"typeof": "object"
},
"item": {
"toString": "[object Number]",
"typeof": "number"
}
}
So, JavaScript (ECMAScript 5) with an array of numbers. The best resource is Mozilla Developer Network, I feel, and “mdn” is a great keyword for search engines: mdn array. Also, you can use auto-completion in the developer console of your browser. Just start with something like:
var bytes = [0x31, 0x31, 0x31, 0x20, 0x30, 0x31, 0x34, 0x00];
…after which typing bytes.
will show you the supported functions and all.
I’m quite sure it’s not, but just repeating that question here