Derive emergency status from squawk if not otherwise provided.

This commit is contained in:
Oliver Jowett 2018-02-23 19:02:33 +00:00
parent 5a9350a6a1
commit a8fe04f856

23
track.c
View file

@ -879,6 +879,29 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm)
a->modeA_hit = 0; a->modeA_hit = 0;
} }
a->squawk = mm->squawk; a->squawk = mm->squawk;
// Handle 7x00 without a corresponding emergency status
if (!mm->emergency_valid) {
emergency_t squawk_emergency;
switch (mm->squawk) {
case 0x7500:
squawk_emergency = EMERGENCY_UNLAWFUL;
break;
case 0x7600:
squawk_emergency = EMERGENCY_NORDO;
break;
case 0x7700:
squawk_emergency = EMERGENCY_GENERAL;
break;
default:
squawk_emergency = EMERGENCY_NONE;
break;
}
if (squawk_emergency != EMERGENCY_NONE && accept_data(&a->emergency_valid, mm->source)) {
a->emergency = squawk_emergency;
}
}
} }
if (mm->emergency_valid && accept_data(&a->emergency_valid, mm->source)) { if (mm->emergency_valid && accept_data(&a->emergency_valid, mm->source)) {