@springfield/ham-radio-api 18.1.0 → 18.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/README.md +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/radio/dialog-message.d.ts +25 -0
- package/dist/radio/dialog-message.d.ts.map +1 -0
- package/dist/radio/dialog-message.js +69 -0
- package/dist/radio/dialog-message.js.map +1 -0
- package/dist/radio/protocol.d.ts +19 -0
- package/dist/radio/protocol.d.ts.map +1 -1
- package/dist/radio/radio.d.ts +19 -1
- package/dist/radio/radio.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -0
- package/src/radio/dialog-message.ts +98 -0
- package/src/radio/protocol.ts +21 -0
- package/src/radio/radio.ts +19 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ Packages that talk to radios depend on this library. It does not open a serial p
|
|
|
6
6
|
|
|
7
7
|
Docs: [HamBench developer docs](https://springfield-ham-radio.github.io/ham-radio-docs/developer/)
|
|
8
8
|
|
|
9
|
+
Package docs: [radio read/write dialog messages](docs/radio-dialog-messages.md)
|
|
10
|
+
|
|
9
11
|
## License
|
|
10
12
|
|
|
11
13
|
MIT — Copyright (c) 2026 Bryan Hunt. See [LICENSE](LICENSE).
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./radio/codec-factory.js";
|
|
|
14
14
|
export * from "./radio/connection.js";
|
|
15
15
|
export * from "./radio/ctcss.js";
|
|
16
16
|
export * from "./radio/dcs.js";
|
|
17
|
+
export * from "./radio/dialog-message.js";
|
|
17
18
|
export * from "./radio/driver.js";
|
|
18
19
|
export * from "./radio/driver-provider.js";
|
|
19
20
|
export * from "./radio/id.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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,7 @@ export * from "./radio/codec-factory.js";
|
|
|
14
14
|
export * from "./radio/connection.js";
|
|
15
15
|
export * from "./radio/ctcss.js";
|
|
16
16
|
export * from "./radio/dcs.js";
|
|
17
|
+
export * from "./radio/dialog-message.js";
|
|
17
18
|
export * from "./radio/driver.js";
|
|
18
19
|
export * from "./radio/driver-provider.js";
|
|
19
20
|
export * from "./radio/id.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0CAA0C,CAAC;AACzD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,oBAAoB,CAAC;AAEnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CA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cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AAExC,cAAc,mBAAmB,CAAC;AAElC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ValidationResult } from "./validation.js";
|
|
2
|
+
/** UAlert-style severity for optional read/write setup text in HamBench. */
|
|
3
|
+
export type RadioDialogSeverity = "info" | "warning";
|
|
4
|
+
/**
|
|
5
|
+
* Optional setup text shown in HamBench before a memory read or write.
|
|
6
|
+
* Radio modules set this on the driver config JSON (`readMessage` / `writeMessage`).
|
|
7
|
+
*/
|
|
8
|
+
export interface RadioDialogMessage {
|
|
9
|
+
/** Short alert title (plain text). */
|
|
10
|
+
title: string;
|
|
11
|
+
/** Alert body (plain text; newlines are line breaks). */
|
|
12
|
+
body: string;
|
|
13
|
+
/**
|
|
14
|
+
* Visual weight in HamBench. Omit for `info`.
|
|
15
|
+
*/
|
|
16
|
+
severity?: RadioDialogSeverity;
|
|
17
|
+
}
|
|
18
|
+
export declare const RADIO_DIALOG_MESSAGE_TITLE_MAX_LENGTH = 80;
|
|
19
|
+
export declare const RADIO_DIALOG_MESSAGE_BODY_MAX_LENGTH = 600;
|
|
20
|
+
/**
|
|
21
|
+
* Validate an optional `readMessage` or `writeMessage` value from a radio config.
|
|
22
|
+
* `undefined` is valid (field omitted).
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateRadioDialogMessage(fieldPath: string, value: unknown): ValidationResult;
|
|
25
|
+
//# sourceMappingURL=dialog-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog-message.d.ts","sourceRoot":"","sources":["../../src/radio/dialog-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,4EAA4E;AAC5E,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC;AAED,eAAO,MAAM,qCAAqC,KAAK,CAAC;AACxD,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAoBxD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAoD9F"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const RADIO_DIALOG_MESSAGE_TITLE_MAX_LENGTH = 80;
|
|
2
|
+
export const RADIO_DIALOG_MESSAGE_BODY_MAX_LENGTH = 600;
|
|
3
|
+
const DIALOG_SEVERITIES = new Set(["info", "warning"]);
|
|
4
|
+
function hasDisallowedControlCharacters(text) {
|
|
5
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
6
|
+
const code = text.charCodeAt(index);
|
|
7
|
+
if (code === 9 || code === 10) {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
if (code < 32 || code === 127) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Validate an optional `readMessage` or `writeMessage` value from a radio config.
|
|
18
|
+
* `undefined` is valid (field omitted).
|
|
19
|
+
*/
|
|
20
|
+
export function validateRadioDialogMessage(fieldPath, value) {
|
|
21
|
+
const errors = [];
|
|
22
|
+
const warnings = [];
|
|
23
|
+
if (value === undefined) {
|
|
24
|
+
return { isValid: true, errors, warnings };
|
|
25
|
+
}
|
|
26
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
27
|
+
errors.push(`${fieldPath} must be an object`);
|
|
28
|
+
return { isValid: false, errors, warnings };
|
|
29
|
+
}
|
|
30
|
+
const record = value;
|
|
31
|
+
if (typeof record.title !== "string") {
|
|
32
|
+
errors.push(`${fieldPath}.title must be a string`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const title = record.title.trim();
|
|
36
|
+
if (title.length === 0) {
|
|
37
|
+
errors.push(`${fieldPath}.title must not be empty`);
|
|
38
|
+
}
|
|
39
|
+
else if (title.length > RADIO_DIALOG_MESSAGE_TITLE_MAX_LENGTH) {
|
|
40
|
+
errors.push(`${fieldPath}.title must be at most ${RADIO_DIALOG_MESSAGE_TITLE_MAX_LENGTH} characters`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (typeof record.body !== "string") {
|
|
44
|
+
errors.push(`${fieldPath}.body must be a string`);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const body = record.body.trim();
|
|
48
|
+
if (body.length === 0) {
|
|
49
|
+
errors.push(`${fieldPath}.body must not be empty`);
|
|
50
|
+
}
|
|
51
|
+
else if (body.length > RADIO_DIALOG_MESSAGE_BODY_MAX_LENGTH) {
|
|
52
|
+
errors.push(`${fieldPath}.body must be at most ${RADIO_DIALOG_MESSAGE_BODY_MAX_LENGTH} characters`);
|
|
53
|
+
}
|
|
54
|
+
else if (hasDisallowedControlCharacters(record.body)) {
|
|
55
|
+
errors.push(`${fieldPath}.body must not contain control characters other than tab or newline`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (record.severity !== undefined) {
|
|
59
|
+
if (typeof record.severity !== "string" || !DIALOG_SEVERITIES.has(record.severity)) {
|
|
60
|
+
errors.push(`${fieldPath}.severity must be "info" or "warning"`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
isValid: errors.length === 0,
|
|
65
|
+
errors,
|
|
66
|
+
warnings,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=dialog-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog-message.js","sourceRoot":"","sources":["../../src/radio/dialog-message.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,qCAAqC,GAAG,EAAE,CAAC;AACxD,MAAM,CAAC,MAAM,oCAAoC,GAAG,GAAG,CAAC;AAExD,MAAM,iBAAiB,GAAqC,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAEzF,SAAS,8BAA8B,CAAC,IAAY;IAClD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YAC9B,SAAS;QACX,CAAC;QAED,IAAI,IAAI,GAAG,EAAE,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,SAAiB,EAAE,KAAc;IAC1E,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,CAAC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CAAC,IAAI,CAAC,GAAG,SAAS,qEAAqE,CAAC,CAAC;QACjG,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,QAA+B,CAAC,EAAE,CAAC;YAC1G,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,uCAAuC,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC5B,MAAM;QACN,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
package/dist/radio/protocol.d.ts
CHANGED
|
@@ -125,4 +125,23 @@ export interface RadioCatWriteStep {
|
|
|
125
125
|
catWrite: RadioCatMemoryConfig;
|
|
126
126
|
}
|
|
127
127
|
export type RadioProtocolStep = RadioExchange | RadioReadStep | RadioWriteStep | RadioCatReadStep | RadioCatWriteStep;
|
|
128
|
+
/**
|
|
129
|
+
* Exchange-only protocol steps (`send`, `expect`, `setBaudRate`, `delay`, `timeout`).
|
|
130
|
+
* Used for {@link RadioOnError} cleanup lists, which must not include read, write, or CAT loop steps.
|
|
131
|
+
*/
|
|
132
|
+
export type RadioProtocolExchangeStep = RadioExchange;
|
|
133
|
+
/**
|
|
134
|
+
* Optional cleanup exchanges keyed by memory operation. The driver runs the matching list
|
|
135
|
+
* best-effort after a protocol step fails or the user cancels; it is not run on success and is
|
|
136
|
+
* skipped when the serial port is already closed.
|
|
137
|
+
*
|
|
138
|
+
* @example Kenwood TH-D74 clone exit at the post-switch baud:
|
|
139
|
+
* ```json
|
|
140
|
+
* [{ "setBaudRate": 57600 }, { "send": ["E"] }]
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export interface RadioOnError {
|
|
144
|
+
readMemory?: RadioProtocolExchangeStep[];
|
|
145
|
+
writeMemory?: RadioProtocolExchangeStep[];
|
|
146
|
+
}
|
|
128
147
|
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/radio/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,cAAc,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,cAAc,EAAE,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAElG;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,cAAc,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;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K,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,cAAc,CAAC;KACxB,CAAC;CACH;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE;QACL,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,IAAI,EAAE,cAAc,EAAE,CAAC;QACvB,MAAM,EAAE,WAAW,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,kBAAkB,EAAE,CAAC;KAC7B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,oBAAoB,CAAC;CAChC;AAED,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,aAAa,GAAG,cAAc,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAEtH;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,aAAa,CAAC;AAEtD;;;;;;;;;GASG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,yBAAyB,EAAE,CAAC;IACzC,WAAW,CAAC,EAAE,yBAAyB,EAAE,CAAC;CAC3C"}
|
package/dist/radio/radio.d.ts
CHANGED
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
import type { RadioId } from "./id.js";
|
|
2
2
|
import type { RadioMemoryConfig } from "./memory-config.js";
|
|
3
3
|
import type { RadioMemoryMap } from "./memory-map.js";
|
|
4
|
-
import type { RadioProtocolStep } from "./protocol.js";
|
|
4
|
+
import type { RadioOnError, RadioProtocolStep } from "./protocol.js";
|
|
5
5
|
import type { RadioSchema } from "./schema.js";
|
|
6
|
+
import type { RadioDialogMessage } from "./dialog-message.js";
|
|
6
7
|
import type { RadioSerialConfig } from "./serial-config.js";
|
|
7
8
|
export interface Radio {
|
|
8
9
|
id: RadioId;
|
|
9
10
|
version: string;
|
|
10
11
|
description: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional setup text for HamBench **Read from Radio** (plain text; see `RadioDialogMessage`).
|
|
14
|
+
*/
|
|
15
|
+
readMessage?: RadioDialogMessage;
|
|
16
|
+
/**
|
|
17
|
+
* Optional setup text for HamBench **Write to Radio** (plain text; see `RadioDialogMessage`).
|
|
18
|
+
*/
|
|
19
|
+
writeMessage?: RadioDialogMessage;
|
|
11
20
|
settingsSchema: RadioSchema;
|
|
12
21
|
memoryConfig: RadioMemoryConfig;
|
|
13
22
|
serialConfig: RadioSerialConfig;
|
|
14
23
|
readMemory: RadioProtocolStep[];
|
|
15
24
|
writeMemory: RadioProtocolStep[];
|
|
25
|
+
/**
|
|
26
|
+
* Optional cleanup exchanges after a failed or cancelled read/write. Not run on success;
|
|
27
|
+
* skipped when the port is closed. Each list may only contain exchange steps (`send`,
|
|
28
|
+
* `expect`, `setBaudRate`, `delay`, `timeout`), not read/write/CAT loops.
|
|
29
|
+
*
|
|
30
|
+
* @example Kenwood TH-D74 clone exit at the post-switch baud:
|
|
31
|
+
* `[{ setBaudRate: 57600 }, { send: ['E'] }]`
|
|
32
|
+
*/
|
|
33
|
+
onError?: RadioOnError;
|
|
16
34
|
/**
|
|
17
35
|
* Optional JSON memory-map for radio-wide settings decode/encode.
|
|
18
36
|
* May be an inline map or a path/$ref resolved by the registry/module.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/radio/radio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAo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": "@springfield/ham-radio-api",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.3.0",
|
|
4
4
|
"author": "Bryan Hunt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"@semantic-release/github": "12.0.10",
|
|
40
40
|
"@semantic-release/npm": "13.2.0",
|
|
41
41
|
"husky": "9.1.7",
|
|
42
|
-
"oxfmt": "^0.
|
|
43
|
-
"oxlint": "1.
|
|
42
|
+
"oxfmt": "^0.73.0",
|
|
43
|
+
"oxlint": "1.88.0",
|
|
44
44
|
"semantic-release": "25.0.9",
|
|
45
45
|
"typescript": "7.0.2",
|
|
46
|
-
"vite": "^8.3.
|
|
47
|
-
"vitest": "^5.0.
|
|
46
|
+
"vite": "^8.3.4",
|
|
47
|
+
"vitest": "^5.0.5"
|
|
48
48
|
},
|
|
49
49
|
"resolutions": {
|
|
50
50
|
"conventional-changelog-conventionalcommits": "9.3.1"
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./radio/codec-factory.js";
|
|
|
16
16
|
export * from "./radio/connection.js";
|
|
17
17
|
export * from "./radio/ctcss.js";
|
|
18
18
|
export * from "./radio/dcs.js";
|
|
19
|
+
export * from "./radio/dialog-message.js";
|
|
19
20
|
export * from "./radio/driver.js";
|
|
20
21
|
export * from "./radio/driver-provider.js";
|
|
21
22
|
export * from "./radio/id.js";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { ValidationResult } from "./validation.js";
|
|
2
|
+
|
|
3
|
+
/** UAlert-style severity for optional read/write setup text in HamBench. */
|
|
4
|
+
export type RadioDialogSeverity = "info" | "warning";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Optional setup text shown in HamBench before a memory read or write.
|
|
8
|
+
* Radio modules set this on the driver config JSON (`readMessage` / `writeMessage`).
|
|
9
|
+
*/
|
|
10
|
+
export interface RadioDialogMessage {
|
|
11
|
+
/** Short alert title (plain text). */
|
|
12
|
+
title: string;
|
|
13
|
+
/** Alert body (plain text; newlines are line breaks). */
|
|
14
|
+
body: string;
|
|
15
|
+
/**
|
|
16
|
+
* Visual weight in HamBench. Omit for `info`.
|
|
17
|
+
*/
|
|
18
|
+
severity?: RadioDialogSeverity;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const RADIO_DIALOG_MESSAGE_TITLE_MAX_LENGTH = 80;
|
|
22
|
+
export const RADIO_DIALOG_MESSAGE_BODY_MAX_LENGTH = 600;
|
|
23
|
+
|
|
24
|
+
const DIALOG_SEVERITIES: ReadonlySet<RadioDialogSeverity> = new Set(["info", "warning"]);
|
|
25
|
+
|
|
26
|
+
function hasDisallowedControlCharacters(text: string): boolean {
|
|
27
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
28
|
+
const code = text.charCodeAt(index);
|
|
29
|
+
|
|
30
|
+
if (code === 9 || code === 10) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (code < 32 || code === 127) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Validate an optional `readMessage` or `writeMessage` value from a radio config.
|
|
44
|
+
* `undefined` is valid (field omitted).
|
|
45
|
+
*/
|
|
46
|
+
export function validateRadioDialogMessage(fieldPath: string, value: unknown): ValidationResult {
|
|
47
|
+
const errors: string[] = [];
|
|
48
|
+
const warnings: string[] = [];
|
|
49
|
+
|
|
50
|
+
if (value === undefined) {
|
|
51
|
+
return { isValid: true, errors, warnings };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
55
|
+
errors.push(`${fieldPath} must be an object`);
|
|
56
|
+
return { isValid: false, errors, warnings };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const record = value as Record<string, unknown>;
|
|
60
|
+
|
|
61
|
+
if (typeof record.title !== "string") {
|
|
62
|
+
errors.push(`${fieldPath}.title must be a string`);
|
|
63
|
+
} else {
|
|
64
|
+
const title = record.title.trim();
|
|
65
|
+
|
|
66
|
+
if (title.length === 0) {
|
|
67
|
+
errors.push(`${fieldPath}.title must not be empty`);
|
|
68
|
+
} else if (title.length > RADIO_DIALOG_MESSAGE_TITLE_MAX_LENGTH) {
|
|
69
|
+
errors.push(`${fieldPath}.title must be at most ${RADIO_DIALOG_MESSAGE_TITLE_MAX_LENGTH} characters`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (typeof record.body !== "string") {
|
|
74
|
+
errors.push(`${fieldPath}.body must be a string`);
|
|
75
|
+
} else {
|
|
76
|
+
const body = record.body.trim();
|
|
77
|
+
|
|
78
|
+
if (body.length === 0) {
|
|
79
|
+
errors.push(`${fieldPath}.body must not be empty`);
|
|
80
|
+
} else if (body.length > RADIO_DIALOG_MESSAGE_BODY_MAX_LENGTH) {
|
|
81
|
+
errors.push(`${fieldPath}.body must be at most ${RADIO_DIALOG_MESSAGE_BODY_MAX_LENGTH} characters`);
|
|
82
|
+
} else if (hasDisallowedControlCharacters(record.body)) {
|
|
83
|
+
errors.push(`${fieldPath}.body must not contain control characters other than tab or newline`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (record.severity !== undefined) {
|
|
88
|
+
if (typeof record.severity !== "string" || !DIALOG_SEVERITIES.has(record.severity as RadioDialogSeverity)) {
|
|
89
|
+
errors.push(`${fieldPath}.severity must be "info" or "warning"`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
isValid: errors.length === 0,
|
|
95
|
+
errors,
|
|
96
|
+
warnings,
|
|
97
|
+
};
|
|
98
|
+
}
|
package/src/radio/protocol.ts
CHANGED
|
@@ -137,3 +137,24 @@ export interface RadioCatWriteStep {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
export type RadioProtocolStep = RadioExchange | RadioReadStep | RadioWriteStep | RadioCatReadStep | RadioCatWriteStep;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Exchange-only protocol steps (`send`, `expect`, `setBaudRate`, `delay`, `timeout`).
|
|
143
|
+
* Used for {@link RadioOnError} cleanup lists, which must not include read, write, or CAT loop steps.
|
|
144
|
+
*/
|
|
145
|
+
export type RadioProtocolExchangeStep = RadioExchange;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Optional cleanup exchanges keyed by memory operation. The driver runs the matching list
|
|
149
|
+
* best-effort after a protocol step fails or the user cancels; it is not run on success and is
|
|
150
|
+
* skipped when the serial port is already closed.
|
|
151
|
+
*
|
|
152
|
+
* @example Kenwood TH-D74 clone exit at the post-switch baud:
|
|
153
|
+
* ```json
|
|
154
|
+
* [{ "setBaudRate": 57600 }, { "send": ["E"] }]
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export interface RadioOnError {
|
|
158
|
+
readMemory?: RadioProtocolExchangeStep[];
|
|
159
|
+
writeMemory?: RadioProtocolExchangeStep[];
|
|
160
|
+
}
|
package/src/radio/radio.ts
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
import type { RadioId } from "./id.js";
|
|
2
2
|
import type { RadioMemoryConfig } from "./memory-config.js";
|
|
3
3
|
import type { RadioMemoryMap } from "./memory-map.js";
|
|
4
|
-
import type { RadioProtocolStep } from "./protocol.js";
|
|
4
|
+
import type { RadioOnError, RadioProtocolStep } from "./protocol.js";
|
|
5
5
|
import type { RadioSchema } from "./schema.js";
|
|
6
|
+
import type { RadioDialogMessage } from "./dialog-message.js";
|
|
6
7
|
import type { RadioSerialConfig } from "./serial-config.js";
|
|
7
8
|
|
|
8
9
|
export interface Radio {
|
|
9
10
|
id: RadioId;
|
|
10
11
|
version: string;
|
|
11
12
|
description: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional setup text for HamBench **Read from Radio** (plain text; see `RadioDialogMessage`).
|
|
15
|
+
*/
|
|
16
|
+
readMessage?: RadioDialogMessage;
|
|
17
|
+
/**
|
|
18
|
+
* Optional setup text for HamBench **Write to Radio** (plain text; see `RadioDialogMessage`).
|
|
19
|
+
*/
|
|
20
|
+
writeMessage?: RadioDialogMessage;
|
|
12
21
|
settingsSchema: RadioSchema;
|
|
13
22
|
memoryConfig: RadioMemoryConfig;
|
|
14
23
|
serialConfig: RadioSerialConfig;
|
|
15
24
|
readMemory: RadioProtocolStep[];
|
|
16
25
|
writeMemory: RadioProtocolStep[];
|
|
26
|
+
/**
|
|
27
|
+
* Optional cleanup exchanges after a failed or cancelled read/write. Not run on success;
|
|
28
|
+
* skipped when the port is closed. Each list may only contain exchange steps (`send`,
|
|
29
|
+
* `expect`, `setBaudRate`, `delay`, `timeout`), not read/write/CAT loops.
|
|
30
|
+
*
|
|
31
|
+
* @example Kenwood TH-D74 clone exit at the post-switch baud:
|
|
32
|
+
* `[{ setBaudRate: 57600 }, { send: ['E'] }]`
|
|
33
|
+
*/
|
|
34
|
+
onError?: RadioOnError;
|
|
17
35
|
/**
|
|
18
36
|
* Optional JSON memory-map for radio-wide settings decode/encode.
|
|
19
37
|
* May be an inline map or a path/$ref resolved by the registry/module.
|