@packet-net/pdn-aprs 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -1
- package/README.md +8 -4
- package/dist/builder.d.ts +33 -8
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +64 -10
- package/dist/builder.js.map +1 -1
- package/dist/decode/index.d.ts.map +1 -1
- package/dist/decode/index.js +5 -0
- package/dist/decode/index.js.map +1 -1
- package/dist/decode/other.js +1 -1
- package/dist/decode/other.js.map +1 -1
- package/dist/decode/positioned.d.ts +17 -1
- package/dist/decode/positioned.d.ts.map +1 -1
- package/dist/decode/positioned.js +21 -7
- package/dist/decode/positioned.js.map +1 -1
- package/dist/decode/reports.d.ts.map +1 -1
- package/dist/decode/reports.js +34 -12
- package/dist/decode/reports.js.map +1 -1
- package/dist/decoder.d.ts.map +1 -1
- package/dist/decoder.js +2 -4
- package/dist/decoder.js.map +1 -1
- package/dist/deviceid.d.ts +8 -2
- package/dist/deviceid.d.ts.map +1 -1
- package/dist/deviceid.js +10 -2
- package/dist/deviceid.js.map +1 -1
- package/dist/encode/common.d.ts +13 -2
- package/dist/encode/common.d.ts.map +1 -1
- package/dist/encode/common.js +36 -4
- package/dist/encode/common.js.map +1 -1
- package/dist/encode/index.d.ts.map +1 -1
- package/dist/encode/index.js +36 -16
- package/dist/encode/index.js.map +1 -1
- package/dist/encode/other.d.ts.map +1 -1
- package/dist/encode/other.js +10 -2
- package/dist/encode/other.js.map +1 -1
- package/dist/encode/position.d.ts +9 -5
- package/dist/encode/position.d.ts.map +1 -1
- package/dist/encode/position.js +219 -121
- package/dist/encode/position.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/neutral.d.ts.map +1 -1
- package/dist/neutral.js +20 -3
- package/dist/neutral.js.map +1 -1
- package/dist/types.d.ts +13 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/builder.ts +77 -14
- package/src/decode/index.ts +4 -0
- package/src/decode/other.ts +1 -1
- package/src/decode/positioned.ts +33 -9
- package/src/decode/reports.ts +33 -9
- package/src/decoder.ts +2 -5
- package/src/deviceid.ts +12 -3
- package/src/encode/common.ts +34 -4
- package/src/encode/index.ts +33 -14
- package/src/encode/other.ts +12 -2
- package/src/encode/position.ts +227 -119
- package/src/index.ts +1 -0
- package/src/neutral.ts +22 -3
- package/src/types.ts +14 -1
package/src/neutral.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// sent. Used by the conformance tests and the differential dump, and handy for comparing this
|
|
4
4
|
// library with another implementation.
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type { DiagnosticCode } from './codes.js';
|
|
7
|
+
import { diagnostic, formatDiagnostic, type Diagnostic, type Severity } from './diagnostics.js';
|
|
7
8
|
import type {
|
|
8
9
|
AprsData,
|
|
9
10
|
AprsPacket,
|
|
@@ -590,8 +591,26 @@ export function fromNeutralData(d: J): AprsData {
|
|
|
590
591
|
case 'unrecognized':
|
|
591
592
|
o.reason = d.reason;
|
|
592
593
|
break;
|
|
593
|
-
case 'third-party':
|
|
594
|
-
|
|
594
|
+
case 'third-party': {
|
|
595
|
+
// The inner packet as data: its information field is written from its data, and its
|
|
596
|
+
// diagnostics are kept, so one with a tolerated defect is refused, as the Encoding rule says.
|
|
597
|
+
const p: J = d.packet ?? {};
|
|
598
|
+
o.packet = {
|
|
599
|
+
source: p.source ?? '',
|
|
600
|
+
destination: p.destination ?? '',
|
|
601
|
+
path: ((p.path ?? []) as string[]).map((e) => (e.endsWith('*') ? { address: e.slice(0, -1), used: true } : { address: e, used: false })),
|
|
602
|
+
information: new Uint8Array(0),
|
|
603
|
+
data: fromNeutralData(p.data ?? { type: 'unrecognized', reason: 'empty' }),
|
|
604
|
+
diagnostics: ((p.diagnostics ?? []) as string[]).map(diagnosticFrom),
|
|
605
|
+
};
|
|
606
|
+
break;
|
|
607
|
+
}
|
|
595
608
|
}
|
|
596
609
|
return o as unknown as AprsData;
|
|
597
610
|
}
|
|
611
|
+
|
|
612
|
+
/** A diagnostic from its neutral form, `severity:code`. */
|
|
613
|
+
function diagnosticFrom(text: string): Diagnostic {
|
|
614
|
+
const colon = text.indexOf(':');
|
|
615
|
+
return diagnostic(text.slice(0, colon) as Severity, text.slice(colon + 1) as DiagnosticCode);
|
|
616
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -442,11 +442,24 @@ export interface MaidenheadBeacon {
|
|
|
442
442
|
readonly comment?: string;
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
+
/** A general query's footprint: a latitude, a longitude and a radius (APRS12c ch. 15). */
|
|
446
|
+
export interface QueryFootprint {
|
|
447
|
+
/** Degrees, north positive. */
|
|
448
|
+
readonly latitude: number;
|
|
449
|
+
/** Degrees, east positive. */
|
|
450
|
+
readonly longitude: number;
|
|
451
|
+
readonly radiusMiles: number;
|
|
452
|
+
/** The latitude as sent (` 34.0`, `-.1715`), with any leading space, so it can be written back the same. */
|
|
453
|
+
readonly latitudeText?: string;
|
|
454
|
+
/** The longitude as sent, so it can be written back the same. */
|
|
455
|
+
readonly longitudeText?: string;
|
|
456
|
+
}
|
|
457
|
+
|
|
445
458
|
/** A general query (`?`). */
|
|
446
459
|
export interface Query {
|
|
447
460
|
readonly type: 'query';
|
|
448
461
|
readonly queryType: string;
|
|
449
|
-
readonly footprint?:
|
|
462
|
+
readonly footprint?: QueryFootprint;
|
|
450
463
|
}
|
|
451
464
|
|
|
452
465
|
/** A station capability: a token, or a token and its value. */
|