From 8d8443f3dc95dc84b238282a69e45668af98f366 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Wed, 14 Sep 2016 16:54:00 +0100 Subject: [PATCH] Track the "best" addrtype we ever saw for an aircraft. --- dump1090.h | 15 ++++++++++----- track.c | 5 +++++ track.h | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/dump1090.h b/dump1090.h index 02bb43d..c9c7d9c 100644 --- a/dump1090.h +++ b/dump1090.h @@ -149,16 +149,21 @@ typedef enum { SOURCE_ADSB, /* data from a ADS-B extended squitter message */ } datasource_t; -/* What sort of address is this and who sent it? */ +/* What sort of address is this and who sent it? + * (Earlier values are higher priority) + */ typedef enum { ADDR_ADSB_ICAO, /* ADS-B, ICAO address, transponder sourced */ ADDR_ADSB_ICAO_NT, /* ADS-B, ICAO address, non-transponder */ - ADDR_ADSB_OTHER, /* ADS-B, other address format, non-transponder */ - ADDR_TISB_ICAO, /* TIS-B, ICAO address */ - ADDR_TISB_OTHER, /* TIS-B, other address format */ - ADDR_TISB_ANON, /* ADS-R/TIS-B, anonymized address */ ADDR_ADSR_ICAO, /* ADS-R, ICAO address */ + ADDR_TISB_ICAO, /* TIS-B, ICAO address */ + + ADDR_ADSB_OTHER, /* ADS-B, other address format, non-transponder */ ADDR_ADSR_OTHER, /* ADS-R, other address format */ + ADDR_TISB_OTHER, /* TIS-B, other address format */ + + ADDR_TISB_ANON, /* ADS-R/TIS-B, anonymized address */ + ADDR_UNKNOWN /* unknown address format */ } addrtype_t; diff --git a/track.c b/track.c index 7fc8734..7fff6f7 100644 --- a/track.c +++ b/track.c @@ -66,6 +66,7 @@ struct aircraft *trackCreateAircraft(struct modesMessage *mm) { // Now initialise things that should not be 0/NULL to their defaults a->addr = mm->addr; + a->addrtype = mm->addrtype; for (i = 0; i < 8; ++i) a->signalLevel[i] = 1e-5; a->signalNext = 0; @@ -534,6 +535,10 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm) a->seen = now; a->messages++; + // update addrtype, we only ever go towards "more direct" types + if (mm->addrtype < a->addrtype) + a->addrtype = mm->addrtype; + if (mm->altitude_valid && mm->altitude_source == ALTITUDE_BARO && accept_data(&a->altitude_valid, mm->source, now)) { unsigned modeC = (a->altitude + 49) / 100; if (modeC != a->altitude_modeC) { diff --git a/track.h b/track.h index 1cab266..574c29f 100644 --- a/track.h +++ b/track.h @@ -69,6 +69,7 @@ typedef struct { /* Structure used to describe the state of one tracked aircraft */ struct aircraft { uint32_t addr; // ICAO address + addrtype_t addrtype; // highest priority address type seen for this aircraft uint64_t seen; // Time (millis) at which the last packet was received long messages; // Number of Mode S messages received