use accept_data for setting position_valid

Check the return value from accept_data to determine if we want to
use the decoded position.
Avoid a position from local CPR with a synthetic MLAT message being used
when the position may still be valid and either odd or even CPR already
stale allowing the MLAT CPR to be used.
Set the position expiration correctly for global surface CPR, the
previous code could have an up to 50 second old CPR being used, which
would result in combine_validity setting an expiry time for the position
only 10 seconds in the future.
This commit is contained in:
Matthias Wirth 2019-10-19 22:52:57 +02:00
parent aa2b205481
commit f67a31823b
1 changed files with 10 additions and 11 deletions

21
track.c
View File

@ -543,8 +543,12 @@ static void updatePosition(struct aircraft *a, struct modesMessage *mm)
// Nonfatal, try again later.
Modes.stats_current.cpr_global_skipped++;
} else {
Modes.stats_current.cpr_global_ok++;
combine_validity(&a->position_valid, &a->cpr_even_valid, &a->cpr_odd_valid);
if (accept_data(&a->position_valid, mm->source)) {
Modes.stats_current.cpr_global_ok++;
} else {
Modes.stats_current.cpr_global_skipped++;
location_result = -2;
}
}
}
@ -552,17 +556,12 @@ static void updatePosition(struct aircraft *a, struct modesMessage *mm)
if (location_result == -1) {
location_result = doLocalCPR(a, mm, &new_lat, &new_lon, &new_nic, &new_rc);
if (location_result < 0) {
Modes.stats_current.cpr_local_skipped++;
} else {
if (location_result == 0 && accept_data(&a->position_valid, mm->source)) {
Modes.stats_current.cpr_local_ok++;
mm->cpr_relative = 1;
if (mm->cpr_odd) {
a->position_valid = a->cpr_odd_valid;
} else {
a->position_valid = a->cpr_even_valid;
}
} else {
Modes.stats_current.cpr_local_skipped++;
location_result = -1;
}
}