@springfield/ham-radio-api 17.0.0 → 17.2.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/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export * from "./radio/driver.js";
18
18
  export * from "./radio/driver-provider.js";
19
19
  export * from "./radio/id.js";
20
20
  export * from "./radio/memory-config.js";
21
+ export * from "./radio/memory-map.js";
21
22
  export * from "./radio/memory-segment.js";
22
23
  export * from "./radio/memory.js";
23
24
  export * from "./radio/module.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","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,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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C;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ export * from "./radio/driver.js";
18
18
  export * from "./radio/driver-provider.js";
19
19
  export * from "./radio/id.js";
20
20
  export * from "./radio/memory-config.js";
21
+ export * from "./radio/memory-map.js";
21
22
  export * from "./radio/memory-segment.js";
22
23
  export * from "./radio/memory.js";
23
24
  export * from "./radio/module.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,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;AAC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CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * JSON memory-map DSL: describes how radio EEPROM bytes map to settings
3
+ * without a radio-specific TypeScript decoder.
4
+ *
5
+ * Addresses are radio EEPROM addresses (not Chirp image offsets).
6
+ */
7
+ /** Scalar JSON values stored in decoded settings. */
8
+ export type RadioSettingScalar = string | number | boolean | null;
9
+ /** Nested settings object produced by decode / consumed by encode. */
10
+ export type RadioSettingValue = RadioSettingScalar | RadioSettingValue[] | {
11
+ [key: string]: RadioSettingValue;
12
+ };
13
+ /** UI widget hint for schema-driven forms. */
14
+ export type RadioMemoryMapWidget = "integer" | "select" | "switch" | "text" | "number";
15
+ /**
16
+ * Decoded tone value for UV-5R-style tone words (before RadioTone binding).
17
+ */
18
+ export type RadioMemoryMapToneValue = {
19
+ mode: "none";
20
+ } | {
21
+ mode: "ctcss";
22
+ value: number;
23
+ } | {
24
+ mode: "dcs";
25
+ code: number;
26
+ polarity: "N" | "R";
27
+ };
28
+ /** How a field's raw bits/bytes become a setting value. */
29
+ export type RadioMemoryMapValueKind = {
30
+ kind: "integer";
31
+ min?: number;
32
+ max?: number;
33
+ } | {
34
+ kind: "boolean";
35
+ } | {
36
+ kind: "enum";
37
+ values: string[];
38
+ } | {
39
+ kind: "ascii";
40
+ length: number;
41
+ } | {
42
+ kind: "digits";
43
+ /** Number of decimal digit bytes. */
44
+ length: number;
45
+ /**
46
+ * Scale applied after parsing digits as a decimal integer.
47
+ * VFO frequency uses 10 (Hz/10 stored as 8 digits).
48
+ * Offset uses 1000 (kHz stored as 6 digits → Hz).
49
+ */
50
+ scale?: number;
51
+ } | {
52
+ kind: "dtmf";
53
+ length: number;
54
+ /** Character set indexed by byte value; 0xFF terminates. */
55
+ charset?: string;
56
+ } | {
57
+ kind: "bbcd";
58
+ /** Number of packed BCD bytes (Chirp bbcd). */
59
+ length: number;
60
+ } | {
61
+ /**
62
+ * Chirp lbcd: little-endian integer whose hex digits are the decimal
63
+ * frequency digits (Hz / scale). UV-5R channel freqs use length 4, scale 10.
64
+ */
65
+ kind: "lbcd";
66
+ length: number;
67
+ /** Multiplier after interpreting hex-as-decimal (default 10 → Hz). */
68
+ scale?: number;
69
+ } | {
70
+ /**
71
+ * UV-5R-style tone word (typically ul16):
72
+ * - 0 / 0xFFFF → none
73
+ * - >= ctcssMin → CTCSS (raw = Hz * 10)
74
+ * - else DCS index into `values` (1-based); reverseOffset adds R polarity
75
+ */
76
+ kind: "tone";
77
+ /** Ordered DCS codes (Chirp UV5R_DTCS). */
78
+ values: number[];
79
+ /** Minimum raw value treated as CTCSS (Chirp uses 0x0258). */
80
+ ctcssMin?: number;
81
+ /** Added to DCS index for reverse polarity (Chirp uses 0x69). */
82
+ reverseOffset?: number;
83
+ };
84
+ /** UI metadata for a non-reserved field. */
85
+ export interface RadioMemoryMapFieldUi {
86
+ group: string;
87
+ label: string;
88
+ widget: RadioMemoryMapWidget;
89
+ description?: string;
90
+ /** Defaults to true. Set false for firmware / read-only messages. */
91
+ writable?: boolean;
92
+ }
93
+ /**
94
+ * One field in a sequential struct.
95
+ * Bitfields pack into the current byte MSB-first (Chirp-style).
96
+ */
97
+ export interface RadioMemoryMapField {
98
+ id: string;
99
+ /**
100
+ * Storage type:
101
+ * - u8 / u16: whole bytes (u16 is little-endian, Chirp ul16)
102
+ * - bits: bitfield of `width` bits within the current byte (MSB-first)
103
+ * - char: ASCII byte (length via value.kind ascii or count)
104
+ */
105
+ type: "u8" | "u16" | "bits" | "char";
106
+ /** Bit width when type is bits. */
107
+ width?: number;
108
+ /** When true, skip decode/encode for this padding field. */
109
+ reserved?: boolean;
110
+ value?: RadioMemoryMapValueKind;
111
+ ui?: RadioMemoryMapFieldUi;
112
+ }
113
+ /**
114
+ * When the first byte of a repeated struct instance equals `equals`,
115
+ * the slot is treated as empty (Chirp: RX freq first byte 0xFF).
116
+ */
117
+ export interface RadioMemoryMapEmptyWhen {
118
+ equals: number;
119
+ }
120
+ /**
121
+ * A named struct at a radio EEPROM seek address.
122
+ * Fields are laid out sequentially from `seek`.
123
+ */
124
+ export interface RadioMemoryMapStruct {
125
+ id: string;
126
+ /** Radio EEPROM start address (number or hex string such as "0x0E20"). */
127
+ seek: number | string;
128
+ fields: RadioMemoryMapField[];
129
+ /**
130
+ * Repeat this struct `count` times with `stride` bytes between entries.
131
+ * Used for channel tables and PTT-ID code tables.
132
+ */
133
+ count?: number;
134
+ stride?: number;
135
+ /** Occupancy rule for repeated structs (e.g. empty channel slots). */
136
+ emptyWhen?: RadioMemoryMapEmptyWhen;
137
+ /**
138
+ * When encoding, fill missing/null instances with 0xFF for `stride` bytes
139
+ * (Chirp-like channel clear). Defaults to false.
140
+ */
141
+ clearEmpty?: boolean;
142
+ }
143
+ /**
144
+ * Maps decoded struct fields onto portable RadioChannel fields.
145
+ * Remaining record fields become RadioProgrammedChannel.settings.
146
+ */
147
+ export interface RadioMemoryMapChannelBindings {
148
+ /** Struct id of the channel record array. */
149
+ records: string;
150
+ /** Optional parallel name table struct id. */
151
+ names?: string;
152
+ /** Field id within the names struct (default "name"). */
153
+ nameField?: string;
154
+ receiveFrequency: string;
155
+ transmitFrequency: string;
156
+ receiveTone: string;
157
+ transmitTone: string;
158
+ }
159
+ /**
160
+ * Complete memory-map definition for a radio model's settings and channels.
161
+ */
162
+ export interface RadioMemoryMap {
163
+ /** Optional map version for tooling. */
164
+ version?: string;
165
+ description?: string;
166
+ structs: RadioMemoryMapStruct[];
167
+ /** Optional projection from channel structs into RadioProgram.channels. */
168
+ channelBindings?: RadioMemoryMapChannelBindings;
169
+ }
170
+ //# sourceMappingURL=memory-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-map.d.ts","sourceRoot":"","sources":["../../src/radio/memory-map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qDAAqD;AACrD,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GA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AM,CAAC;IAChB,sEAAsE;IACtE,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,2EAA2E;IAC3E,eAAe,CAAC,EAAE,6BAA6B,CAAC;CACjD"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * JSON memory-map DSL: describes how radio EEPROM bytes map to settings
3
+ * without a radio-specific TypeScript decoder.
4
+ *
5
+ * Addresses are radio EEPROM addresses (not Chirp image offsets).
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=memory-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-map.js","sourceRoot":"","sources":["../../src/radio/memory-map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -1,5 +1,6 @@
1
1
  import type { RadioId } from "./id.js";
2
2
  import type { RadioMemoryConfig } from "./memory-config.js";
3
+ import type { RadioMemoryMap } from "./memory-map.js";
3
4
  import type { RadioProtocolStep } from "./protocol.js";
4
5
  import type { RadioSchema } from "./schema.js";
5
6
  import type { RadioSerialConfig } from "./serial-config.js";
@@ -12,5 +13,12 @@ export interface Radio {
12
13
  serialConfig: RadioSerialConfig;
13
14
  readMemory: RadioProtocolStep[];
14
15
  writeMemory: RadioProtocolStep[];
16
+ /**
17
+ * Optional JSON memory-map for radio-wide settings decode/encode.
18
+ * May be an inline map or a path/$ref resolved by the registry/module.
19
+ */
20
+ memoryMap?: RadioMemoryMap | {
21
+ $ref: string;
22
+ };
15
23
  }
16
24
  //# sourceMappingURL=radio.d.ts.map
@@ -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,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,WAAW,CAAC;IAC5B,YAAY,EAAE,iBAAiB,CAAC;IAChC,YAAY,EAAE,iBAAiB,CAAC;IAChC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,WAAW,EAAE,iBAAiB,EAAE,CAAC;CAClC"}
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,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,WAAW,CAAC;IAC5B,YAAY,EAAE,iBAAiB,CAAC;IAChC,YAAY,EAAE,iBAAiB,CAAC;IAChC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C"}
@@ -1,4 +1,11 @@
1
- export interface RadioSettings {
2
- [setting: string]: string | number | boolean;
3
- }
1
+ import type { RadioSettingValue } from "./memory-map.js";
2
+ /**
3
+ * Decoded radio-wide settings.
4
+ *
5
+ * Values may be nested objects (struct id → fields) or arrays (repeated structs).
6
+ * Channel-specific settings may still use a flat map of primitives.
7
+ */
8
+ export type RadioSettings = {
9
+ [setting: string]: RadioSettingValue;
10
+ };
4
11
  //# sourceMappingURL=settings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/radio/settings.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAC9C"}
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/radio/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAAC;CACtC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@springfield/ham-radio-api",
3
- "version": "17.0.0",
3
+ "version": "17.2.0",
4
4
  "author": "Bryan Hunt",
5
5
  "files": [
6
6
  "dist/",
package/src/index.ts CHANGED
@@ -20,6 +20,7 @@ export * from "./radio/driver.js";
20
20
  export * from "./radio/driver-provider.js";
21
21
  export * from "./radio/id.js";
22
22
  export * from "./radio/memory-config.js";
23
+ export * from "./radio/memory-map.js";
23
24
  export * from "./radio/memory-segment.js";
24
25
  export * from "./radio/memory.js";
25
26
  export * from "./radio/module.js";
@@ -0,0 +1,169 @@
1
+ /**
2
+ * JSON memory-map DSL: describes how radio EEPROM bytes map to settings
3
+ * without a radio-specific TypeScript decoder.
4
+ *
5
+ * Addresses are radio EEPROM addresses (not Chirp image offsets).
6
+ */
7
+
8
+ /** Scalar JSON values stored in decoded settings. */
9
+ export type RadioSettingScalar = string | number | boolean | null;
10
+
11
+ /** Nested settings object produced by decode / consumed by encode. */
12
+ export type RadioSettingValue = RadioSettingScalar | RadioSettingValue[] | { [key: string]: RadioSettingValue };
13
+
14
+ /** UI widget hint for schema-driven forms. */
15
+ export type RadioMemoryMapWidget = "integer" | "select" | "switch" | "text" | "number";
16
+
17
+ /**
18
+ * Decoded tone value for UV-5R-style tone words (before RadioTone binding).
19
+ */
20
+ export type RadioMemoryMapToneValue =
21
+ | { mode: "none" }
22
+ | { mode: "ctcss"; value: number }
23
+ | { mode: "dcs"; code: number; polarity: "N" | "R" };
24
+
25
+ /** How a field's raw bits/bytes become a setting value. */
26
+ export type RadioMemoryMapValueKind =
27
+ | { kind: "integer"; min?: number; max?: number }
28
+ | { kind: "boolean" }
29
+ | { kind: "enum"; values: string[] }
30
+ | { kind: "ascii"; length: number }
31
+ | {
32
+ kind: "digits";
33
+ /** Number of decimal digit bytes. */
34
+ length: number;
35
+ /**
36
+ * Scale applied after parsing digits as a decimal integer.
37
+ * VFO frequency uses 10 (Hz/10 stored as 8 digits).
38
+ * Offset uses 1000 (kHz stored as 6 digits → Hz).
39
+ */
40
+ scale?: number;
41
+ }
42
+ | {
43
+ kind: "dtmf";
44
+ length: number;
45
+ /** Character set indexed by byte value; 0xFF terminates. */
46
+ charset?: string;
47
+ }
48
+ | {
49
+ kind: "bbcd";
50
+ /** Number of packed BCD bytes (Chirp bbcd). */
51
+ length: number;
52
+ }
53
+ | {
54
+ /**
55
+ * Chirp lbcd: little-endian integer whose hex digits are the decimal
56
+ * frequency digits (Hz / scale). UV-5R channel freqs use length 4, scale 10.
57
+ */
58
+ kind: "lbcd";
59
+ length: number;
60
+ /** Multiplier after interpreting hex-as-decimal (default 10 → Hz). */
61
+ scale?: number;
62
+ }
63
+ | {
64
+ /**
65
+ * UV-5R-style tone word (typically ul16):
66
+ * - 0 / 0xFFFF → none
67
+ * - >= ctcssMin → CTCSS (raw = Hz * 10)
68
+ * - else DCS index into `values` (1-based); reverseOffset adds R polarity
69
+ */
70
+ kind: "tone";
71
+ /** Ordered DCS codes (Chirp UV5R_DTCS). */
72
+ values: number[];
73
+ /** Minimum raw value treated as CTCSS (Chirp uses 0x0258). */
74
+ ctcssMin?: number;
75
+ /** Added to DCS index for reverse polarity (Chirp uses 0x69). */
76
+ reverseOffset?: number;
77
+ };
78
+
79
+ /** UI metadata for a non-reserved field. */
80
+ export interface RadioMemoryMapFieldUi {
81
+ group: string;
82
+ label: string;
83
+ widget: RadioMemoryMapWidget;
84
+ description?: string;
85
+ /** Defaults to true. Set false for firmware / read-only messages. */
86
+ writable?: boolean;
87
+ }
88
+
89
+ /**
90
+ * One field in a sequential struct.
91
+ * Bitfields pack into the current byte MSB-first (Chirp-style).
92
+ */
93
+ export interface RadioMemoryMapField {
94
+ id: string;
95
+ /**
96
+ * Storage type:
97
+ * - u8 / u16: whole bytes (u16 is little-endian, Chirp ul16)
98
+ * - bits: bitfield of `width` bits within the current byte (MSB-first)
99
+ * - char: ASCII byte (length via value.kind ascii or count)
100
+ */
101
+ type: "u8" | "u16" | "bits" | "char";
102
+ /** Bit width when type is bits. */
103
+ width?: number;
104
+ /** When true, skip decode/encode for this padding field. */
105
+ reserved?: boolean;
106
+ value?: RadioMemoryMapValueKind;
107
+ ui?: RadioMemoryMapFieldUi;
108
+ }
109
+
110
+ /**
111
+ * When the first byte of a repeated struct instance equals `equals`,
112
+ * the slot is treated as empty (Chirp: RX freq first byte 0xFF).
113
+ */
114
+ export interface RadioMemoryMapEmptyWhen {
115
+ equals: number;
116
+ }
117
+
118
+ /**
119
+ * A named struct at a radio EEPROM seek address.
120
+ * Fields are laid out sequentially from `seek`.
121
+ */
122
+ export interface RadioMemoryMapStruct {
123
+ id: string;
124
+ /** Radio EEPROM start address (number or hex string such as "0x0E20"). */
125
+ seek: number | string;
126
+ fields: RadioMemoryMapField[];
127
+ /**
128
+ * Repeat this struct `count` times with `stride` bytes between entries.
129
+ * Used for channel tables and PTT-ID code tables.
130
+ */
131
+ count?: number;
132
+ stride?: number;
133
+ /** Occupancy rule for repeated structs (e.g. empty channel slots). */
134
+ emptyWhen?: RadioMemoryMapEmptyWhen;
135
+ /**
136
+ * When encoding, fill missing/null instances with 0xFF for `stride` bytes
137
+ * (Chirp-like channel clear). Defaults to false.
138
+ */
139
+ clearEmpty?: boolean;
140
+ }
141
+
142
+ /**
143
+ * Maps decoded struct fields onto portable RadioChannel fields.
144
+ * Remaining record fields become RadioProgrammedChannel.settings.
145
+ */
146
+ export interface RadioMemoryMapChannelBindings {
147
+ /** Struct id of the channel record array. */
148
+ records: string;
149
+ /** Optional parallel name table struct id. */
150
+ names?: string;
151
+ /** Field id within the names struct (default "name"). */
152
+ nameField?: string;
153
+ receiveFrequency: string;
154
+ transmitFrequency: string;
155
+ receiveTone: string;
156
+ transmitTone: string;
157
+ }
158
+
159
+ /**
160
+ * Complete memory-map definition for a radio model's settings and channels.
161
+ */
162
+ export interface RadioMemoryMap {
163
+ /** Optional map version for tooling. */
164
+ version?: string;
165
+ description?: string;
166
+ structs: RadioMemoryMapStruct[];
167
+ /** Optional projection from channel structs into RadioProgram.channels. */
168
+ channelBindings?: RadioMemoryMapChannelBindings;
169
+ }
@@ -1,5 +1,6 @@
1
1
  import type { RadioId } from "./id.js";
2
2
  import type { RadioMemoryConfig } from "./memory-config.js";
3
+ import type { RadioMemoryMap } from "./memory-map.js";
3
4
  import type { RadioProtocolStep } from "./protocol.js";
4
5
  import type { RadioSchema } from "./schema.js";
5
6
  import type { RadioSerialConfig } from "./serial-config.js";
@@ -13,4 +14,9 @@ export interface Radio {
13
14
  serialConfig: RadioSerialConfig;
14
15
  readMemory: RadioProtocolStep[];
15
16
  writeMemory: RadioProtocolStep[];
17
+ /**
18
+ * Optional JSON memory-map for radio-wide settings decode/encode.
19
+ * May be an inline map or a path/$ref resolved by the registry/module.
20
+ */
21
+ memoryMap?: RadioMemoryMap | { $ref: string };
16
22
  }
@@ -1,3 +1,11 @@
1
- export interface RadioSettings {
2
- [setting: string]: string | number | boolean;
3
- }
1
+ import type { RadioSettingValue } from "./memory-map.js";
2
+
3
+ /**
4
+ * Decoded radio-wide settings.
5
+ *
6
+ * Values may be nested objects (struct id → fields) or arrays (repeated structs).
7
+ * Channel-specific settings may still use a flat map of primitives.
8
+ */
9
+ export type RadioSettings = {
10
+ [setting: string]: RadioSettingValue;
11
+ };