mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
Fix false emergency alerts and ACARS compatibility
- Fix emergency alerts triggering for non-emergency squawk codes (VFR 1200/7000, etc.) by checking squawkInfo.type === 'emergency' before alerting - Fix emergency filter to only show actual emergency squawk codes - Add acarsdec version detection to support both -j (newer) and -o 4 (older) JSON flags Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,28 @@ def find_acarsdec():
|
||||
return shutil.which('acarsdec')
|
||||
|
||||
|
||||
def get_acarsdec_json_flag(acarsdec_path: str) -> str:
|
||||
"""Detect which JSON output flag acarsdec supports.
|
||||
|
||||
Newer forks (TLeconte) use -j, older versions use -o 4.
|
||||
"""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[acarsdec_path, '-h'],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5
|
||||
)
|
||||
help_text = result.stdout + result.stderr
|
||||
# Check if -j flag is documented in help
|
||||
if ' -j' in help_text or '\n-j' in help_text:
|
||||
return '-j'
|
||||
except Exception:
|
||||
pass
|
||||
# Default to older -o 4 syntax
|
||||
return '-o'
|
||||
|
||||
|
||||
def stream_acars_output(process: subprocess.Popen, is_text_mode: bool = False) -> None:
|
||||
"""Stream acarsdec JSON output to queue."""
|
||||
global acars_message_count, acars_last_message_time
|
||||
@@ -179,10 +201,12 @@ def start_acars() -> Response:
|
||||
# acarsdec -j -g <gain> -p <ppm> -r <device> <freq1> <freq2> ...
|
||||
# Note: -j is JSON stdout (newer forks), -o 4 was the old syntax
|
||||
# gain/ppm must come BEFORE -r
|
||||
cmd = [
|
||||
acarsdec_path,
|
||||
'-j', # JSON output to stdout
|
||||
]
|
||||
json_flag = get_acarsdec_json_flag(acarsdec_path)
|
||||
cmd = [acarsdec_path]
|
||||
if json_flag == '-j':
|
||||
cmd.append('-j') # JSON output (newer TLeconte fork)
|
||||
else:
|
||||
cmd.extend(['-o', '4']) # JSON output (older versions)
|
||||
|
||||
# Add gain if not auto (must be before -r)
|
||||
if gain and str(gain) != '0':
|
||||
|
||||
@@ -540,7 +540,7 @@
|
||||
const squawkInfo = checkSquawkCode(ac);
|
||||
const onWatchlist = isOnWatchlist(ac);
|
||||
|
||||
if (squawkInfo) {
|
||||
if (squawkInfo && squawkInfo.type === 'emergency') {
|
||||
alertedAircraft[icao] = 'emergency';
|
||||
playAlertSound('emergency');
|
||||
showAlertBanner(`EMERGENCY: ${squawkInfo.name} - ${ac.callsign || icao}`, '#ff0000');
|
||||
@@ -1905,7 +1905,7 @@ ACARS: ${r.statistics.acarsMessages} messages`;
|
||||
const squawkInfo = checkSquawkCode(ac);
|
||||
if (currentFilter === 'military') return militaryInfo.military;
|
||||
if (currentFilter === 'civil') return !militaryInfo.military;
|
||||
if (currentFilter === 'emergency') return !!squawkInfo;
|
||||
if (currentFilter === 'emergency') return squawkInfo && squawkInfo.type === 'emergency';
|
||||
if (currentFilter === 'watchlist') return isOnWatchlist(ac);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user