DeuxVis / Lora-TTNMapper-T-Beam

TTNMapper on the TTGO T-Beam
GNU General Public License v3.0
111 stars 48 forks source link

Added Payload decoder to readme.md #2

Closed Roeland54 closed 5 years ago

DeuxVis commented 5 years ago

FYI my decoder is this :

function Decoder(bytes, port) {
    var decoded = {};

    decoded.latitude = ((bytes[0]<<16)>>>0) + ((bytes[1]<<8)>>>0) + bytes[2];
    decoded.latitude = (decoded.latitude / 16777215.0 * 180) - 90;

    decoded.longitude = ((bytes[3]<<16)>>>0) + ((bytes[4]<<8)>>>0) + bytes[5];
    decoded.longitude = (decoded.longitude / 16777215.0 * 360) - 180;

    var altValue = ((bytes[6]<<8)>>>0) + bytes[7];
    var sign = bytes[6] & (1 << 7);
    if(sign)
    {
        decoded.altitude = 0xFFFF0000 | altValue;
    }
    else
    {
        decoded.altitude = altValue;
    }

    decoded.hdop = bytes[8] / 10.0;

    return decoded;
}

The main difference is it seems to be taking care of negative altitudes.

It also does include the hexstring variable in the output. Is it needed ?

Roeland54 commented 5 years ago

Seems like your decoder is the best option. The hexstring is not needed. So maybe you can add yours instead.

DeuxVis commented 5 years ago

Excellent work Roeland, thanks. Sorry not to be more responsive at the moment, I might be able to take a few minutes to test and accept your pull requests later in the week.

Roeland54 commented 5 years ago

With pleasure. Sorry about the commit mess but I forgot that merging into my own master branch would impact this pull request. I reverted the changes.