From 5a33b4ee8fc52f938939215f25a677a3283d6048 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Thu, 18 Feb 2021 13:53:01 +0800 Subject: [PATCH] Set at least airground = AG_UNCERTAIN for airborne position messages with valid altitudes. DF18 messages don't have a CA field so we can't set airground from that. That meant that aircraft tracking wouldn't update airground state at all from a DF18 airborne position message, even if the existing tracked airground state was stale. It seems reasonable to set at least AG_UNCERTAIN if we're seeing airborne positions with valid altitude data. Fixes github issue #113 --- mode_s.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mode_s.c b/mode_s.c index fea0bfa..13ac0d8 100644 --- a/mode_s.c +++ b/mode_s.c @@ -1039,6 +1039,11 @@ static void decodeESAirbornePosition(struct modesMessage *mm, int check_imf) altitude_unit_t unit; int alt = decodeAC12Field(AC12Field, &unit); if (alt != INVALID_ALTITUDE) { + // If we haven't set airground yet (e.g. DF18) + // then we can at least set it to UNCERTAIN here + if (mm->airground == AG_INVALID) + mm->airground = AG_UNCERTAIN; + if (mm->metype == 20 || mm->metype == 21 || mm->metype == 22) { mm->altitude_geom = alt; mm->altitude_geom_unit = unit;