Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c7c54984ba
|
|||
|
83d05fb2e9
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hamradio/aprs",
|
||||
"type": "module",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"description": "APRS (Automatic Packet Reporting System) protocol support for Typescript",
|
||||
"keywords": [
|
||||
"APRS",
|
||||
|
||||
@@ -346,10 +346,11 @@ export const decodeCommentExtras = (comment: string, withStructure: boolean = fa
|
||||
}
|
||||
|
||||
// Parse embedded telemetry in comment. Look for |ss11|, |ss1122|, |ss112233|, |ss1122334455|, or |ss1122334455!"| patterns (where ss is sequence and each pair of digits is an analog channel in base91, and optional last pair is digital channel in base91).
|
||||
if ((match = comment.match(/\|([a-z0-9]{4,14})\|/i))) {
|
||||
if ((match = comment.match(/\|([^|]+)\|/))) {
|
||||
try {
|
||||
const telemetry = decodeTelemetry(match[1]);
|
||||
extras.telemetry = telemetry;
|
||||
comment = comment.replace(match[0], "").trim();
|
||||
if (withStructure) {
|
||||
fields.push(
|
||||
{
|
||||
|
||||
@@ -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