Strip out bad callsigns seen in ADS-B ident messages.

Same rules as apply to Comm-B - alphanumeric + space only.
This commit is contained in:
Oliver Jowett 2018-07-20 20:56:28 +01:00
parent d3448b0efb
commit b82922e81c

View file

@ -716,10 +716,18 @@ static void decodeESIdentAndCategory(struct modesMessage *mm)
mm->callsign[6] = ais_charset[getbits(me, 45, 50)];
mm->callsign[7] = ais_charset[getbits(me, 51, 56)];
mm->callsign[8] = 0;
mm->callsign_valid = 1;
// A common failure mode seems to be to intermittently send
// all zeros. Catch that here.
mm->callsign_valid = (strcmp(mm->callsign, "@@@@@@@@") != 0);
// actually valid?
for (unsigned i = 0; i < 8; ++i) {
if (!(mm->callsign[i] >= 'A' && mm->callsign[i] <= 'Z') &&
!(mm->callsign[i] >= '0' && mm->callsign[i] <= '9') &&
mm->callsign[i] != ' ') {
// Bad callsign, ignore it
mm->callsign_valid = 0;
break;
}
}
mm->category = ((0x0E - mm->metype) << 4) | mm->mesub;
mm->category_valid = 1;