altos: report 0/0/0 for APRS position when GPS is not locked
authorKeith Packard <keithp@keithp.com>
Fri, 7 Feb 2014 01:08:34 +0000 (17:08 -0800)
committerKeith Packard <keithp@keithp.com>
Fri, 7 Feb 2014 01:08:34 +0000 (17:08 -0800)
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 <keithp@keithp.com>
src/drivers/ao_aprs.c

index 56d984375ba82f725875cddd1cc921e74c285aa5..25a651ca3a836ac4eb9593606a84ced0be9856a6 100644 (file)
@@ -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;