Major change: switched to DataType enum

This commit is contained in:
2026-03-15 22:57:19 +01:00
parent 074806528f
commit c300aefc0b
7 changed files with 260 additions and 216 deletions

View File

@@ -14,54 +14,51 @@ export interface IFrame {
}
// APRS Data Type Identifiers (first character of payload)
export const DataTypeIdentifier = {
export enum DataType {
// Position Reports
PositionNoTimestampNoMessaging: "!",
PositionNoTimestampWithMessaging: "=",
PositionWithTimestampNoMessaging: "/",
PositionWithTimestampWithMessaging: "@",
PositionNoTimestampNoMessaging = "!",
PositionNoTimestampWithMessaging = "=",
PositionWithTimestampNoMessaging = "/",
PositionWithTimestampWithMessaging = "@",
// Mic-E
MicECurrent: "`",
MicEOld: "'",
MicECurrent = "`",
MicEOld = "'",
// Messages and Bulletins
Message: ":",
Message = ":",
// Objects and Items
Object: ";",
Item: ")",
Object = ";",
Item = ")",
// Status
Status: ">",
Status = ">",
// Query
Query: "?",
Query = "?",
// Telemetry
TelemetryData: "T",
TelemetryData = "T",
// Weather
WeatherReportNoPosition: "_",
WeatherReportNoPosition = "_",
// Raw GPS Data
RawGPS: "$",
RawGPS = "$",
// Station Capabilities
StationCapabilities: "<",
StationCapabilities = "<",
// User-Defined
UserDefined: "{",
UserDefined = "{",
// Third-Party Traffic
ThirdParty: "}",
ThirdParty = "}",
// Invalid/Test Data
InvalidOrTest: ",",
} as const;
export type DataTypeIdentifier =
(typeof DataTypeIdentifier)[keyof typeof DataTypeIdentifier];
InvalidOrTest = ",",
}
export interface ISymbol {
table: string; // Symbol table identifier
@@ -99,7 +96,11 @@ export interface ITimestamp {
// Position Report Payload
export interface PositionPayload {
type: "position";
type:
| DataType.PositionNoTimestampNoMessaging
| DataType.PositionNoTimestampWithMessaging
| DataType.PositionWithTimestampNoMessaging
| DataType.PositionWithTimestampWithMessaging;
timestamp?: ITimestamp;
position: IPosition;
messaging: boolean; // Whether APRS messaging is enabled
@@ -128,19 +129,20 @@ export interface CompressedPosition {
// Mic-E Payload (compressed in destination address)
export interface MicEPayload {
type: "mic-e";
type: DataType.MicECurrent | DataType.MicEOld;
position: IPosition;
course?: number;
speed?: number;
altitude?: number;
messageType?: string; // Standard Mic-E message
isStandard?: boolean; // Whether messageType is a standard Mic-E message
telemetry?: number[]; // Optional telemetry channels
status?: string;
}
export type MessageVariant = "message" | "bulletin";
// Message Payload
export interface MessagePayload {
type: "message";
type: DataType.Message;
variant: "message";
addressee: string; // 9 character padded callsign
text: string; // Message text
messageNumber?: string; // Message ID for acknowledgment
@@ -150,7 +152,8 @@ export interface MessagePayload {
// Bulletin/Announcement (variant of message)
export interface BulletinPayload {
type: "bulletin";
type: DataType.Message;
variant: "bulletin";
bulletinId: string; // Bulletin identifier (BLN#)
text: string;
group?: string; // Optional group bulletin
@@ -158,7 +161,7 @@ export interface BulletinPayload {
// Object Payload
export interface ObjectPayload {
type: "object";
type: DataType.Object;
name: string; // 9 character object name
timestamp: ITimestamp;
alive: boolean; // True if object is active, false if killed
@@ -169,7 +172,7 @@ export interface ObjectPayload {
// Item Payload
export interface ItemPayload {
type: "item";
type: DataType.Item;
name: string; // 3-9 character item name
alive: boolean; // True if item is active, false if killed
position: IPosition;
@@ -177,7 +180,7 @@ export interface ItemPayload {
// Status Payload
export interface StatusPayload {
type: "status";
type: DataType.Status;
timestamp?: ITimestamp;
text: string;
maidenhead?: string; // Optional Maidenhead grid locator
@@ -189,14 +192,22 @@ export interface StatusPayload {
// Query Payload
export interface QueryPayload {
type: "query";
type: DataType.Query;
queryType: string; // e.g., 'APRSD', 'APRST', 'PING'
target?: string; // Target callsign or area
}
export type TelemetryVariant =
| "data"
| "parameters"
| "unit"
| "coefficients"
| "bitsense";
// Telemetry Data Payload
export interface TelemetryDataPayload {
type: "telemetry-data";
type: DataType.TelemetryData;
variant: "data";
sequence: number;
analog: number[]; // Up to 5 analog channels
digital: number; // 8-bit digital value
@@ -204,19 +215,22 @@ export interface TelemetryDataPayload {
// Telemetry Parameter Names
export interface TelemetryParameterPayload {
type: "telemetry-parameters";
type: DataType.TelemetryData;
variant: "parameters";
names: string[]; // Parameter names
}
// Telemetry Unit/Label
export interface TelemetryUnitPayload {
type: "telemetry-units";
type: DataType.TelemetryData;
variant: "unit";
units: string[]; // Units for each parameter
}
// Telemetry Coefficients
export interface TelemetryCoefficientsPayload {
type: "telemetry-coefficients";
type: DataType.TelemetryData;
variant: "coefficients";
coefficients: {
a: number[]; // a coefficients
b: number[]; // b coefficients
@@ -226,14 +240,15 @@ export interface TelemetryCoefficientsPayload {
// Telemetry Bit Sense/Project Name
export interface TelemetryBitSensePayload {
type: "telemetry-bitsense";
type: DataType.TelemetryData;
variant: "bitsense";
sense: number; // 8-bit sense value
projectName?: string;
}
// Weather Report Payload
export interface WeatherPayload {
type: "weather";
type: DataType.WeatherReportNoPosition;
timestamp?: ITimestamp;
position?: IPosition;
windDirection?: number; // Degrees
@@ -255,34 +270,33 @@ export interface WeatherPayload {
// Raw GPS Payload (NMEA sentences)
export interface RawGPSPayload {
type: "raw-gps";
type: DataType.RawGPS;
sentence: string; // Raw NMEA sentence
position?: IPosition; // Optional parsed position if available
}
// Station Capabilities Payload
export interface StationCapabilitiesPayload {
type: "capabilities";
type: DataType.StationCapabilities;
capabilities: string[];
}
// User-Defined Payload
export interface UserDefinedPayload {
type: "user-defined";
type: DataType.UserDefined;
userPacketType: string;
data: string;
}
// Third-Party Traffic Payload
export interface ThirdPartyPayload {
type: "third-party";
type: DataType.ThirdParty;
frame?: IFrame; // Optional nested frame if payload contains another APRS frame
comment?: string; // Optional comment
}
// DF Report Payload
export interface DFReportPayload {
type: "df-report";
timestamp?: ITimestamp;
position: IPosition;
course?: number;
@@ -295,7 +309,7 @@ export interface DFReportPayload {
}
export interface BasePayload {
type: string;
type: DataType;
}
// Union type for all decoded payload types
@@ -319,7 +333,6 @@ export type Payload = BasePayload &
| StationCapabilitiesPayload
| UserDefinedPayload
| ThirdPartyPayload
| DFReportPayload
);
// Extended Frame with decoded payload