From 4a5b3837b460d1b6fcea99312728114c4734495a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 6 Feb 2014 17:08:34 -0800 Subject: [PATCH] altos: report 0/0/0 for APRS position when GPS is not locked We were reporting whatever the GPS device sent, even if it wasn't reporting a valid status. That's not terribly useful. Signed-off-by: Keith Packard --- src/drivers/ao_aprs.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/drivers/ao_aprs.c b/src/drivers/ao_aprs.c index 56d98437..25a651ca 100644 --- a/src/drivers/ao_aprs.c +++ b/src/drivers/ao_aprs.c @@ -515,13 +515,19 @@ static int tncComment(uint8_t *buf) */ static int tncPositionPacket(void) { - int32_t latitude = ao_gps_data.latitude; - int32_t longitude = ao_gps_data.longitude; - int32_t altitude = ao_gps_data.altitude; + int32_t latitude = 0; + int32_t longitude = 0; + int32_t altitude = 0; uint8_t *buf; - if (altitude < 0) - altitude = 0; + if (ao_gps_data.flags & AO_GPS_VALID) { + latitude = ao_gps_data.latitude; + longitude = ao_gps_data.longitude; + altitude = ao_gps_data.altitude; + if (altitude < 0) + altitude = 0; + } + altitude = (altitude * (int32_t) 10000 + (3048/2)) / (int32_t) 3048; buf = tncBuffer; -- 2.30.2