diff --git a/src/main/telemetry/ltm.c b/src/main/telemetry/ltm.c index 90d263ce9c..40d44f13f5 100644 --- a/src/main/telemetry/ltm.c +++ b/src/main/telemetry/ltm.c @@ -130,28 +130,31 @@ static void ltm_finalise(void) static void ltm_gframe(void) { uint8_t gps_fix_type = 0; - int32_t ltm_alt; + int32_t ltm_lat = 0, ltm_lon = 0, ltm_alt = 0, ltm_gs = 0; - if (!sensors(SENSOR_GPS)) - return; + if (sensors(SENSOR_GPS)) { + if (gpsSol.fixType == GPS_NO_FIX) + gps_fix_type = 1; + else if (gpsSol.fixType == GPS_FIX_2D) + gps_fix_type = 2; + else if (gpsSol.fixType == GPS_FIX_3D) + gps_fix_type = 3; - if (gpsSol.fixType == GPS_NO_FIX) - gps_fix_type = 1; - else if (gpsSol.fixType == GPS_FIX_2D) - gps_fix_type = 2; - else if (gpsSol.fixType == GPS_FIX_3D) - gps_fix_type = 3; - - ltm_initialise_packet('G'); - ltm_serialise_32(gpsSol.llh.lat); - ltm_serialise_32(gpsSol.llh.lon); - ltm_serialise_8((uint8_t)(gpsSol.groundSpeed / 100)); + ltm_lat = gpsSol.llh.lat; + ltm_lon = gpsSol.llh.lon; + ltm_gs = gpsSol.groundSpeed / 100; + } #if defined(NAV) - ltm_alt = (sensors(SENSOR_SONAR) || sensors(SENSOR_BARO)) ? getEstimatedActualPosition(Z) : gpsSol.llh.alt; // cm + ltm_alt = getEstimatedActualPosition(Z); // cm #else - ltm_alt = gpsSol.llh.alt; // cm + ltm_alt = sensors(SENSOR_GPS) ? gpsSol.llh.alt : 0; // cm #endif + + ltm_initialise_packet('G'); + ltm_serialise_32(ltm_lat); + ltm_serialise_32(ltm_lon); + ltm_serialise_8((uint8_t)ltm_gs); ltm_serialise_32(ltm_alt); ltm_serialise_8((gpsSol.numSat << 2) | gps_fix_type); ltm_finalise();