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.
This commit is contained in:
davidbaker 2015-03-24 12:05:38 -05:00
parent f9c2896404
commit 069ebf37c7
1 changed files with 12 additions and 6 deletions

View File

@ -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;