hamlib 0.1.6 → 0.1.7

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/lib/index.js CHANGED
@@ -36,15 +36,7 @@ class HamLib {
36
36
  * @throws {Error} Throws error when connection fails
37
37
  */
38
38
  async open() {
39
- return new Promise((resolve, reject) => {
40
- this._nativeInstance.open((err, result) => {
41
- if (err) {
42
- reject(new Error(err.message || 'Failed to open connection'));
43
- } else {
44
- resolve(result);
45
- }
46
- });
47
- });
39
+ return this._nativeInstance.open();
48
40
  }
49
41
 
50
42
  /**
@@ -53,15 +45,7 @@ class HamLib {
53
45
  * @throws {Error} Throws error when device doesn't support or operation fails
54
46
  */
55
47
  async setVfo(vfo) {
56
- return new Promise((resolve, reject) => {
57
- this._nativeInstance.setVfo(vfo, (err, result) => {
58
- if (err) {
59
- reject(new Error(err.message || 'Failed to set VFO'));
60
- } else {
61
- resolve(result);
62
- }
63
- });
64
- });
48
+ return this._nativeInstance.setVfo(vfo);
65
49
  }
66
50
 
67
51
  /**
@@ -70,52 +54,31 @@ class HamLib {
70
54
  * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
71
55
  */
72
56
  async setFrequency(frequency, vfo) {
73
- return new Promise((resolve, reject) => {
74
- if (vfo) {
75
- this._nativeInstance.setFrequency(frequency, vfo, (err, result) => {
76
- if (err) {
77
- reject(new Error(err.message || 'Failed to set frequency'));
78
- } else {
79
- resolve(result);
80
- }
81
- });
82
- } else {
83
- this._nativeInstance.setFrequency(frequency, (err, result) => {
84
- if (err) {
85
- reject(new Error(err.message || 'Failed to set frequency'));
86
- } else {
87
- resolve(result);
88
- }
89
- });
90
- }
91
- });
57
+ if (vfo) {
58
+ return this._nativeInstance.setFrequency(frequency, vfo);
59
+ } else {
60
+ return this._nativeInstance.setFrequency(frequency);
61
+ }
92
62
  }
93
63
 
94
64
  /**
95
65
  * Set radio mode
96
66
  * @param {string} mode - Radio mode ('USB', 'LSB', 'FM', 'PKTFM', etc.)
97
67
  * @param {string} [bandwidth] - Optional bandwidth ('narrow', 'wide')
68
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
98
69
  */
99
- async setMode(mode, bandwidth) {
100
- return new Promise((resolve, reject) => {
70
+ async setMode(mode, bandwidth, vfo) {
71
+ if (vfo !== undefined) {
101
72
  if (bandwidth) {
102
- this._nativeInstance.setMode(mode, bandwidth, (err, result) => {
103
- if (err) {
104
- reject(new Error(err.message || 'Failed to set mode'));
105
- } else {
106
- resolve(result);
107
- }
108
- });
73
+ return this._nativeInstance.setMode(mode, bandwidth, vfo);
109
74
  } else {
110
- this._nativeInstance.setMode(mode, (err, result) => {
111
- if (err) {
112
- reject(new Error(err.message || 'Failed to set mode'));
113
- } else {
114
- resolve(result);
115
- }
116
- });
75
+ return this._nativeInstance.setMode(mode, vfo);
117
76
  }
118
- });
77
+ } else if (bandwidth) {
78
+ return this._nativeInstance.setMode(mode, bandwidth);
79
+ } else {
80
+ return this._nativeInstance.setMode(mode);
81
+ }
119
82
  }
120
83
 
121
84
  /**
@@ -123,31 +86,22 @@ class HamLib {
123
86
  * @param {boolean} state - true to enable PTT, false to disable
124
87
  */
125
88
  async setPtt(state) {
126
- return new Promise((resolve, reject) => {
127
- this._nativeInstance.setPtt(state, (err, result) => {
128
- if (err) {
129
- reject(new Error(err.message || 'Failed to set PTT'));
130
- } else {
131
- resolve(result);
132
- }
133
- });
134
- });
89
+ return this._nativeInstance.setPtt(state);
135
90
  }
136
91
 
137
92
  /**
138
93
  * Get current VFO
139
- * @returns {string} Current VFO identifier
94
+ * @param {Object} [options] - Options for VFO query
95
+ * @param {boolean} [options.fallbackToDefault=false] - Return default VFO instead of throwing error if not supported
96
+ * @returns {string} Current VFO identifier ('VFO-A', 'VFO-B', or 'VFO-CURR')
140
97
  */
141
- async getVfo() {
142
- return new Promise((resolve, reject) => {
143
- this._nativeInstance.getVfo((err, result) => {
144
- if (err) {
145
- reject(new Error(err.message || 'Failed to get VFO'));
146
- } else {
147
- resolve(result);
148
- }
149
- });
150
- });
98
+ async getVfo(options = {}) {
99
+ try {
100
+ return await this._nativeInstance.getVfo();
101
+ } catch (error) {
102
+ // 如果无线电不支持VFO查询,且用户要求回退到默认值
103
+ return 'VFO-CURR'; // 返回合理的默认值
104
+ }
151
105
  }
152
106
 
153
107
  /**
@@ -156,25 +110,11 @@ class HamLib {
156
110
  * @returns {number} Current frequency in hertz
157
111
  */
158
112
  async getFrequency(vfo) {
159
- return new Promise((resolve, reject) => {
160
- if (vfo) {
161
- this._nativeInstance.getFrequency(vfo, (err, result) => {
162
- if (err) {
163
- reject(new Error(err.message || 'Failed to get frequency'));
164
- } else {
165
- resolve(result);
166
- }
167
- });
168
- } else {
169
- this._nativeInstance.getFrequency((err, result) => {
170
- if (err) {
171
- reject(new Error(err.message || 'Failed to get frequency'));
172
- } else {
173
- resolve(result);
174
- }
175
- });
176
- }
177
- });
113
+ if (vfo) {
114
+ return this._nativeInstance.getFrequency(vfo);
115
+ } else {
116
+ return this._nativeInstance.getFrequency();
117
+ }
178
118
  }
179
119
 
180
120
  /**
@@ -182,31 +122,20 @@ class HamLib {
182
122
  * @returns {Object} Object containing mode and bandwidth information
183
123
  */
184
124
  async getMode() {
185
- return new Promise((resolve, reject) => {
186
- this._nativeInstance.getMode((err, result) => {
187
- if (err) {
188
- reject(new Error(err.message || 'Failed to get mode'));
189
- } else {
190
- resolve(result);
191
- }
192
- });
193
- });
125
+ return this._nativeInstance.getMode();
194
126
  }
195
127
 
196
128
  /**
197
129
  * Get current signal strength
130
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
198
131
  * @returns {number} Signal strength value
199
132
  */
200
- async getStrength() {
201
- return new Promise((resolve, reject) => {
202
- this._nativeInstance.getStrength((err, result) => {
203
- if (err) {
204
- reject(new Error(err.message || 'Failed to get signal strength'));
205
- } else {
206
- resolve(result);
207
- }
208
- });
209
- });
133
+ async getStrength(vfo) {
134
+ if (vfo) {
135
+ return this._nativeInstance.getStrength(vfo);
136
+ } else {
137
+ return this._nativeInstance.getStrength();
138
+ }
210
139
  }
211
140
 
212
141
  /**
@@ -214,15 +143,7 @@ class HamLib {
214
143
  * Connection can be re-established by calling open()
215
144
  */
216
145
  async close() {
217
- return new Promise((resolve, reject) => {
218
- this._nativeInstance.close((err, result) => {
219
- if (err) {
220
- reject(new Error(err.message || 'Failed to close connection'));
221
- } else {
222
- resolve(result);
223
- }
224
- });
225
- });
146
+ return this._nativeInstance.close();
226
147
  }
227
148
 
228
149
  /**
@@ -230,15 +151,7 @@ class HamLib {
230
151
  * Object reference should be deleted after calling this
231
152
  */
232
153
  async destroy() {
233
- return new Promise((resolve, reject) => {
234
- this._nativeInstance.destroy((err, result) => {
235
- if (err) {
236
- reject(new Error(err.message || 'Failed to destroy connection'));
237
- } else {
238
- resolve(result);
239
- }
240
- });
241
- });
154
+ return this._nativeInstance.destroy();
242
155
  }
243
156
 
244
157
  /**
@@ -256,7 +169,7 @@ class HamLib {
256
169
  * @param {number} channelNumber - Memory channel number
257
170
  * @param {Object} channelData - Channel data (frequency, mode, description, etc.)
258
171
  */
259
- setMemoryChannel(channelNumber, channelData) {
172
+ async setMemoryChannel(channelNumber, channelData) {
260
173
  return this._nativeInstance.setMemoryChannel(channelNumber, channelData);
261
174
  }
262
175
 
@@ -266,7 +179,7 @@ class HamLib {
266
179
  * @param {boolean} [readOnly=true] - Whether to read in read-only mode
267
180
  * @returns {Object} Channel data
268
181
  */
269
- getMemoryChannel(channelNumber, readOnly = true) {
182
+ async getMemoryChannel(channelNumber, readOnly = true) {
270
183
  return this._nativeInstance.getMemoryChannel(channelNumber, readOnly);
271
184
  }
272
185
 
@@ -274,7 +187,7 @@ class HamLib {
274
187
  * Select memory channel for operation
275
188
  * @param {number} channelNumber - Memory channel number to select
276
189
  */
277
- selectMemoryChannel(channelNumber) {
190
+ async selectMemoryChannel(channelNumber) {
278
191
  return this._nativeInstance.selectMemoryChannel(channelNumber);
279
192
  }
280
193
 
@@ -284,7 +197,7 @@ class HamLib {
284
197
  * Set RIT (Receiver Incremental Tuning) offset
285
198
  * @param {number} offsetHz - RIT offset in Hz
286
199
  */
287
- setRit(offsetHz) {
200
+ async setRit(offsetHz) {
288
201
  return this._nativeInstance.setRit(offsetHz);
289
202
  }
290
203
 
@@ -292,7 +205,7 @@ class HamLib {
292
205
  * Get current RIT offset
293
206
  * @returns {number} RIT offset in Hz
294
207
  */
295
- getRit() {
208
+ async getRit() {
296
209
  return this._nativeInstance.getRit();
297
210
  }
298
211
 
@@ -300,7 +213,7 @@ class HamLib {
300
213
  * Set XIT (Transmitter Incremental Tuning) offset
301
214
  * @param {number} offsetHz - XIT offset in Hz
302
215
  */
303
- setXit(offsetHz) {
216
+ async setXit(offsetHz) {
304
217
  return this._nativeInstance.setXit(offsetHz);
305
218
  }
306
219
 
@@ -308,7 +221,7 @@ class HamLib {
308
221
  * Get current XIT offset
309
222
  * @returns {number} XIT offset in Hz
310
223
  */
311
- getXit() {
224
+ async getXit() {
312
225
  return this._nativeInstance.getXit();
313
226
  }
314
227
 
@@ -316,7 +229,7 @@ class HamLib {
316
229
  * Clear both RIT and XIT offsets
317
230
  * @returns {boolean} Success status
318
231
  */
319
- clearRitXit() {
232
+ async clearRitXit() {
320
233
  return this._nativeInstance.clearRitXit();
321
234
  }
322
235
 
@@ -327,14 +240,14 @@ class HamLib {
327
240
  * @param {string} scanType - Scan type ('VFO', 'MEM', 'PROG', 'DELTA', 'PRIO')
328
241
  * @param {number} [channel=0] - Optional channel number for some scan types
329
242
  */
330
- startScan(scanType, channel = 0) {
243
+ async startScan(scanType, channel = 0) {
331
244
  return this._nativeInstance.startScan(scanType, channel);
332
245
  }
333
246
 
334
247
  /**
335
248
  * Stop scanning operation
336
249
  */
337
- stopScan() {
250
+ async stopScan() {
338
251
  return this._nativeInstance.stopScan();
339
252
  }
340
253
 
@@ -345,7 +258,7 @@ class HamLib {
345
258
  * @param {string} levelType - Level type ('AF', 'RF', 'SQL', 'RFPOWER', etc.)
346
259
  * @param {number} value - Level value (0.0-1.0 typically)
347
260
  */
348
- setLevel(levelType, value) {
261
+ async setLevel(levelType, value) {
349
262
  return this._nativeInstance.setLevel(levelType, value);
350
263
  }
351
264
 
@@ -354,7 +267,7 @@ class HamLib {
354
267
  * @param {string} levelType - Level type ('AF', 'RF', 'SQL', 'STRENGTH', etc.)
355
268
  * @returns {number} Level value
356
269
  */
357
- getLevel(levelType) {
270
+ async getLevel(levelType) {
358
271
  return this._nativeInstance.getLevel(levelType);
359
272
  }
360
273
 
@@ -373,7 +286,7 @@ class HamLib {
373
286
  * @param {string} functionType - Function type ('NB', 'COMP', 'VOX', 'TONE', etc.)
374
287
  * @param {boolean} enable - true to enable, false to disable
375
288
  */
376
- setFunction(functionType, enable) {
289
+ async setFunction(functionType, enable) {
377
290
  return this._nativeInstance.setFunction(functionType, enable);
378
291
  }
379
292
 
@@ -382,7 +295,7 @@ class HamLib {
382
295
  * @param {string} functionType - Function type ('NB', 'COMP', 'VOX', 'TONE', etc.)
383
296
  * @returns {boolean} Function enabled status
384
297
  */
385
- getFunction(functionType) {
298
+ async getFunction(functionType) {
386
299
  return this._nativeInstance.getFunction(functionType);
387
300
  }
388
301
 
@@ -399,54 +312,92 @@ class HamLib {
399
312
  /**
400
313
  * Set split mode TX frequency
401
314
  * @param {number} txFrequency - TX frequency in Hz
315
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
402
316
  */
403
- setSplitFreq(txFrequency) {
404
- return this._nativeInstance.setSplitFreq(txFrequency);
317
+ async setSplitFreq(txFrequency, vfo) {
318
+ if (vfo) {
319
+ return this._nativeInstance.setSplitFreq(txFrequency, vfo);
320
+ } else {
321
+ return this._nativeInstance.setSplitFreq(txFrequency);
322
+ }
405
323
  }
406
324
 
407
325
  /**
408
326
  * Get split mode TX frequency
327
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
409
328
  * @returns {number} TX frequency in Hz
410
329
  */
411
- getSplitFreq() {
412
- return this._nativeInstance.getSplitFreq();
330
+ async getSplitFreq(vfo) {
331
+ if (vfo) {
332
+ return this._nativeInstance.getSplitFreq(vfo);
333
+ } else {
334
+ return this._nativeInstance.getSplitFreq();
335
+ }
413
336
  }
414
337
 
415
338
  /**
416
339
  * Set split mode TX mode
417
340
  * @param {string} txMode - TX mode ('USB', 'LSB', 'FM', etc.)
418
341
  * @param {number} [txWidth] - Optional TX bandwidth
342
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
419
343
  */
420
- setSplitMode(txMode, txWidth) {
421
- if (txWidth !== undefined) {
344
+ async setSplitMode(txMode, txWidth, vfo) {
345
+ if (vfo !== undefined) {
346
+ if (txWidth !== undefined) {
347
+ return this._nativeInstance.setSplitMode(txMode, txWidth, vfo);
348
+ } else {
349
+ return this._nativeInstance.setSplitMode(txMode, vfo);
350
+ }
351
+ } else if (txWidth !== undefined) {
422
352
  return this._nativeInstance.setSplitMode(txMode, txWidth);
353
+ } else {
354
+ return this._nativeInstance.setSplitMode(txMode);
423
355
  }
424
- return this._nativeInstance.setSplitMode(txMode);
425
356
  }
426
357
 
427
358
  /**
428
359
  * Get split mode TX mode
360
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
429
361
  * @returns {Object} TX mode and width
430
362
  */
431
- getSplitMode() {
432
- return this._nativeInstance.getSplitMode();
363
+ async getSplitMode(vfo) {
364
+ if (vfo) {
365
+ return this._nativeInstance.getSplitMode(vfo);
366
+ } else {
367
+ return this._nativeInstance.getSplitMode();
368
+ }
433
369
  }
434
370
 
435
371
  /**
436
372
  * Enable/disable split operation
437
373
  * @param {boolean} enable - true to enable split, false to disable
438
- * @param {string} [txVfo='VFO-B'] - TX VFO ('VFO-A' or 'VFO-B')
374
+ * @param {string} [rxVfo] - RX VFO ('VFO-A' or 'VFO-B'). Default: current VFO
375
+ * @param {string} [txVfo] - TX VFO ('VFO-A' or 'VFO-B'). Default: VFO-B
439
376
  */
440
- setSplit(enable, txVfo = 'VFO-B') {
441
- return this._nativeInstance.setSplit(enable, txVfo);
377
+ async setSplit(enable, rxVfo, txVfo) {
378
+ if (txVfo !== undefined) {
379
+ // 3-parameter version: setSplit(enable, rxVfo, txVfo) - matches Hamlib API order
380
+ return this._nativeInstance.setSplit(enable, rxVfo, txVfo);
381
+ } else if (rxVfo !== undefined) {
382
+ // 2-parameter version: setSplit(enable, rxVfo)
383
+ return this._nativeInstance.setSplit(enable, rxVfo);
384
+ } else {
385
+ // 1-parameter version: setSplit(enable)
386
+ return this._nativeInstance.setSplit(enable);
387
+ }
442
388
  }
443
389
 
444
390
  /**
445
391
  * Get split operation status
392
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
446
393
  * @returns {Object} Split status and TX VFO
447
394
  */
448
- getSplit() {
449
- return this._nativeInstance.getSplit();
395
+ async getSplit(vfo) {
396
+ if (vfo) {
397
+ return this._nativeInstance.getSplit(vfo);
398
+ } else {
399
+ return this._nativeInstance.getSplit();
400
+ }
450
401
  }
451
402
 
452
403
  // VFO Operations
@@ -455,27 +406,13 @@ class HamLib {
455
406
  * Perform VFO operation
456
407
  * @param {string} operation - VFO operation ('CPY', 'XCHG', 'FROM_VFO', 'TO_VFO', 'MCL', 'UP', 'DOWN', 'BAND_UP', 'BAND_DOWN', 'LEFT', 'RIGHT', 'TUNE', 'TOGGLE')
457
408
  */
458
- vfoOperation(operation) {
409
+ async vfoOperation(operation) {
459
410
  return this._nativeInstance.vfoOperation(operation);
460
411
  }
461
412
 
462
413
  // Antenna Selection
463
414
 
464
- /**
465
- * Set antenna
466
- * @param {number} antenna - Antenna number (1, 2, 3, etc.)
467
- */
468
- setAntenna(antenna) {
469
- return this._nativeInstance.setAntenna(antenna);
470
- }
471
-
472
- /**
473
- * Get current antenna
474
- * @returns {number} Current antenna number
475
- */
476
- getAntenna() {
477
- return this._nativeInstance.getAntenna();
478
- }
415
+ // Note: setAntenna and getAntenna are defined later in the file with full VFO support
479
416
 
480
417
  // Serial Port Configuration
481
418
 
@@ -493,7 +430,7 @@ class HamLib {
493
430
  * // Set handshake to hardware
494
431
  * hamlib.setSerialConfig('serial_handshake', 'Hardware');
495
432
  */
496
- setSerialConfig(paramName, paramValue) {
433
+ async setSerialConfig(paramName, paramValue) {
497
434
  return this._nativeInstance.setSerialConfig(paramName, paramValue);
498
435
  }
499
436
 
@@ -508,7 +445,7 @@ class HamLib {
508
445
  * // Get current parity setting
509
446
  * const parity = hamlib.getSerialConfig('serial_parity');
510
447
  */
511
- getSerialConfig(paramName) {
448
+ async getSerialConfig(paramName) {
512
449
  return this._nativeInstance.getSerialConfig(paramName);
513
450
  }
514
451
 
@@ -525,7 +462,7 @@ class HamLib {
525
462
  * // Use CAT command for PTT
526
463
  * hamlib.setPttType('RIG');
527
464
  */
528
- setPttType(pttType) {
465
+ async setPttType(pttType) {
529
466
  return this._nativeInstance.setPttType(pttType);
530
467
  }
531
468
 
@@ -533,7 +470,7 @@ class HamLib {
533
470
  * Get current PTT type
534
471
  * @returns {string} Current PTT type
535
472
  */
536
- getPttType() {
473
+ async getPttType() {
537
474
  return this._nativeInstance.getPttType();
538
475
  }
539
476
 
@@ -550,7 +487,7 @@ class HamLib {
550
487
  * // Use CAT command for DCD
551
488
  * hamlib.setDcdType('RIG');
552
489
  */
553
- setDcdType(dcdType) {
490
+ async setDcdType(dcdType) {
554
491
  return this._nativeInstance.setDcdType(dcdType);
555
492
  }
556
493
 
@@ -558,7 +495,7 @@ class HamLib {
558
495
  * Get current DCD type
559
496
  * @returns {string} Current DCD type
560
497
  */
561
- getDcdType() {
498
+ async getDcdType() {
562
499
  return this._nativeInstance.getDcdType();
563
500
  }
564
501
 
@@ -573,6 +510,545 @@ class HamLib {
573
510
  getSupportedSerialConfigs() {
574
511
  return this._nativeInstance.getSupportedSerialConfigs();
575
512
  }
513
+
514
+ // Power Control
515
+
516
+ /**
517
+ * Set radio power status
518
+ * @param {number} status - Power status (0=OFF, 1=ON, 2=STANDBY, 4=OPERATE, 8=UNKNOWN)
519
+ * @returns {Promise<number>} Success status
520
+ * @example
521
+ * await rig.setPowerstat(1); // Power on
522
+ * await rig.setPowerstat(0); // Power off
523
+ * await rig.setPowerstat(2); // Standby mode
524
+ */
525
+ async setPowerstat(status) {
526
+ return this._nativeInstance.setPowerstat(status);
527
+ }
528
+
529
+ /**
530
+ * Get current radio power status
531
+ * @returns {Promise<number>} Power status (0=OFF, 1=ON, 2=STANDBY, 4=OPERATE, 8=UNKNOWN)
532
+ * @example
533
+ * const powerStatus = await rig.getPowerstat();
534
+ * if (powerStatus === 1) {
535
+ * console.log('Radio is powered on');
536
+ * }
537
+ */
538
+ async getPowerstat() {
539
+ return this._nativeInstance.getPowerstat();
540
+ }
541
+
542
+ // PTT Status Detection
543
+
544
+ /**
545
+ * Get current PTT status
546
+ * @param {string} [vfo] - Optional VFO to get PTT status from ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
547
+ * @returns {Promise<boolean>} PTT status (true if transmitting, false if receiving)
548
+ * @example
549
+ * const isTransmitting = await rig.getPtt();
550
+ * if (isTransmitting) {
551
+ * console.log('Radio is transmitting');
552
+ * }
553
+ */
554
+ async getPtt(vfo) {
555
+ if (vfo) {
556
+ return this._nativeInstance.getPtt(vfo);
557
+ } else {
558
+ return this._nativeInstance.getPtt();
559
+ }
560
+ }
561
+
562
+ // Data Carrier Detect
563
+
564
+ /**
565
+ * Get current DCD (Data Carrier Detect) status
566
+ * @param {string} [vfo] - Optional VFO to get DCD status from ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
567
+ * @returns {Promise<boolean>} DCD status (true if carrier detected, false if no carrier)
568
+ * @example
569
+ * const carrierDetected = await rig.getDcd();
570
+ * if (carrierDetected) {
571
+ * console.log('Carrier detected');
572
+ * }
573
+ */
574
+ async getDcd(vfo) {
575
+ if (vfo) {
576
+ return this._nativeInstance.getDcd(vfo);
577
+ } else {
578
+ return this._nativeInstance.getDcd();
579
+ }
580
+ }
581
+
582
+ // Tuning Step Control
583
+
584
+ /**
585
+ * Set tuning step
586
+ * @param {number} step - Tuning step in Hz
587
+ * @param {string} [vfo] - Optional VFO to set tuning step on ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
588
+ * @returns {Promise<number>} Success status
589
+ * @example
590
+ * await rig.setTuningStep(25000); // 25 kHz steps
591
+ * await rig.setTuningStep(12500); // 12.5 kHz steps
592
+ * await rig.setTuningStep(100); // 100 Hz steps for HF
593
+ */
594
+ async setTuningStep(step, vfo) {
595
+ if (vfo) {
596
+ return this._nativeInstance.setTuningStep(step, vfo);
597
+ } else {
598
+ return this._nativeInstance.setTuningStep(step);
599
+ }
600
+ }
601
+
602
+ /**
603
+ * Get current tuning step
604
+ * @param {string} [vfo] - Optional VFO to get tuning step from ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
605
+ * @returns {Promise<number>} Current tuning step in Hz
606
+ * @example
607
+ * const step = await rig.getTuningStep();
608
+ * console.log(`Current tuning step: ${step} Hz`);
609
+ */
610
+ async getTuningStep(vfo) {
611
+ if (vfo) {
612
+ return this._nativeInstance.getTuningStep(vfo);
613
+ } else {
614
+ return this._nativeInstance.getTuningStep();
615
+ }
616
+ }
617
+
618
+ // Repeater Control
619
+
620
+ /**
621
+ * Set repeater shift direction
622
+ * @param {string} shift - Repeater shift direction ('NONE', 'MINUS', 'PLUS', '-', '+')
623
+ * @param {string} [vfo] - Optional VFO to set repeater shift on ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
624
+ * @returns {Promise<number>} Success status
625
+ * @example
626
+ * await rig.setRepeaterShift('PLUS'); // Positive shift (+)
627
+ * await rig.setRepeaterShift('MINUS'); // Negative shift (-)
628
+ * await rig.setRepeaterShift('NONE'); // No shift (simplex)
629
+ */
630
+ async setRepeaterShift(shift, vfo) {
631
+ if (vfo) {
632
+ return this._nativeInstance.setRepeaterShift(shift, vfo);
633
+ } else {
634
+ return this._nativeInstance.setRepeaterShift(shift);
635
+ }
636
+ }
637
+
638
+ /**
639
+ * Get current repeater shift direction
640
+ * @param {string} [vfo] - Optional VFO to get repeater shift from ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
641
+ * @returns {Promise<string>} Current repeater shift direction
642
+ * @example
643
+ * const shift = await rig.getRepeaterShift();
644
+ * console.log(`Repeater shift: ${shift}`); // 'None', 'Minus', or 'Plus'
645
+ */
646
+ async getRepeaterShift(vfo) {
647
+ if (vfo) {
648
+ return this._nativeInstance.getRepeaterShift(vfo);
649
+ } else {
650
+ return this._nativeInstance.getRepeaterShift();
651
+ }
652
+ }
653
+
654
+ /**
655
+ * Set repeater offset frequency
656
+ * @param {number} offset - Repeater offset in Hz
657
+ * @param {string} [vfo] - Optional VFO to set repeater offset on ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
658
+ * @returns {Promise<number>} Success status
659
+ * @example
660
+ * await rig.setRepeaterOffset(600000); // 600 kHz offset (2m band)
661
+ * await rig.setRepeaterOffset(5000000); // 5 MHz offset (70cm band)
662
+ */
663
+ async setRepeaterOffset(offset, vfo) {
664
+ if (vfo) {
665
+ return this._nativeInstance.setRepeaterOffset(offset, vfo);
666
+ } else {
667
+ return this._nativeInstance.setRepeaterOffset(offset);
668
+ }
669
+ }
670
+
671
+ /**
672
+ * Get current repeater offset frequency
673
+ * @param {string} [vfo] - Optional VFO to get repeater offset from ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
674
+ * @returns {Promise<number>} Current repeater offset in Hz
675
+ * @example
676
+ * const offset = await rig.getRepeaterOffset();
677
+ * console.log(`Repeater offset: ${offset} Hz`);
678
+ */
679
+ async getRepeaterOffset(vfo) {
680
+ if (vfo) {
681
+ return this._nativeInstance.getRepeaterOffset(vfo);
682
+ } else {
683
+ return this._nativeInstance.getRepeaterOffset();
684
+ }
685
+ }
686
+
687
+ // CTCSS/DCS Tone Control
688
+
689
+ /**
690
+ * Set CTCSS tone frequency
691
+ * @param {number} tone - CTCSS tone frequency in tenths of Hz (e.g., 1000 for 100.0 Hz)
692
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
693
+ */
694
+ async setCtcssTone(tone, vfo) {
695
+ if (vfo) {
696
+ return this._nativeInstance.setCtcssTone(tone, vfo);
697
+ } else {
698
+ return this._nativeInstance.setCtcssTone(tone);
699
+ }
700
+ }
701
+
702
+ /**
703
+ * Get current CTCSS tone frequency
704
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
705
+ * @returns {number} Current CTCSS tone frequency in tenths of Hz
706
+ */
707
+ async getCtcssTone(vfo) {
708
+ if (vfo) {
709
+ return this._nativeInstance.getCtcssTone(vfo);
710
+ } else {
711
+ return this._nativeInstance.getCtcssTone();
712
+ }
713
+ }
714
+
715
+ /**
716
+ * Set DCS code
717
+ * @param {number} code - DCS code (e.g., 23, 174, 754)
718
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
719
+ */
720
+ async setDcsCode(code, vfo) {
721
+ if (vfo) {
722
+ return this._nativeInstance.setDcsCode(code, vfo);
723
+ } else {
724
+ return this._nativeInstance.setDcsCode(code);
725
+ }
726
+ }
727
+
728
+ /**
729
+ * Get current DCS code
730
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
731
+ * @returns {number} Current DCS code
732
+ */
733
+ async getDcsCode(vfo) {
734
+ if (vfo) {
735
+ return this._nativeInstance.getDcsCode(vfo);
736
+ } else {
737
+ return this._nativeInstance.getDcsCode();
738
+ }
739
+ }
740
+
741
+ /**
742
+ * Set CTCSS SQL (squelch) tone frequency
743
+ * @param {number} tone - CTCSS SQL tone frequency in tenths of Hz (e.g., 1000 for 100.0 Hz)
744
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
745
+ */
746
+ async setCtcssSql(tone, vfo) {
747
+ if (vfo) {
748
+ return this._nativeInstance.setCtcssSql(tone, vfo);
749
+ } else {
750
+ return this._nativeInstance.setCtcssSql(tone);
751
+ }
752
+ }
753
+
754
+ /**
755
+ * Get current CTCSS SQL tone frequency
756
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
757
+ * @returns {number} Current CTCSS SQL tone frequency in tenths of Hz
758
+ */
759
+ async getCtcssSql(vfo) {
760
+ if (vfo) {
761
+ return this._nativeInstance.getCtcssSql(vfo);
762
+ } else {
763
+ return this._nativeInstance.getCtcssSql();
764
+ }
765
+ }
766
+
767
+ /**
768
+ * Set DCS SQL (squelch) code
769
+ * @param {number} code - DCS SQL code (e.g., 23, 174, 754)
770
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
771
+ */
772
+ async setDcsSql(code, vfo) {
773
+ if (vfo) {
774
+ return this._nativeInstance.setDcsSql(code, vfo);
775
+ } else {
776
+ return this._nativeInstance.setDcsSql(code);
777
+ }
778
+ }
779
+
780
+ /**
781
+ * Get current DCS SQL code
782
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
783
+ * @returns {number} Current DCS SQL code
784
+ */
785
+ async getDcsSql(vfo) {
786
+ if (vfo) {
787
+ return this._nativeInstance.getDcsSql(vfo);
788
+ } else {
789
+ return this._nativeInstance.getDcsSql();
790
+ }
791
+ }
792
+
793
+ // Parameter Control
794
+
795
+ /**
796
+ * Set radio parameter
797
+ * @param {string} paramName - Parameter name (e.g., 'ANN', 'APO', 'BACKLIGHT', 'BEEP', 'TIME', 'BAT')
798
+ * @param {number} value - Parameter value (numeric)
799
+ */
800
+ async setParm(paramName, value) {
801
+ return this._nativeInstance.setParm(paramName, value);
802
+ }
803
+
804
+ /**
805
+ * Get radio parameter value
806
+ * @param {string} paramName - Parameter name (e.g., 'ANN', 'APO', 'BACKLIGHT', 'BEEP', 'TIME', 'BAT')
807
+ * @returns {number} Parameter value
808
+ */
809
+ async getParm(paramName) {
810
+ return this._nativeInstance.getParm(paramName);
811
+ }
812
+
813
+ // DTMF Support
814
+
815
+ /**
816
+ * Send DTMF digits
817
+ * @param {string} digits - DTMF digits to send (0-9, A-D, *, #)
818
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
819
+ */
820
+ async sendDtmf(digits, vfo) {
821
+ if (vfo) {
822
+ return this._nativeInstance.sendDtmf(digits, vfo);
823
+ } else {
824
+ return this._nativeInstance.sendDtmf(digits);
825
+ }
826
+ }
827
+
828
+ /**
829
+ * Receive DTMF digits
830
+ * @param {number} [maxLength=32] - Maximum number of digits to receive
831
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
832
+ * @returns {Object} Object containing digits and length
833
+ */
834
+ async recvDtmf(maxLength, vfo) {
835
+ if (vfo) {
836
+ return this._nativeInstance.recvDtmf(maxLength || 32, vfo);
837
+ } else {
838
+ return this._nativeInstance.recvDtmf(maxLength || 32);
839
+ }
840
+ }
841
+
842
+ // Memory Channel Advanced Operations
843
+
844
+ /**
845
+ * Get current memory channel number
846
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
847
+ * @returns {number} Current memory channel number
848
+ */
849
+ async getMem(vfo) {
850
+ if (vfo) {
851
+ return this._nativeInstance.getMem(vfo);
852
+ } else {
853
+ return this._nativeInstance.getMem();
854
+ }
855
+ }
856
+
857
+ /**
858
+ * Set memory bank
859
+ * @param {number} bank - Bank number to select
860
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
861
+ */
862
+ async setBank(bank, vfo) {
863
+ if (vfo) {
864
+ return this._nativeInstance.setBank(bank, vfo);
865
+ } else {
866
+ return this._nativeInstance.setBank(bank);
867
+ }
868
+ }
869
+
870
+ /**
871
+ * Get total number of memory channels available
872
+ * @returns {number} Total number of memory channels
873
+ */
874
+ async memCount() {
875
+ return this._nativeInstance.memCount();
876
+ }
877
+
878
+ // Morse Code Support
879
+
880
+ /**
881
+ * Send Morse code message
882
+ * @param {string} message - Morse code message to send (text will be converted to Morse)
883
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
884
+ */
885
+ async sendMorse(message, vfo) {
886
+ if (vfo) {
887
+ return this._nativeInstance.sendMorse(message, vfo);
888
+ } else {
889
+ return this._nativeInstance.sendMorse(message);
890
+ }
891
+ }
892
+
893
+ /**
894
+ * Stop current Morse code transmission
895
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
896
+ */
897
+ async stopMorse(vfo) {
898
+ if (vfo) {
899
+ return this._nativeInstance.stopMorse(vfo);
900
+ } else {
901
+ return this._nativeInstance.stopMorse();
902
+ }
903
+ }
904
+
905
+ /**
906
+ * Wait for Morse code transmission to complete
907
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
908
+ */
909
+ async waitMorse(vfo) {
910
+ if (vfo) {
911
+ return this._nativeInstance.waitMorse(vfo);
912
+ } else {
913
+ return this._nativeInstance.waitMorse();
914
+ }
915
+ }
916
+
917
+ // Voice Memory Support
918
+
919
+ /**
920
+ * Play voice memory channel
921
+ * @param {number} channel - Voice memory channel number to play
922
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
923
+ */
924
+ async sendVoiceMem(channel, vfo) {
925
+ if (vfo) {
926
+ return this._nativeInstance.sendVoiceMem(channel, vfo);
927
+ } else {
928
+ return this._nativeInstance.sendVoiceMem(channel);
929
+ }
930
+ }
931
+
932
+ /**
933
+ * Stop voice memory playback
934
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
935
+ */
936
+ async stopVoiceMem(vfo) {
937
+ if (vfo) {
938
+ return this._nativeInstance.stopVoiceMem(vfo);
939
+ } else {
940
+ return this._nativeInstance.stopVoiceMem();
941
+ }
942
+ }
943
+
944
+ // Complex Split Frequency/Mode Operations
945
+
946
+ /**
947
+ * Set split frequency and mode simultaneously
948
+ * @param {number} txFrequency - TX frequency in Hz
949
+ * @param {string} txMode - TX mode ('USB', 'LSB', 'FM', etc.)
950
+ * @param {number} txWidth - TX bandwidth in Hz
951
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
952
+ */
953
+ async setSplitFreqMode(txFrequency, txMode, txWidth, vfo) {
954
+ if (vfo) {
955
+ return this._nativeInstance.setSplitFreqMode(txFrequency, txMode, txWidth, vfo);
956
+ } else {
957
+ return this._nativeInstance.setSplitFreqMode(txFrequency, txMode, txWidth);
958
+ }
959
+ }
960
+
961
+ /**
962
+ * Get split frequency and mode information
963
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
964
+ * @returns {Object} Object containing TX frequency, mode, and width
965
+ */
966
+ async getSplitFreqMode(vfo) {
967
+ if (vfo) {
968
+ return this._nativeInstance.getSplitFreqMode(vfo);
969
+ } else {
970
+ return this._nativeInstance.getSplitFreqMode();
971
+ }
972
+ }
973
+
974
+ // Antenna Control
975
+
976
+ /**
977
+ * Set antenna selection
978
+ * @param {number} antenna - Antenna number to select (1-based)
979
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
980
+ * @returns {Promise<number>} Success status
981
+ * @example
982
+ * await rig.setAntenna(1); // Select antenna 1
983
+ * await rig.setAntenna(2); // Select antenna 2
984
+ */
985
+ async setAntenna(antenna, vfo) {
986
+ if (vfo) {
987
+ return this._nativeInstance.setAntenna(antenna, vfo);
988
+ } else {
989
+ return this._nativeInstance.setAntenna(antenna);
990
+ }
991
+ }
992
+
993
+ /**
994
+ * Get comprehensive antenna information
995
+ * @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
996
+ * @returns {Promise<Object>} Antenna information object containing:
997
+ * - currentAntenna: Currently selected antenna
998
+ * - txAntenna: TX antenna selection
999
+ * - rxAntenna: RX antenna selection
1000
+ * - option: Additional antenna option/parameter
1001
+ * @example
1002
+ * const antennaInfo = await rig.getAntenna();
1003
+ * console.log(`Current: ${antennaInfo.currentAntenna}, TX: ${antennaInfo.txAntenna}, RX: ${antennaInfo.rxAntenna}`);
1004
+ */
1005
+ async getAntenna(vfo) {
1006
+ if (vfo) {
1007
+ return this._nativeInstance.getAntenna(vfo);
1008
+ } else {
1009
+ return this._nativeInstance.getAntenna();
1010
+ }
1011
+ }
1012
+
1013
+ // Power Conversion Functions
1014
+
1015
+ /**
1016
+ * Convert power level to milliwatts
1017
+ * @param {number} power - Power level (0.0-1.0)
1018
+ * @param {number} frequency - Frequency in Hz
1019
+ * @param {string} mode - Radio mode ('USB', 'LSB', 'FM', etc.)
1020
+ * @returns {Promise<number>} Power in milliwatts
1021
+ * @example
1022
+ * const milliwatts = await rig.power2mW(0.5, 14205000, 'USB');
1023
+ * console.log(`50% power = ${milliwatts} mW`);
1024
+ */
1025
+ async power2mW(power, frequency, mode) {
1026
+ return this._nativeInstance.power2mW(power, frequency, mode);
1027
+ }
1028
+
1029
+ /**
1030
+ * Convert milliwatts to power level
1031
+ * @param {number} milliwatts - Power in milliwatts
1032
+ * @param {number} frequency - Frequency in Hz
1033
+ * @param {string} mode - Radio mode ('USB', 'LSB', 'FM', etc.)
1034
+ * @returns {Promise<number>} Power level (0.0-1.0)
1035
+ * @example
1036
+ * const powerLevel = await rig.mW2power(5000, 14205000, 'USB');
1037
+ * console.log(`5000 mW = ${(powerLevel * 100).toFixed(1)}% power`);
1038
+ */
1039
+ async mW2power(milliwatts, frequency, mode) {
1040
+ return this._nativeInstance.mW2power(milliwatts, frequency, mode);
1041
+ }
1042
+
1043
+ // Reset Function
1044
+
1045
+ /**
1046
+ * Reset radio to default state
1047
+ * @param {string} [resetType='SOFT'] - Reset type ('NONE', 'SOFT', 'VFO', 'MCALL', 'MASTER')
1048
+ */
1049
+ async reset(resetType = 'SOFT') {
1050
+ return this._nativeInstance.reset(resetType);
1051
+ }
576
1052
  }
577
1053
 
578
1054
  // Export for CommonJS