TTN-Mapper-GPS/decoder.txt

13 lines
363 B
Plaintext
Raw Normal View History

2019-10-04 09:24:27 +00:00
function Decoder(b, port) {
var lat = (b[0] | b[1]<<8 | b[2]<<16 | (b[2] & 0x80 ? 0xFF<<24 : 0)) / 10000;
var lon = (b[3] | b[4]<<8 | b[5]<<16 | (b[5] & 0x80 ? 0xFF<<24 : 0)) / 10000;
var alt = (b[6] | b[7]<<8 | (b[7] & 0x80 ? 0xFF<<16 : 0));
var hdop = b[8] / 100;
return {
latitude: lat,
longitude: lon,
altitude: alt,
hdop: hdop
};
}