Fix up address type categorization to match the spec.

This commit is contained in:
Oliver Jowett 2016-09-15 15:30:34 +01:00
parent 7c1fed98d2
commit 729d91c1ab
3 changed files with 36 additions and 32 deletions

View file

@ -158,12 +158,11 @@ typedef enum {
ADDR_ADSR_ICAO, /* ADS-R, ICAO address */ ADDR_ADSR_ICAO, /* ADS-R, ICAO address */
ADDR_TISB_ICAO, /* TIS-B, ICAO address */ ADDR_TISB_ICAO, /* TIS-B, ICAO address */
ADDR_ADSB_OTHER, /* ADS-B, other address format, non-transponder */ ADDR_ADSB_OTHER, /* ADS-B, other address format */
ADDR_ADSR_OTHER, /* ADS-R, other address format */ ADDR_ADSR_OTHER, /* ADS-R, other address format */
ADDR_TISB_TRACKFILE, /* TIS-B, Mode A code + track file number */
ADDR_TISB_OTHER, /* TIS-B, 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 */ ADDR_UNKNOWN /* unknown address format */
} addrtype_t; } addrtype_t;

View file

@ -796,11 +796,12 @@ static void setIMF(struct modesMessage *mm)
switch (mm->addrtype) { switch (mm->addrtype) {
case ADDR_ADSB_ICAO: case ADDR_ADSB_ICAO:
case ADDR_ADSB_ICAO_NT: case ADDR_ADSB_ICAO_NT:
// Shouldn't happen, but let's try to handle it
mm->addrtype = ADDR_ADSB_OTHER; mm->addrtype = ADDR_ADSB_OTHER;
break; break;
case ADDR_TISB_ICAO: case ADDR_TISB_ICAO:
mm->addrtype = ADDR_TISB_OTHER; mm->addrtype = ADDR_TISB_TRACKFILE;
break; break;
case ADDR_ADSR_ICAO: case ADDR_ADSR_ICAO:
@ -1164,39 +1165,43 @@ static void decodeExtendedSquitter(struct modesMessage *mm)
// Check CF on DF18 to work out the format of the ES and whether we need to look for an IMF bit // Check CF on DF18 to work out the format of the ES and whether we need to look for an IMF bit
if (mm->msgtype == 18) { if (mm->msgtype == 18) {
switch (mm->CF) { switch (mm->CF) {
case 0: // ADS-B ES/NT devices that report the ICAO 24-bit address in the AA field case 0: // ADS-B Message from a non-transponder device, AA field holds 24-bit ICAO aircraft address
mm->addrtype = ADDR_ADSB_ICAO_NT; mm->addrtype = ADDR_ADSB_ICAO_NT;
break; break;
case 1: // Reserved for ADS-B for ES/NT devices that use other addressing techniques in the AA field case 1: // Reserved for ADS-B Message in which the AA field holds anonymous address or ground vehicle address or fixed obstruction address
mm->addrtype = ADDR_ADSB_OTHER; mm->addrtype = ADDR_ADSB_OTHER;
mm->addr |= MODES_NON_ICAO_ADDRESS; mm->addr |= MODES_NON_ICAO_ADDRESS;
break; break;
case 2: // Fine TIS-B message (formats are close enough to DF17 for our purposes) case 2: // Fine TIS-B Message
// IMF=0: AA field contains the 24-bit ICAO aircraft address
// IMF=1: AA field contains the 12-bit Mode A code followed by a 12-bit track file number
mm->source = SOURCE_TISB; mm->source = SOURCE_TISB;
mm->addrtype = ADDR_TISB_ICAO; mm->addrtype = ADDR_TISB_ICAO;
check_imf = 1; check_imf = 1;
break; break;
case 3: // Coarse TIS-B airborne position and velocity. case 3: // Coarse TIS-B airborne position and velocity.
// TODO: decode me. // IMF=0: AA field contains the 24-bit ICAO aircraft address
// IMF=1: AA field contains the 12-bit Mode A code followed by a 12-bit track file number
// For now we only look at the IMF bit. // For now we only look at the IMF bit.
mm->source = SOURCE_TISB; mm->source = SOURCE_TISB;
mm->addrtype = ADDR_TISB_ICAO; mm->addrtype = ADDR_TISB_ICAO;
if (getbit(me, 1)) { if (getbit(me, 1))
mm->addr |= MODES_NON_ICAO_ADDRESS; setIMF(mm);
mm->addrtype = ADDR_TISB_OTHER;
}
return; return;
case 5: // TIS-B messages that relay ADS-B Messages using anonymous 24-bit addresses (format not explicitly defined, but it seems to follow DF17) case 5: // Fine TIS-B Message, AA field contains a non-ICAO 24-bit address
mm->addrtype = ADDR_TISB_ANON; mm->addrtype = ADDR_TISB_OTHER;
mm->source = SOURCE_TISB; mm->source = SOURCE_TISB;
mm->addr |= MODES_NON_ICAO_ADDRESS; mm->addr |= MODES_NON_ICAO_ADDRESS;
break; break;
case 6: // ADS-B rebroadcast using the same type codes and message formats as defined for DF = 17 ADS-B messages case 6: // Rebroadcast of ADS-B Message from an alternate data link
// IMF=0: AA field holds 24-bit ICAO aircraft address
// IMF=1: AA field holds anonymous address or ground vehicle address or fixed obstruction address
mm->addrtype = ADDR_ADSR_ICAO; mm->addrtype = ADDR_ADSR_ICAO;
check_imf = 1; check_imf = 1;
break; break;
@ -1370,8 +1375,8 @@ static const char *addrtype_to_string(addrtype_t type) {
return "TIS-B"; return "TIS-B";
case ADDR_TISB_OTHER: case ADDR_TISB_OTHER:
return "TIS-B, other addressing scheme"; return "TIS-B, other addressing scheme";
case ADDR_TISB_ANON: case ADDR_TISB_TRACKFILE:
return "TIS-B, anonymized address"; return "TIS-B, Mode A code and track file number";
case ADDR_ADSR_ICAO: case ADDR_ADSR_ICAO:
return "ADS-R"; return "ADS-R";
case ADDR_ADSR_OTHER: case ADDR_ADSR_OTHER:

View file

@ -993,18 +993,18 @@ static const char *addrtype_short_string(addrtype_t type) {
return "adsb_icao"; return "adsb_icao";
case ADDR_ADSB_ICAO_NT: case ADDR_ADSB_ICAO_NT:
return "adsb_icao_nt"; return "adsb_icao_nt";
case ADDR_ADSB_OTHER:
return "adsb_other";
case ADDR_TISB_ICAO:
return "tisb_icao";
case ADDR_TISB_OTHER:
return "tisb_other";
case ADDR_TISB_ANON:
return "tisb_anon";
case ADDR_ADSR_ICAO: case ADDR_ADSR_ICAO:
return "adsr_icao"; return "adsr_icao";
case ADDR_TISB_ICAO:
return "tisb_icao";
case ADDR_ADSB_OTHER:
return "adsb_other";
case ADDR_ADSR_OTHER: case ADDR_ADSR_OTHER:
return "adsr_other"; return "adsr_other";
case ADDR_TISB_OTHER:
return "tisb_other";
case ADDR_TISB_TRACKFILE:
return "tisb_trackfile";
default: default:
return "unknown"; return "unknown";
} }