Correctly decode all embedded telemetry data
This commit is contained in:
@@ -2,7 +2,7 @@ import type { Dissected, Field, Segment } from "@hamradio/packet";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { Frame } from "../src/frame";
|
||||
import type { PositionPayload } from "../src/frame.types";
|
||||
import { DataType, type ObjectPayload, type PositionPayload } from "../src/frame.types";
|
||||
import { feetToMeters, milesToMeters } from "../src/parser";
|
||||
import { decodeTelemetry } from "../src/payload.extras";
|
||||
|
||||
@@ -133,8 +133,7 @@ describe("APRS extras test vectors", () => {
|
||||
it("parses combined tokens: DDD/SSS PHG and DFS", () => {
|
||||
const raw = "N0CALL>APRS,WIDE1-1:!4500.00N/07000.00W>090/045PHG5132DFS2132";
|
||||
const frame = Frame.fromString(raw);
|
||||
const res = frame.decode(true) as { payload: PositionPayload | null; structure: Dissected };
|
||||
const { payload, structure } = res;
|
||||
const { payload, structure } = frame.decode(true) as { payload: PositionPayload | null; structure: Dissected };
|
||||
|
||||
expect(payload).not.toBeNull();
|
||||
expect(payload!.position.course).toBe(90);
|
||||
@@ -221,4 +220,22 @@ describe("decodeTelemetry", () => {
|
||||
it("throws on invalid base91", () => {
|
||||
expect(() => decodeTelemetry("ss11~~")).toThrow();
|
||||
});
|
||||
|
||||
it("decodes telemetry test vector", () => {
|
||||
const result = decodeTelemetry("$T%R#`");
|
||||
expect(result.sequence).toBe(324);
|
||||
expect(result.analog).toEqual([413, 245]);
|
||||
expect(result.digital).toBeUndefined();
|
||||
});
|
||||
|
||||
it("decodes test vector with embedded telemetry", () => {
|
||||
const raw = "N0CALL-11>APLRFT,qAR,N0CALL-10:!\\45;<P(6y>HIGLoRa APRS Tracker|$T%R#`|";
|
||||
const frame = Frame.fromString(raw);
|
||||
const { payload } = frame.decode(true) as { payload: ObjectPayload | null; structure: Dissected };
|
||||
|
||||
expect(payload).not.toBeNull();
|
||||
expect(payload!.type).toBe(DataType.PositionNoTimestampNoMessaging);
|
||||
expect(payload!.position).toBeDefined();
|
||||
expect(payload!.position.comment).toBe("LoRa APRS Tracker");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user