From 6fd5098b89b6f8e102600bd9290d4fb5ba68a9b6 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 18 Mar 2026 22:43:40 +0000 Subject: [PATCH] Clear stale telemetry and add transmitter fallbacks --- templates/satellite_dashboard.html | 21 ++++++++- utils/satnogs.py | 71 +++++++++++++++++++++++++++--- 2 files changed, 86 insertions(+), 6 deletions(-) diff --git a/templates/satellite_dashboard.html b/templates/satellite_dashboard.html index eacf4dd..87d4b1f 100644 --- a/templates/satellite_dashboard.html +++ b/templates/satellite_dashboard.html @@ -666,6 +666,7 @@ if (orbitTrack) { groundMap.removeLayer(orbitTrack); orbitTrack = null; } } + clearTelemetry(); loadTransmitters(selectedSatellite); calculatePasses(); fetchCurrentTelemetry(); @@ -744,7 +745,10 @@ const visEl = document.getElementById('statVisible'); if (visEl) visEl.textContent = visibleCount; - if (!pos) return; + if (!pos) { + clearTelemetry(); + return; + } // Update telemetry panel const telLat = document.getElementById('telLat'); @@ -788,6 +792,21 @@ } } + function clearTelemetry() { + const telLat = document.getElementById('telLat'); + const telLon = document.getElementById('telLon'); + const telAlt = document.getElementById('telAlt'); + const telEl = document.getElementById('telEl'); + const telAz = document.getElementById('telAz'); + const telDist = document.getElementById('telDist'); + if (telLat) telLat.textContent = '---.----'; + if (telLon) telLon.textContent = '---.----'; + if (telAlt) telAlt.textContent = '--- km'; + if (telEl) telEl.textContent = '--.-'; + if (telAz) telAz.textContent = '---.-'; + if (telDist) telDist.textContent = '---- km'; + } + async function fetchCurrentTelemetry() { const lat = parseFloat(document.getElementById('obsLat')?.value); const lon = parseFloat(document.getElementById('obsLon')?.value); diff --git a/utils/satnogs.py b/utils/satnogs.py index f97841c..b195971 100644 --- a/utils/satnogs.py +++ b/utils/satnogs.py @@ -28,6 +28,63 @@ _prefetch_started = False _SATNOGS_URL = "https://db.satnogs.org/api/transmitters/?format=json" _REQUEST_TIMEOUT = 6 # seconds +_BUILTIN_TRANSMITTERS: dict[int, list[dict]] = { + 25544: [ + { + "description": "APRS digipeater", + "downlink_low": 145.825, + "downlink_high": 145.825, + "uplink_low": None, + "uplink_high": None, + "mode": "FM AX.25", + "baud": 1200, + "status": "active", + "type": "beacon", + "service": "Packet", + }, + { + "description": "SSTV events", + "downlink_low": 145.800, + "downlink_high": 145.800, + "uplink_low": None, + "uplink_high": None, + "mode": "FM", + "baud": None, + "status": "active", + "type": "image", + "service": "SSTV", + }, + ], + 57166: [ + { + "description": "Meteor LRPT weather downlink", + "downlink_low": 137.900, + "downlink_high": 137.900, + "uplink_low": None, + "uplink_high": None, + "mode": "LRPT", + "baud": 72000, + "status": "active", + "type": "image", + "service": "Weather", + }, + ], + 59051: [ + { + "description": "Meteor LRPT weather downlink", + "downlink_low": 137.900, + "downlink_high": 137.900, + "uplink_low": None, + "uplink_high": None, + "mode": "LRPT", + "baud": 72000, + "status": "active", + "type": "image", + "service": "Weather", + }, + ], +} + # --------------------------------------------------------------------------- # Internal helpers @@ -125,10 +182,12 @@ def get_transmitters(norad_id: int) -> list[dict]: with _fetch_lock: age = time.time() - _fetched_at if not _transmitters or age > _CACHE_TTL: - _transmitters = fetch_transmitters() - _fetched_at = time.time() + fetched = fetch_transmitters() + if fetched: + _transmitters = fetched + _fetched_at = time.time() - return _transmitters.get(int(norad_id), []) + return _transmitters.get(int(norad_id), _BUILTIN_TRANSMITTERS.get(int(norad_id), [])) def refresh_transmitters() -> int: @@ -141,8 +200,10 @@ def refresh_transmitters() -> int: global _transmitters, _fetched_at # noqa: PLW0603 with _fetch_lock: - _transmitters = fetch_transmitters() - _fetched_at = time.time() + fetched = fetch_transmitters() + if fetched: + _transmitters = fetched + _fetched_at = time.time() return len(_transmitters)