Skip to content

Instantly share code, notes, and snippets.

@felixerdy
Last active November 1, 2020 09:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixerdy/f959ac03df98c6947f1c7f35d537f23e to your computer and use it in GitHub Desktop.
Save felixerdy/f959ac03df98c6947f1c7f35d537f23e to your computer and use it in GitHub Desktop.
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