Closed dakoller closed 7 years ago
Hi,
I use the following decoder function from you:
function Decoder(bytes, port) { // Decode an uplink message from a buffer // (array) of bytes to an object of fields. var decoded = {}; // if (port === 1) decoded.led = bytes[0]; decoded.lat = ((bytes[0]<<16)>>>0) + ((bytes[1]<<8)>>>0) + bytes[2]; decoded.lat = (decoded.lat / 16777215.0 180) - 90; decoded.lon = ((bytes[3]<<16)>>>0) + ((bytes[4]<<8)>>>0) + bytes[5]; decoded.lon = (decoded.lon / 16777215.0 360) - 180; var altValue = ((bytes[6]<<8)>>>0) + bytes[7]; var sign = bytes[6] & (1 << 7); if(sign) { decoded.alt = 0xFFFF0000 | altValue; } else { decoded.alt = altValue; } decoded.hdop = bytes[8] / 10.0; return decoded; }
The output on the serial monitor is TX done Waiting for GPS fix 49408992 8681883 208 717 49 8 TX done Waiting for GPS fix 49408886 8681921 188 719 49 8 TX done Waiting for GPS fix 49408520 8682020 128 726
..but the console receives e.g. the following paylod:
343934303936343320383638313732362033303820373131
which is resolved into:
{ "alt": 13363, "hdop": 3.2, "lat": -53.28038473608403, "lon": -112.1857268920974 }
I guess it is just a small typo in the decoder function.
(I took the source code from the ascii example, but the decoder function was only in the binary folder)
Kind regards,
Daniel
You are actually using the wrong example code for that decoder function. You are transmitting the coordinates as ascii, not as binary. If you switch to the binary example the decoder will work fine.
Hi,
I use the following decoder function from you:
function Decoder(bytes, port) { // Decode an uplink message from a buffer // (array) of bytes to an object of fields. var decoded = {}; // if (port === 1) decoded.led = bytes[0]; decoded.lat = ((bytes[0]<<16)>>>0) + ((bytes[1]<<8)>>>0) + bytes[2]; decoded.lat = (decoded.lat / 16777215.0 180) - 90; decoded.lon = ((bytes[3]<<16)>>>0) + ((bytes[4]<<8)>>>0) + bytes[5]; decoded.lon = (decoded.lon / 16777215.0 360) - 180; var altValue = ((bytes[6]<<8)>>>0) + bytes[7]; var sign = bytes[6] & (1 << 7); if(sign) { decoded.alt = 0xFFFF0000 | altValue; } else { decoded.alt = altValue; } decoded.hdop = bytes[8] / 10.0; return decoded; }
The output on the serial monitor is TX done Waiting for GPS fix 49408992 8681883 208 717 49 8 TX done Waiting for GPS fix 49408886 8681921 188 719 49 8 TX done Waiting for GPS fix 49408520 8682020 128 726
..but the console receives e.g. the following paylod:
343934303936343320383638313732362033303820373131
which is resolved into:
{ "alt": 13363, "hdop": 3.2, "lat": -53.28038473608403, "lon": -112.1857268920974 }
I guess it is just a small typo in the decoder function.
(I took the source code from the ascii example, but the decoder function was only in the binary folder)
Kind regards,
Daniel