Skip to content

Instantly share code, notes, and snippets.

@felixerdy

felixerdy/decoder.js Secret

Last active Nov 1, 2020
Embed
What would you like to do?
Decoder for TTN Mapper
function Decoder(b, port) {
var lat = (b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) / 10000000;
var lon = (b[4] | (b[5] << 8) | (b[6] << 16) | (b[7] << 24)) / 10000000;
var alt = (b[8] | (b[9] << 8)) / 10; // in m
var pdop = (b[10] | (b[11] << 8)) / 100;
return {
latitude: lat,
longitude: lon,
altitude: alt,
hdop: pdop,
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment