Tweak when we allow updates to air/ground status.
This commit is contained in:
parent
571ea7ac41
commit
2ce2af1685
11
track.c
11
track.c
|
@ -940,8 +940,15 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
|
||||||
a->geom_rate = mm->geom_rate;
|
a->geom_rate = mm->geom_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mm->airground != AG_INVALID && accept_data(&a->airground_valid, mm->source)) {
|
if (mm->airground != AG_INVALID) {
|
||||||
a->airground = mm->airground;
|
// If our current state is UNCERTAIN, accept new data as normal
|
||||||
|
// If our current state is certain but new data is not, only accept the uncertain state if the certain data has gone stale
|
||||||
|
if (mm->airground != AG_UNCERTAIN ||
|
||||||
|
(mm->airground == AG_UNCERTAIN && !trackDataFresh(&a->airground_valid))) {
|
||||||
|
if (accept_data(&a->airground_valid, mm->source)) {
|
||||||
|
a->airground = mm->airground;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mm->callsign_valid && accept_data(&a->callsign_valid, mm->source)) {
|
if (mm->callsign_valid && accept_data(&a->callsign_valid, mm->source)) {
|
||||||
|
|
6
track.h
6
track.h
|
@ -259,6 +259,12 @@ static inline int trackDataValid(const data_validity *v)
|
||||||
return (v->source != SOURCE_INVALID && messageNow() < v->expires);
|
return (v->source != SOURCE_INVALID && messageNow() < v->expires);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* is this bit of data fresh? */
|
||||||
|
static inline int trackDataFresh(const data_validity *v)
|
||||||
|
{
|
||||||
|
return (v->source != SOURCE_INVALID && messageNow() < v->stale);
|
||||||
|
}
|
||||||
|
|
||||||
/* what's the age of this data, in milliseconds? */
|
/* what's the age of this data, in milliseconds? */
|
||||||
static inline uint64_t trackDataAge(const data_validity *v)
|
static inline uint64_t trackDataAge(const data_validity *v)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue