Don't emit stale alt/speed/track/pos (more than 30s old) even if

they were updated since we last emitted a message.
This commit is contained in:
Oliver Jowett 2015-06-16 01:38:44 +01:00
parent 4f861f653a
commit 7d4eaf6a48

View file

@ -1458,9 +1458,9 @@ static void writeFATSV() {
emittedAge = (now - a->fatsv_last_emitted); emittedAge = (now - a->fatsv_last_emitted);
if (a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) { if (a->bFlags & MODES_ACFLAGS_ALTITUDE_VALID) {
altValid = 1;
alt = a->altitude; alt = a->altitude;
altAge = now - a->seenAltitude; altAge = now - a->seenAltitude;
altValid = (altAge <= 30000);
} }
if (a->bFlags & MODES_ACFLAGS_AOG_VALID) { if (a->bFlags & MODES_ACFLAGS_AOG_VALID) {
@ -1476,18 +1476,18 @@ static void writeFATSV() {
} }
if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) { if (a->bFlags & MODES_ACFLAGS_LATLON_VALID) {
latlonValid = 1;
latlonAge = now - a->seenLatLon; latlonAge = now - a->seenLatLon;
latlonValid = (latlonAge <= 30000);
} }
if (a->bFlags & MODES_ACFLAGS_HEADING_VALID) { if (a->bFlags & MODES_ACFLAGS_HEADING_VALID) {
trackValid = 1;
trackAge = now - a->seenTrack; trackAge = now - a->seenTrack;
trackValid = (trackAge <= 30000);
} }
if (a->bFlags & MODES_ACFLAGS_SPEED_VALID) { if (a->bFlags & MODES_ACFLAGS_SPEED_VALID) {
speedValid = 1;
speedAge = now - a->seenSpeed; speedAge = now - a->seenSpeed;
speedValid = (speedAge <= 30000);
} }
// don't send mode S very often // don't send mode S very often
@ -1539,6 +1539,7 @@ static void writeFATSV() {
} }
// only emit alt, speed, latlon, track if they have been received since the last time // only emit alt, speed, latlon, track if they have been received since the last time
// and are not stale
if (altValid && altAge < emittedAge) { if (altValid && altAge < emittedAge) {
p += snprintf(p, bufsize(p,end), "\talt\t%d", alt); p += snprintf(p, bufsize(p,end), "\talt\t%d", alt);