I’m not sure of the Buffer issue, or from where it originates (my lack of understanding/knowing the engine under the TTN hood and the languages), but clearly it was working in the past. I will look at “Is there any documentation on payload functions?” and will see if I can find an answer there.
Below is the first block of code from encoder.js from lora-serialization with just the unixtime
variable. Is the second line Buffer(byteSize)
causing the issue, or is it behind the scenes in TTN?
var intToBytes = function(i, byteSize) {
var buf = new Buffer(byteSize);
for (var x = 0; x < byteSize; x++) {
buf[x] = i >> (x * 8);
}
return buf;
};
var unixtime = function(i) {
if (isNaN(i) || i < 0) {
throw new Error('Unix time must be positive');
}
return intToBytes(i, unixtime.BYTES);
};
unixtime.BYTES = 4;
Using lora-serialization alone would be great, but might decide to use it for decode with some of the other information you provide on the “best practices” link as a work around for the encoder. Is it possible to use one for decoding and another for encoding, as long as the node is programmed for that?