helium / longfi-arduino

Apache License 2.0
62 stars 48 forks source link

Uplink Integration Response Error when trying to send mapping data to https://mappers.helium.com/api/v1/ingest/uplink #38

Closed mauricecyril closed 2 years ago

mauricecyril commented 3 years ago

Trying to use a TTGO v1.1 and I'm able to successfully send packets, however all my uplink responses are returning errors.

In the Helium Console I've setup the following integration https://mappers.helium.com/api/v1/ingest/uplink

For the function I've followed https://github.com/helium/longfi-arduino/tree/master/TTGO-TBeam-Tracker and applied the following decoder function https://github.com/helium/longfi-arduino/blob/master/TTGO-TBeam-Tracker/console-decoders/mapper_decoder.js

The arduino code contains: if (0 < gps_hdop() && gps_hdop() < 50 && gps_latitude() != 0 && gps_longitude() != 0 && gps_altitude() != 0) { char buffer[40]; snprintf(buffer, sizeof(buffer), "Latitude: %10.6f\n", gps_latitude()); screen_print(buffer); snprintf(buffer, sizeof(buffer), "Longitude: %10.6f\n", gps_longitude()); screen_print(buffer); snprintf(buffer, sizeof(buffer), "Error: %4.2fm\n", gps_hdop()); screen_print(buffer);

buildPacket(txBuffer);
mauricecyril commented 3 years ago

Was able to resolve this by changing the console function slightly. decoded.hdop = bytes[8] / 10.0; has to be changed to decoded.accuracy = bytes[8] / 10.0;

` 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.accuracy = bytes[8] / 10.0;
decoded.sats = bytes[9];

return decoded;

} `