You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
// TTN V2
|
|
|
|
function Decoder(bytes, port) {
|
|
|
|
var decoded = {};
|
|
|
|
decoded.latitude = ((bytes[0]<<24)>>>0) + ((bytes[1]<<16)>>>0) + ((bytes[2]<<8)>>>0) + bytes[3];
|
|
|
|
decoded.latitude /= 10e4;
|
|
|
|
decoded.longitude = ((bytes[4]<<24)>>>0) + ((bytes[5]<<16)>>>0) + ((bytes[6]<<8)>>>0) + bytes[7];
|
|
|
|
decoded.longitude /= 10e4;
|
|
|
|
decoded.lastGPSAcquisition = bytes[8];
|
|
|
|
return decoded;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TTN V3
|
|
|
|
function decodeUplink(input) {
|
|
|
|
const bytes = input.bytes, data = {}
|
|
|
|
data.latitude = ((bytes[0]<<24)>>>0) + ((bytes[1]<<16)>>>0) + ((bytes[2]<<8)>>>0) + bytes[3];
|
|
|
|
data.latitude /= 10e4;
|
|
|
|
data.longitude = ((bytes[4]<<24)>>>0) + ((bytes[5]<<16)>>>0) + ((bytes[6]<<8)>>>0) + bytes[7];
|
|
|
|
data.longitude /= 10e4;
|
|
|
|
data.lastGPSAcquisition = bytes[8];
|
|
|
|
return {
|
|
|
|
data,
|
|
|
|
warnings: [],
|
|
|
|
errors: []
|
|
|
|
};
|
|
|
|
}
|