From 069ebf37c7634d8f2ba25aab958de583320f08d6 Mon Sep 17 00:00:00 2001 From: davidbaker Date: Tue, 24 Mar 2015 12:05:38 -0500 Subject: [PATCH] Only send messages that have the LatLon updated. Before we send messages if the LatLon or Altitude/Direction was updated. One of the values was stale. Now the LatLon will be very accurate but the Altitude can be very stale. --- net_io.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/net_io.c b/net_io.c index 7c35958..7a701e4 100644 --- a/net_io.c +++ b/net_io.c @@ -1025,7 +1025,7 @@ void modesReadFromClients(void) { void showFlightsFATSV(void) { struct aircraft *a = Modes.aircrafts; - time_t now = time(NULL); + time_t now = time(NULL), seen; int age, emittedSecondsAgo; static time_t lastTime = 0; char msg[TSV_BUFFER_SIZE], *p = msg; @@ -1054,11 +1054,17 @@ void showFlightsFATSV(void) { continue; } - age = (int)(now - a->seen); - emittedSecondsAgo = (int)(now - a->fatsv_last_emitted); + // ADSB messages have seenLatLon set, Mode A/C never set seenLatLon + if (a->seenLatLon == 0) { + seen = a->seen; + } else { + seen = a->seenLatLon; + } + age = (int)(seen - a->fatsv_last_emitted); + emittedSecondsAgo = (int)(seen - a->fatsv_last_emitted); // don't emit if it hasn't updated since last time - if (age > emittedSecondsAgo) { + if (age == 0) { continue; } @@ -1117,7 +1123,7 @@ void showFlightsFATSV(void) { } } - p += sprintf(p, "clock\t%ld\thexid\t%06X", a->seen, a->addr); + p += sprintf(p, "clock\t%ld\thexid\t%06X", seen, a->addr); // if ((a->bFlags & MODES_ACFLAGS_CALLSIGN_VALID) && *a->flight != '\0') { if (*a->flight != '\0') { @@ -1173,7 +1179,7 @@ void showFlightsFATSV(void) { p += sprintf(p, "\n"); - a->fatsv_last_emitted = now; + a->fatsv_last_emitted = seen; a->fatsv_emitted_altitude = alt; a->fatsv_emitted_track = a->track;