Implemented Query, Telemetry, Weather and RawGPS parsing

This commit is contained in:
2026-03-15 21:13:12 +01:00
parent e0d4844c5b
commit eca757b24f
7 changed files with 714 additions and 19 deletions

View File

@@ -0,0 +1,37 @@
import { describe, it, expect } from "vitest";
import { Frame } from "../src/frame";
import { WeatherPayload } from "../src/frame.types";
import { Dissected } from "@hamradio/packet";
describe("Frame decode - Weather", () => {
it("parses weather with timestamp, wind, temp, rain, humidity and pressure", () => {
const data = "SRC>DEST:_120345z180/10g15t072r000p025P050h50b10132";
const frame = Frame.fromString(data);
const payload = frame.decode() as WeatherPayload;
expect(payload).not.toBeNull();
expect(payload.type).toBe("weather");
expect(payload.timestamp).toBeDefined();
expect(payload.windDirection).toBe(180);
expect(payload.windSpeed).toBe(10);
expect(payload.windGust).toBe(15);
expect(payload.temperature).toBe(72);
expect(payload.rainLast24Hours).toBe(25);
expect(payload.rainSinceMidnight).toBe(50);
expect(payload.humidity).toBe(50);
expect(payload.pressure).toBe(10132);
});
it("emits structure when requested", () => {
const data = "SRC>DEST:_120345z180/10g15t072r000p025P050h50b10132";
const frame = Frame.fromString(data);
const res = frame.decode(true) as {
payload: WeatherPayload;
structure: Dissected;
};
expect(res.payload).not.toBeNull();
expect(Array.isArray(res.structure)).toBe(true);
const names = res.structure.map((s) => s.name);
expect(names).toContain("timestamp");
expect(names).toContain("weather");
});
});