Files
protoloon/index.js
2026-04-01 12:32:21 -06:00

55 lines
1.9 KiB
JavaScript

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, then decodes the telemetry.
async function fetchAndDecodeWsprData() {
const querier = new QuerierWsprLive();
// Parameters from your query URL:
const band = '20m';
const min = 0;
const callsign = 'VE6AZX';
const timeStart = '2026-01-06 07:00:00';
const timeEnd = ''; // An empty string means no end time
console.log("Fetching WSPR data...");
const results = await querier.SearchRegularType1(band, min, callsign, timeStart, timeEnd);
console.log(`Found ${results.length} records.`);
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;
}
fetchAndDecodeWsprData();