From 7b15a0eb9ce5f576f85f31cdfe6ba4cc24d8cba9 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 1 Apr 2026 12:32:21 -0600 Subject: [PATCH] feat: Add WSPR telemetry decoding and fix module paths Co-authored-by: aider (gemini/gemini-2.5-pro) --- index.js | 40 +++++++++++++++++++++++++++++++++++----- js/WsprSearch.js | 6 +++--- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 7ddbf44..633950a 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,9 @@ import { QuerierWsprLive } from './js/QuerierWsprLive.js'; +import { WSPREncoded } from './js/WSPREncoded.js'; // This function reuses your existing code to perform the same search -// as the wspr.live URL you provided. -async function fetchWsprData() { +// as the wspr.live URL you provided, then decodes the telemetry. +async function fetchAndDecodeWsprData() { const querier = new QuerierWsprLive(); // Parameters from your query URL: @@ -16,9 +17,38 @@ async function fetchWsprData() { const results = await querier.SearchRegularType1(band, min, callsign, timeStart, timeEnd); console.log(`Found ${results.length} records.`); - console.log(results); - return results; + const positions = []; + for (const record of results) { + // Decode telemetry from grid and power + const telemetry = WSPREncoded.DecodeU4BGridPower(record.grid4, record.powerDbm); + + if (telemetry.msgType === 'standard') { + // If it's standard telemetry, decode callsign for fine-grained location + const [grid56, altitudeMeters] = WSPREncoded.DecodeU4BCall(record.callsign); + + const fullGrid = record.grid4 + grid56; + + // Convert Maidenhead grid to latitude and longitude + const [lat, lng] = WSPREncoded.DecodeMaidenheadToDeg(fullGrid); + + positions.push({ + time: record.time, + callsign: record.callsign, + grid: fullGrid, + lat: lat, + lng: lng, + altitude: altitudeMeters, + powerDbm: record.powerDbm, + rxBy: record.rxCallsign, + }); + } + } + + console.log(`Decoded ${positions.length} positions.`); + console.log(positions); + + return positions; } -fetchWsprData(); +fetchAndDecodeWsprData(); diff --git a/js/WsprSearch.js b/js/WsprSearch.js index 17c9fa8..938a60d 100644 --- a/js/WsprSearch.js +++ b/js/WsprSearch.js @@ -6,7 +6,7 @@ See the /faq/tos page for details. (If this generated header is stamped on a file which is a 3rd party file or under a different license or copyright, then ignore this copyright statement and use that file's terms.) */ -import * as utl from '/js/Utl.js'; +import * as utl from './Utl.js'; import { Base } from './Base.js'; import { CandidateFilterByBadTelemetry } from './CandidateFilterByBadTelemetry.js'; @@ -19,9 +19,9 @@ import { CodecHeartbeat } from './CodecHeartbeat.js'; import { CodecExpandedBasicTelemetry } from './CodecExpandedBasicTelemetry.js'; import { CodecHighResLocation } from './CodecHighResLocation.js'; import { QuerierWsprLive } from './QuerierWsprLive.js'; -import { WSPR } from '/js/WSPR.js'; +import { WSPR } from './WSPR.js'; import { WsprCodecMaker } from '/pro/codec/WsprCodec.js'; -import { WSPREncoded } from '/js/WSPREncoded.js'; +import { WSPREncoded } from './WSPREncoded.js'; import { WsprMessageCandidate, NonRejectedOnlyFilter } from './WsprMessageCandidate.js'; import { WsprSearchResultDataTableBuilder } from './WsprSearchResultDataTableBuilder.js';