Derive emergency status from squawk if not otherwise provided.
This commit is contained in:
parent
5a9350a6a1
commit
a8fe04f856
23
track.c
23
track.c
|
@ -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)) {
|
||||||
|
|
Loading…
Reference in a new issue