Clear stale telemetry and add transmitter fallbacks

This commit is contained in:
James Smith
2026-03-18 22:43:40 +00:00
parent 6941e704cd
commit 6fd5098b89
2 changed files with 86 additions and 6 deletions

View File

@@ -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);

View File

@@ -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)