icom-wlan-node 0.1.1 → 0.2.1
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 +234 -23
- package/dist/core/Session.d.ts +9 -0
- package/dist/core/Session.js +34 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -2
- package/dist/rig/IcomCiv.js +6 -1
- package/dist/rig/IcomConstants.d.ts +72 -0
- package/dist/rig/IcomConstants.js +82 -1
- package/dist/rig/IcomControl.d.ts +185 -7
- package/dist/rig/IcomControl.js +819 -67
- package/dist/rig/IcomRigCommands.d.ts +7 -0
- package/dist/rig/IcomRigCommands.js +28 -0
- package/dist/transport/UdpClient.js +18 -4
- package/dist/types.d.ts +254 -0
- package/dist/types.js +46 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IcomRigOptions, RigEventEmitter, IcomMode, ConnectorDataMode, SetModeOptions, QueryOptions, SwrReading, AlcReading, WlanLevelReading, LevelMeterReading } from '../types';
|
|
1
|
+
import { IcomRigOptions, RigEventEmitter, IcomMode, ConnectorDataMode, SetModeOptions, QueryOptions, SwrReading, AlcReading, WlanLevelReading, LevelMeterReading, SquelchStatusReading, AudioSquelchReading, OvfStatusReading, PowerLevelReading, CompLevelReading, VoltageReading, CurrentReading, ConnectionState, ConnectionMonitorConfig, ConnectionPhase, ConnectionMetrics } from '../types';
|
|
2
2
|
import { IcomCiv } from './IcomCiv';
|
|
3
3
|
import { IcomAudio } from './IcomAudio';
|
|
4
4
|
export declare class IcomControl {
|
|
@@ -14,15 +14,58 @@ export declare class IcomControl {
|
|
|
14
14
|
private tokenTimer?;
|
|
15
15
|
private civAssembleBuf;
|
|
16
16
|
private meterTimer?;
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
private
|
|
21
|
-
private
|
|
22
|
-
private resolveAudioReady;
|
|
17
|
+
private connectionSession;
|
|
18
|
+
private nextSessionId;
|
|
19
|
+
private abortHandlers;
|
|
20
|
+
private monitorTimer?;
|
|
21
|
+
private monitorConfig;
|
|
23
22
|
constructor(options: IcomRigOptions);
|
|
24
23
|
get events(): RigEventEmitter;
|
|
24
|
+
/**
|
|
25
|
+
* Transition to a new connection phase with logging
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
private transitionTo;
|
|
29
|
+
/**
|
|
30
|
+
* Validate if a state transition is legal
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
private canTransitionTo;
|
|
34
|
+
/**
|
|
35
|
+
* Abort an ongoing connection attempt by session ID
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
private abortConnectionAttempt;
|
|
39
|
+
/**
|
|
40
|
+
* Connect to the rig
|
|
41
|
+
* Idempotent: multiple calls during CONNECTING phase are safe
|
|
42
|
+
* @throws Error if called during DISCONNECTING phase
|
|
43
|
+
*/
|
|
25
44
|
connect(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Internal connection implementation
|
|
47
|
+
* Uses local promises to avoid race conditions
|
|
48
|
+
* Uses phased timeout: 30s for overall, 10s for sub-sessions after login
|
|
49
|
+
* @param sessionId - Unique session ID to prevent race conditions
|
|
50
|
+
*/
|
|
51
|
+
private _doConnect;
|
|
52
|
+
/**
|
|
53
|
+
* Create local promises for connection readiness
|
|
54
|
+
* This avoids race conditions with instance variables
|
|
55
|
+
* @param sessionId - Connection session ID for abort handler tracking
|
|
56
|
+
*/
|
|
57
|
+
private createReadyPromises;
|
|
58
|
+
/**
|
|
59
|
+
* Start unified connection monitoring
|
|
60
|
+
* Monitors all three sessions from a single timer to avoid race conditions
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
private startUnifiedMonitoring;
|
|
64
|
+
/**
|
|
65
|
+
* Stop unified connection monitoring
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
private stopUnifiedMonitoring;
|
|
26
69
|
disconnect(): Promise<void>;
|
|
27
70
|
sendCiv(data: Buffer): void;
|
|
28
71
|
/**
|
|
@@ -129,6 +172,83 @@ export declare class IcomControl {
|
|
|
129
172
|
* await rig.setConnectorDataMode('WLAN');
|
|
130
173
|
*/
|
|
131
174
|
setConnectorDataMode(mode: ConnectorDataMode | number): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Read squelch status (noise/signal gate state)
|
|
177
|
+
* @param options - Query options (timeout in ms, default 3000)
|
|
178
|
+
* @returns Squelch status with raw value and boolean state
|
|
179
|
+
* @example
|
|
180
|
+
* const status = await rig.readSquelchStatus({ timeout: 2000 });
|
|
181
|
+
* if (status) {
|
|
182
|
+
* console.log(`Squelch: ${status.isOpen ? 'OPEN' : 'CLOSED'}`);
|
|
183
|
+
* }
|
|
184
|
+
*/
|
|
185
|
+
readSquelchStatus(options?: QueryOptions): Promise<SquelchStatusReading | null>;
|
|
186
|
+
/**
|
|
187
|
+
* Read audio squelch state
|
|
188
|
+
* @param options - Query options (timeout in ms, default 3000)
|
|
189
|
+
* @returns Audio squelch status with raw value and boolean state
|
|
190
|
+
* @example
|
|
191
|
+
* const squelch = await rig.readAudioSquelch({ timeout: 2000 });
|
|
192
|
+
* if (squelch) {
|
|
193
|
+
* console.log(`Audio Squelch: ${squelch.isOpen ? 'OPEN' : 'CLOSED'}`);
|
|
194
|
+
* }
|
|
195
|
+
*/
|
|
196
|
+
readAudioSquelch(options?: QueryOptions): Promise<AudioSquelchReading | null>;
|
|
197
|
+
/**
|
|
198
|
+
* Read OVF (ADC overload) status
|
|
199
|
+
* @param options - Query options (timeout in ms, default 3000)
|
|
200
|
+
* @returns OVF status with raw value and boolean overload flag
|
|
201
|
+
* @example
|
|
202
|
+
* const ovf = await rig.readOvfStatus({ timeout: 2000 });
|
|
203
|
+
* if (ovf) {
|
|
204
|
+
* console.log(`ADC: ${ovf.isOverload ? '⚠️ OVERLOAD' : '✓ OK'}`);
|
|
205
|
+
* }
|
|
206
|
+
*/
|
|
207
|
+
readOvfStatus(options?: QueryOptions): Promise<OvfStatusReading | null>;
|
|
208
|
+
/**
|
|
209
|
+
* Read power output level during transmission
|
|
210
|
+
* @param options - Query options (timeout in ms, default 3000)
|
|
211
|
+
* @returns Power level with raw value and percentage
|
|
212
|
+
* @example
|
|
213
|
+
* const power = await rig.readPowerLevel({ timeout: 2000 });
|
|
214
|
+
* if (power) {
|
|
215
|
+
* console.log(`Power: ${power.percent.toFixed(1)}%`);
|
|
216
|
+
* }
|
|
217
|
+
*/
|
|
218
|
+
readPowerLevel(options?: QueryOptions): Promise<PowerLevelReading | null>;
|
|
219
|
+
/**
|
|
220
|
+
* Read COMP (voice compression) level during transmission
|
|
221
|
+
* @param options - Query options (timeout in ms, default 3000)
|
|
222
|
+
* @returns Compression level with raw value and percentage
|
|
223
|
+
* @example
|
|
224
|
+
* const comp = await rig.readCompLevel({ timeout: 2000 });
|
|
225
|
+
* if (comp) {
|
|
226
|
+
* console.log(`COMP: ${comp.percent.toFixed(1)}%`);
|
|
227
|
+
* }
|
|
228
|
+
*/
|
|
229
|
+
readCompLevel(options?: QueryOptions): Promise<CompLevelReading | null>;
|
|
230
|
+
/**
|
|
231
|
+
* Read power supply voltage
|
|
232
|
+
* @param options - Query options (timeout in ms, default 3000)
|
|
233
|
+
* @returns Voltage reading with raw value and volts
|
|
234
|
+
* @example
|
|
235
|
+
* const voltage = await rig.readVoltage({ timeout: 2000 });
|
|
236
|
+
* if (voltage) {
|
|
237
|
+
* console.log(`Voltage: ${voltage.volts.toFixed(2)}V`);
|
|
238
|
+
* }
|
|
239
|
+
*/
|
|
240
|
+
readVoltage(options?: QueryOptions): Promise<VoltageReading | null>;
|
|
241
|
+
/**
|
|
242
|
+
* Read power supply current draw
|
|
243
|
+
* @param options - Query options (timeout in ms, default 3000)
|
|
244
|
+
* @returns Current reading with raw value and amperes
|
|
245
|
+
* @example
|
|
246
|
+
* const current = await rig.readCurrent({ timeout: 2000 });
|
|
247
|
+
* if (current) {
|
|
248
|
+
* console.log(`Current: ${current.amps.toFixed(2)}A`);
|
|
249
|
+
* }
|
|
250
|
+
*/
|
|
251
|
+
readCurrent(options?: QueryOptions): Promise<CurrentReading | null>;
|
|
132
252
|
private static isReplyOf;
|
|
133
253
|
/**
|
|
134
254
|
* Extract meter data from CI-V response frame
|
|
@@ -152,4 +272,62 @@ export declare class IcomControl {
|
|
|
152
272
|
private stopMeterPolling;
|
|
153
273
|
private onAudioData;
|
|
154
274
|
private sendConnectionRequest;
|
|
275
|
+
/**
|
|
276
|
+
* Configure unified connection monitoring
|
|
277
|
+
* @param config - Monitoring configuration options
|
|
278
|
+
* @example
|
|
279
|
+
* rig.configureMonitoring({ timeout: 10000, checkInterval: 2000, autoReconnect: true });
|
|
280
|
+
*/
|
|
281
|
+
configureMonitoring(config: ConnectionMonitorConfig): void;
|
|
282
|
+
/**
|
|
283
|
+
* Get current connection state for all sessions
|
|
284
|
+
* @returns Object with connection state for each session
|
|
285
|
+
*/
|
|
286
|
+
getConnectionState(): {
|
|
287
|
+
control: ConnectionState;
|
|
288
|
+
civ: ConnectionState;
|
|
289
|
+
audio: ConnectionState;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Check if any session has lost connection
|
|
293
|
+
* @returns true if any session is disconnected
|
|
294
|
+
*/
|
|
295
|
+
isAnySessionDisconnected(): boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Handle connection lost event from a session
|
|
298
|
+
* Simplified strategy: any session loss triggers full reconnect
|
|
299
|
+
* @private
|
|
300
|
+
*/
|
|
301
|
+
private handleConnectionLost;
|
|
302
|
+
/**
|
|
303
|
+
* Schedule a full reconnection (all sessions)
|
|
304
|
+
* Uses simple while loop with exponential backoff
|
|
305
|
+
* @private
|
|
306
|
+
*/
|
|
307
|
+
private scheduleFullReconnect;
|
|
308
|
+
/**
|
|
309
|
+
* Connect with timeout (helper for reconnection)
|
|
310
|
+
* @private
|
|
311
|
+
*/
|
|
312
|
+
private connectWithTimeout;
|
|
313
|
+
/**
|
|
314
|
+
* Sleep helper (returns a Promise)
|
|
315
|
+
* @private
|
|
316
|
+
*/
|
|
317
|
+
private sleep;
|
|
318
|
+
/**
|
|
319
|
+
* Calculate reconnect delay using exponential backoff
|
|
320
|
+
* @private
|
|
321
|
+
*/
|
|
322
|
+
private calculateReconnectDelay;
|
|
323
|
+
/**
|
|
324
|
+
* Get current connection phase
|
|
325
|
+
* @returns Current connection phase (IDLE, CONNECTING, CONNECTED, etc.)
|
|
326
|
+
*/
|
|
327
|
+
getConnectionPhase(): ConnectionPhase;
|
|
328
|
+
/**
|
|
329
|
+
* Get detailed connection metrics for monitoring and diagnostics
|
|
330
|
+
* @returns Connection metrics including phase, uptime, session states
|
|
331
|
+
*/
|
|
332
|
+
getConnectionMetrics(): ConnectionMetrics;
|
|
155
333
|
}
|