hamlib 0.1.6 → 0.1.8
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 +299 -0
- package/index.d.ts +593 -69
- package/lib/index.js +695 -190
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/hamlib.node +0 -0
- package/prebuilds/linux-arm64/hamlib.node +0 -0
- package/prebuilds/linux-x64/hamlib.node +0 -0
- package/src/hamlib.cpp +4249 -1592
- package/src/hamlib.h +69 -2
- package/src/hamlib_compat.h +44 -0
- package/Readme.md +0 -593
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
|
|
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
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
70
|
+
async setMode(mode, bandwidth, vfo) {
|
|
71
|
+
if (vfo !== undefined) {
|
|
101
72
|
if (bandwidth) {
|
|
102
|
-
this._nativeInstance.setMode(mode, bandwidth,
|
|
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,
|
|
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
|
|
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
|
-
* @
|
|
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
|
-
|
|
143
|
-
this._nativeInstance.getVfo(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
|
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
|
-
|
|
202
|
-
this._nativeInstance.getStrength(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
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} [
|
|
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
|
|
441
|
-
|
|
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
|
-
|
|
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,60 +406,75 @@ 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
|
|
|
482
419
|
/**
|
|
483
420
|
* Set serial port configuration parameter
|
|
484
|
-
* @param {string} paramName - Parameter name
|
|
421
|
+
* @param {string} paramName - Parameter name:
|
|
422
|
+
* - Serial settings: 'data_bits', 'stop_bits', 'serial_parity', 'serial_handshake'
|
|
423
|
+
* - Control signals: 'rts_state', 'dtr_state'
|
|
424
|
+
* - Communication: 'rate', 'timeout', 'retry'
|
|
425
|
+
* - Timing: 'write_delay', 'post_write_delay'
|
|
426
|
+
* - Advanced: 'flushx'
|
|
485
427
|
* @param {string} paramValue - Parameter value
|
|
486
428
|
* @example
|
|
487
|
-
* //
|
|
429
|
+
* // Basic serial settings
|
|
488
430
|
* hamlib.setSerialConfig('data_bits', '8');
|
|
489
|
-
*
|
|
490
|
-
* // Set parity to even
|
|
431
|
+
* hamlib.setSerialConfig('stop_bits', '1');
|
|
491
432
|
* hamlib.setSerialConfig('serial_parity', 'Even');
|
|
492
|
-
*
|
|
493
|
-
* // Set handshake to hardware
|
|
494
433
|
* hamlib.setSerialConfig('serial_handshake', 'Hardware');
|
|
434
|
+
*
|
|
435
|
+
* // Control signals
|
|
436
|
+
* hamlib.setSerialConfig('rts_state', 'ON');
|
|
437
|
+
* hamlib.setSerialConfig('dtr_state', 'OFF');
|
|
438
|
+
*
|
|
439
|
+
* // Communication settings
|
|
440
|
+
* hamlib.setSerialConfig('rate', '115200');
|
|
441
|
+
* hamlib.setSerialConfig('timeout', '1000');
|
|
442
|
+
* hamlib.setSerialConfig('retry', '3');
|
|
443
|
+
*
|
|
444
|
+
* // Timing control
|
|
445
|
+
* hamlib.setSerialConfig('write_delay', '10');
|
|
446
|
+
* hamlib.setSerialConfig('post_write_delay', '50');
|
|
447
|
+
*
|
|
448
|
+
* // Advanced features
|
|
449
|
+
* hamlib.setSerialConfig('flushx', 'true');
|
|
495
450
|
*/
|
|
496
|
-
setSerialConfig(paramName, paramValue) {
|
|
451
|
+
async setSerialConfig(paramName, paramValue) {
|
|
497
452
|
return this._nativeInstance.setSerialConfig(paramName, paramValue);
|
|
498
453
|
}
|
|
499
454
|
|
|
500
455
|
/**
|
|
501
456
|
* Get serial port configuration parameter
|
|
502
|
-
* @param {string} paramName - Parameter name to retrieve
|
|
457
|
+
* @param {string} paramName - Parameter name to retrieve (same as setSerialConfig)
|
|
503
458
|
* @returns {string} Parameter value
|
|
504
459
|
* @example
|
|
505
|
-
* // Get
|
|
460
|
+
* // Get basic serial settings
|
|
506
461
|
* const dataBits = hamlib.getSerialConfig('data_bits');
|
|
507
|
-
*
|
|
508
|
-
* // Get current parity setting
|
|
509
462
|
* const parity = hamlib.getSerialConfig('serial_parity');
|
|
463
|
+
* const handshake = hamlib.getSerialConfig('serial_handshake');
|
|
464
|
+
*
|
|
465
|
+
* // Get communication settings
|
|
466
|
+
* const rate = hamlib.getSerialConfig('rate');
|
|
467
|
+
* const timeout = hamlib.getSerialConfig('timeout');
|
|
468
|
+
*
|
|
469
|
+
* // Get control signals state
|
|
470
|
+
* const rtsState = hamlib.getSerialConfig('rts_state');
|
|
471
|
+
* const dtrState = hamlib.getSerialConfig('dtr_state');
|
|
472
|
+
*
|
|
473
|
+
* // Get timing settings
|
|
474
|
+
* const writeDelay = hamlib.getSerialConfig('write_delay');
|
|
475
|
+
* const flushx = hamlib.getSerialConfig('flushx');
|
|
510
476
|
*/
|
|
511
|
-
getSerialConfig(paramName) {
|
|
477
|
+
async getSerialConfig(paramName) {
|
|
512
478
|
return this._nativeInstance.getSerialConfig(paramName);
|
|
513
479
|
}
|
|
514
480
|
|
|
@@ -525,7 +491,7 @@ class HamLib {
|
|
|
525
491
|
* // Use CAT command for PTT
|
|
526
492
|
* hamlib.setPttType('RIG');
|
|
527
493
|
*/
|
|
528
|
-
setPttType(pttType) {
|
|
494
|
+
async setPttType(pttType) {
|
|
529
495
|
return this._nativeInstance.setPttType(pttType);
|
|
530
496
|
}
|
|
531
497
|
|
|
@@ -533,7 +499,7 @@ class HamLib {
|
|
|
533
499
|
* Get current PTT type
|
|
534
500
|
* @returns {string} Current PTT type
|
|
535
501
|
*/
|
|
536
|
-
getPttType() {
|
|
502
|
+
async getPttType() {
|
|
537
503
|
return this._nativeInstance.getPttType();
|
|
538
504
|
}
|
|
539
505
|
|
|
@@ -550,7 +516,7 @@ class HamLib {
|
|
|
550
516
|
* // Use CAT command for DCD
|
|
551
517
|
* hamlib.setDcdType('RIG');
|
|
552
518
|
*/
|
|
553
|
-
setDcdType(dcdType) {
|
|
519
|
+
async setDcdType(dcdType) {
|
|
554
520
|
return this._nativeInstance.setDcdType(dcdType);
|
|
555
521
|
}
|
|
556
522
|
|
|
@@ -558,7 +524,7 @@ class HamLib {
|
|
|
558
524
|
* Get current DCD type
|
|
559
525
|
* @returns {string} Current DCD type
|
|
560
526
|
*/
|
|
561
|
-
getDcdType() {
|
|
527
|
+
async getDcdType() {
|
|
562
528
|
return this._nativeInstance.getDcdType();
|
|
563
529
|
}
|
|
564
530
|
|
|
@@ -573,6 +539,545 @@ class HamLib {
|
|
|
573
539
|
getSupportedSerialConfigs() {
|
|
574
540
|
return this._nativeInstance.getSupportedSerialConfigs();
|
|
575
541
|
}
|
|
542
|
+
|
|
543
|
+
// Power Control
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Set radio power status
|
|
547
|
+
* @param {number} status - Power status (0=OFF, 1=ON, 2=STANDBY, 4=OPERATE, 8=UNKNOWN)
|
|
548
|
+
* @returns {Promise<number>} Success status
|
|
549
|
+
* @example
|
|
550
|
+
* await rig.setPowerstat(1); // Power on
|
|
551
|
+
* await rig.setPowerstat(0); // Power off
|
|
552
|
+
* await rig.setPowerstat(2); // Standby mode
|
|
553
|
+
*/
|
|
554
|
+
async setPowerstat(status) {
|
|
555
|
+
return this._nativeInstance.setPowerstat(status);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Get current radio power status
|
|
560
|
+
* @returns {Promise<number>} Power status (0=OFF, 1=ON, 2=STANDBY, 4=OPERATE, 8=UNKNOWN)
|
|
561
|
+
* @example
|
|
562
|
+
* const powerStatus = await rig.getPowerstat();
|
|
563
|
+
* if (powerStatus === 1) {
|
|
564
|
+
* console.log('Radio is powered on');
|
|
565
|
+
* }
|
|
566
|
+
*/
|
|
567
|
+
async getPowerstat() {
|
|
568
|
+
return this._nativeInstance.getPowerstat();
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// PTT Status Detection
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Get current PTT status
|
|
575
|
+
* @param {string} [vfo] - Optional VFO to get PTT status from ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
|
|
576
|
+
* @returns {Promise<boolean>} PTT status (true if transmitting, false if receiving)
|
|
577
|
+
* @example
|
|
578
|
+
* const isTransmitting = await rig.getPtt();
|
|
579
|
+
* if (isTransmitting) {
|
|
580
|
+
* console.log('Radio is transmitting');
|
|
581
|
+
* }
|
|
582
|
+
*/
|
|
583
|
+
async getPtt(vfo) {
|
|
584
|
+
if (vfo) {
|
|
585
|
+
return this._nativeInstance.getPtt(vfo);
|
|
586
|
+
} else {
|
|
587
|
+
return this._nativeInstance.getPtt();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// Data Carrier Detect
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Get current DCD (Data Carrier Detect) status
|
|
595
|
+
* @param {string} [vfo] - Optional VFO to get DCD status from ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
|
|
596
|
+
* @returns {Promise<boolean>} DCD status (true if carrier detected, false if no carrier)
|
|
597
|
+
* @example
|
|
598
|
+
* const carrierDetected = await rig.getDcd();
|
|
599
|
+
* if (carrierDetected) {
|
|
600
|
+
* console.log('Carrier detected');
|
|
601
|
+
* }
|
|
602
|
+
*/
|
|
603
|
+
async getDcd(vfo) {
|
|
604
|
+
if (vfo) {
|
|
605
|
+
return this._nativeInstance.getDcd(vfo);
|
|
606
|
+
} else {
|
|
607
|
+
return this._nativeInstance.getDcd();
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// Tuning Step Control
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Set tuning step
|
|
615
|
+
* @param {number} step - Tuning step in Hz
|
|
616
|
+
* @param {string} [vfo] - Optional VFO to set tuning step on ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
|
|
617
|
+
* @returns {Promise<number>} Success status
|
|
618
|
+
* @example
|
|
619
|
+
* await rig.setTuningStep(25000); // 25 kHz steps
|
|
620
|
+
* await rig.setTuningStep(12500); // 12.5 kHz steps
|
|
621
|
+
* await rig.setTuningStep(100); // 100 Hz steps for HF
|
|
622
|
+
*/
|
|
623
|
+
async setTuningStep(step, vfo) {
|
|
624
|
+
if (vfo) {
|
|
625
|
+
return this._nativeInstance.setTuningStep(step, vfo);
|
|
626
|
+
} else {
|
|
627
|
+
return this._nativeInstance.setTuningStep(step);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Get current tuning step
|
|
633
|
+
* @param {string} [vfo] - Optional VFO to get tuning step from ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
|
|
634
|
+
* @returns {Promise<number>} Current tuning step in Hz
|
|
635
|
+
* @example
|
|
636
|
+
* const step = await rig.getTuningStep();
|
|
637
|
+
* console.log(`Current tuning step: ${step} Hz`);
|
|
638
|
+
*/
|
|
639
|
+
async getTuningStep(vfo) {
|
|
640
|
+
if (vfo) {
|
|
641
|
+
return this._nativeInstance.getTuningStep(vfo);
|
|
642
|
+
} else {
|
|
643
|
+
return this._nativeInstance.getTuningStep();
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// Repeater Control
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Set repeater shift direction
|
|
651
|
+
* @param {string} shift - Repeater shift direction ('NONE', 'MINUS', 'PLUS', '-', '+')
|
|
652
|
+
* @param {string} [vfo] - Optional VFO to set repeater shift on ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
|
|
653
|
+
* @returns {Promise<number>} Success status
|
|
654
|
+
* @example
|
|
655
|
+
* await rig.setRepeaterShift('PLUS'); // Positive shift (+)
|
|
656
|
+
* await rig.setRepeaterShift('MINUS'); // Negative shift (-)
|
|
657
|
+
* await rig.setRepeaterShift('NONE'); // No shift (simplex)
|
|
658
|
+
*/
|
|
659
|
+
async setRepeaterShift(shift, vfo) {
|
|
660
|
+
if (vfo) {
|
|
661
|
+
return this._nativeInstance.setRepeaterShift(shift, vfo);
|
|
662
|
+
} else {
|
|
663
|
+
return this._nativeInstance.setRepeaterShift(shift);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Get current repeater shift direction
|
|
669
|
+
* @param {string} [vfo] - Optional VFO to get repeater shift from ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
|
|
670
|
+
* @returns {Promise<string>} Current repeater shift direction
|
|
671
|
+
* @example
|
|
672
|
+
* const shift = await rig.getRepeaterShift();
|
|
673
|
+
* console.log(`Repeater shift: ${shift}`); // 'None', 'Minus', or 'Plus'
|
|
674
|
+
*/
|
|
675
|
+
async getRepeaterShift(vfo) {
|
|
676
|
+
if (vfo) {
|
|
677
|
+
return this._nativeInstance.getRepeaterShift(vfo);
|
|
678
|
+
} else {
|
|
679
|
+
return this._nativeInstance.getRepeaterShift();
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Set repeater offset frequency
|
|
685
|
+
* @param {number} offset - Repeater offset in Hz
|
|
686
|
+
* @param {string} [vfo] - Optional VFO to set repeater offset on ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
|
|
687
|
+
* @returns {Promise<number>} Success status
|
|
688
|
+
* @example
|
|
689
|
+
* await rig.setRepeaterOffset(600000); // 600 kHz offset (2m band)
|
|
690
|
+
* await rig.setRepeaterOffset(5000000); // 5 MHz offset (70cm band)
|
|
691
|
+
*/
|
|
692
|
+
async setRepeaterOffset(offset, vfo) {
|
|
693
|
+
if (vfo) {
|
|
694
|
+
return this._nativeInstance.setRepeaterOffset(offset, vfo);
|
|
695
|
+
} else {
|
|
696
|
+
return this._nativeInstance.setRepeaterOffset(offset);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Get current repeater offset frequency
|
|
702
|
+
* @param {string} [vfo] - Optional VFO to get repeater offset from ('VFO-A' or 'VFO-B'). If not specified, uses current VFO
|
|
703
|
+
* @returns {Promise<number>} Current repeater offset in Hz
|
|
704
|
+
* @example
|
|
705
|
+
* const offset = await rig.getRepeaterOffset();
|
|
706
|
+
* console.log(`Repeater offset: ${offset} Hz`);
|
|
707
|
+
*/
|
|
708
|
+
async getRepeaterOffset(vfo) {
|
|
709
|
+
if (vfo) {
|
|
710
|
+
return this._nativeInstance.getRepeaterOffset(vfo);
|
|
711
|
+
} else {
|
|
712
|
+
return this._nativeInstance.getRepeaterOffset();
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
// CTCSS/DCS Tone Control
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Set CTCSS tone frequency
|
|
720
|
+
* @param {number} tone - CTCSS tone frequency in tenths of Hz (e.g., 1000 for 100.0 Hz)
|
|
721
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
722
|
+
*/
|
|
723
|
+
async setCtcssTone(tone, vfo) {
|
|
724
|
+
if (vfo) {
|
|
725
|
+
return this._nativeInstance.setCtcssTone(tone, vfo);
|
|
726
|
+
} else {
|
|
727
|
+
return this._nativeInstance.setCtcssTone(tone);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Get current CTCSS tone frequency
|
|
733
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
734
|
+
* @returns {number} Current CTCSS tone frequency in tenths of Hz
|
|
735
|
+
*/
|
|
736
|
+
async getCtcssTone(vfo) {
|
|
737
|
+
if (vfo) {
|
|
738
|
+
return this._nativeInstance.getCtcssTone(vfo);
|
|
739
|
+
} else {
|
|
740
|
+
return this._nativeInstance.getCtcssTone();
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Set DCS code
|
|
746
|
+
* @param {number} code - DCS code (e.g., 23, 174, 754)
|
|
747
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
748
|
+
*/
|
|
749
|
+
async setDcsCode(code, vfo) {
|
|
750
|
+
if (vfo) {
|
|
751
|
+
return this._nativeInstance.setDcsCode(code, vfo);
|
|
752
|
+
} else {
|
|
753
|
+
return this._nativeInstance.setDcsCode(code);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Get current DCS code
|
|
759
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
760
|
+
* @returns {number} Current DCS code
|
|
761
|
+
*/
|
|
762
|
+
async getDcsCode(vfo) {
|
|
763
|
+
if (vfo) {
|
|
764
|
+
return this._nativeInstance.getDcsCode(vfo);
|
|
765
|
+
} else {
|
|
766
|
+
return this._nativeInstance.getDcsCode();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Set CTCSS SQL (squelch) tone frequency
|
|
772
|
+
* @param {number} tone - CTCSS SQL tone frequency in tenths of Hz (e.g., 1000 for 100.0 Hz)
|
|
773
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
774
|
+
*/
|
|
775
|
+
async setCtcssSql(tone, vfo) {
|
|
776
|
+
if (vfo) {
|
|
777
|
+
return this._nativeInstance.setCtcssSql(tone, vfo);
|
|
778
|
+
} else {
|
|
779
|
+
return this._nativeInstance.setCtcssSql(tone);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Get current CTCSS SQL tone frequency
|
|
785
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
786
|
+
* @returns {number} Current CTCSS SQL tone frequency in tenths of Hz
|
|
787
|
+
*/
|
|
788
|
+
async getCtcssSql(vfo) {
|
|
789
|
+
if (vfo) {
|
|
790
|
+
return this._nativeInstance.getCtcssSql(vfo);
|
|
791
|
+
} else {
|
|
792
|
+
return this._nativeInstance.getCtcssSql();
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Set DCS SQL (squelch) code
|
|
798
|
+
* @param {number} code - DCS SQL code (e.g., 23, 174, 754)
|
|
799
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
800
|
+
*/
|
|
801
|
+
async setDcsSql(code, vfo) {
|
|
802
|
+
if (vfo) {
|
|
803
|
+
return this._nativeInstance.setDcsSql(code, vfo);
|
|
804
|
+
} else {
|
|
805
|
+
return this._nativeInstance.setDcsSql(code);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Get current DCS SQL code
|
|
811
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
812
|
+
* @returns {number} Current DCS SQL code
|
|
813
|
+
*/
|
|
814
|
+
async getDcsSql(vfo) {
|
|
815
|
+
if (vfo) {
|
|
816
|
+
return this._nativeInstance.getDcsSql(vfo);
|
|
817
|
+
} else {
|
|
818
|
+
return this._nativeInstance.getDcsSql();
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// Parameter Control
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Set radio parameter
|
|
826
|
+
* @param {string} paramName - Parameter name (e.g., 'ANN', 'APO', 'BACKLIGHT', 'BEEP', 'TIME', 'BAT')
|
|
827
|
+
* @param {number} value - Parameter value (numeric)
|
|
828
|
+
*/
|
|
829
|
+
async setParm(paramName, value) {
|
|
830
|
+
return this._nativeInstance.setParm(paramName, value);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Get radio parameter value
|
|
835
|
+
* @param {string} paramName - Parameter name (e.g., 'ANN', 'APO', 'BACKLIGHT', 'BEEP', 'TIME', 'BAT')
|
|
836
|
+
* @returns {number} Parameter value
|
|
837
|
+
*/
|
|
838
|
+
async getParm(paramName) {
|
|
839
|
+
return this._nativeInstance.getParm(paramName);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
// DTMF Support
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Send DTMF digits
|
|
846
|
+
* @param {string} digits - DTMF digits to send (0-9, A-D, *, #)
|
|
847
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
848
|
+
*/
|
|
849
|
+
async sendDtmf(digits, vfo) {
|
|
850
|
+
if (vfo) {
|
|
851
|
+
return this._nativeInstance.sendDtmf(digits, vfo);
|
|
852
|
+
} else {
|
|
853
|
+
return this._nativeInstance.sendDtmf(digits);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Receive DTMF digits
|
|
859
|
+
* @param {number} [maxLength=32] - Maximum number of digits to receive
|
|
860
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
861
|
+
* @returns {Object} Object containing digits and length
|
|
862
|
+
*/
|
|
863
|
+
async recvDtmf(maxLength, vfo) {
|
|
864
|
+
if (vfo) {
|
|
865
|
+
return this._nativeInstance.recvDtmf(maxLength || 32, vfo);
|
|
866
|
+
} else {
|
|
867
|
+
return this._nativeInstance.recvDtmf(maxLength || 32);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
// Memory Channel Advanced Operations
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* Get current memory channel number
|
|
875
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
876
|
+
* @returns {number} Current memory channel number
|
|
877
|
+
*/
|
|
878
|
+
async getMem(vfo) {
|
|
879
|
+
if (vfo) {
|
|
880
|
+
return this._nativeInstance.getMem(vfo);
|
|
881
|
+
} else {
|
|
882
|
+
return this._nativeInstance.getMem();
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Set memory bank
|
|
888
|
+
* @param {number} bank - Bank number to select
|
|
889
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
890
|
+
*/
|
|
891
|
+
async setBank(bank, vfo) {
|
|
892
|
+
if (vfo) {
|
|
893
|
+
return this._nativeInstance.setBank(bank, vfo);
|
|
894
|
+
} else {
|
|
895
|
+
return this._nativeInstance.setBank(bank);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Get total number of memory channels available
|
|
901
|
+
* @returns {number} Total number of memory channels
|
|
902
|
+
*/
|
|
903
|
+
async memCount() {
|
|
904
|
+
return this._nativeInstance.memCount();
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// Morse Code Support
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Send Morse code message
|
|
911
|
+
* @param {string} message - Morse code message to send (text will be converted to Morse)
|
|
912
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
913
|
+
*/
|
|
914
|
+
async sendMorse(message, vfo) {
|
|
915
|
+
if (vfo) {
|
|
916
|
+
return this._nativeInstance.sendMorse(message, vfo);
|
|
917
|
+
} else {
|
|
918
|
+
return this._nativeInstance.sendMorse(message);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Stop current Morse code transmission
|
|
924
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
925
|
+
*/
|
|
926
|
+
async stopMorse(vfo) {
|
|
927
|
+
if (vfo) {
|
|
928
|
+
return this._nativeInstance.stopMorse(vfo);
|
|
929
|
+
} else {
|
|
930
|
+
return this._nativeInstance.stopMorse();
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Wait for Morse code transmission to complete
|
|
936
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
937
|
+
*/
|
|
938
|
+
async waitMorse(vfo) {
|
|
939
|
+
if (vfo) {
|
|
940
|
+
return this._nativeInstance.waitMorse(vfo);
|
|
941
|
+
} else {
|
|
942
|
+
return this._nativeInstance.waitMorse();
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
// Voice Memory Support
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Play voice memory channel
|
|
950
|
+
* @param {number} channel - Voice memory channel number to play
|
|
951
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
952
|
+
*/
|
|
953
|
+
async sendVoiceMem(channel, vfo) {
|
|
954
|
+
if (vfo) {
|
|
955
|
+
return this._nativeInstance.sendVoiceMem(channel, vfo);
|
|
956
|
+
} else {
|
|
957
|
+
return this._nativeInstance.sendVoiceMem(channel);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Stop voice memory playback
|
|
963
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
964
|
+
*/
|
|
965
|
+
async stopVoiceMem(vfo) {
|
|
966
|
+
if (vfo) {
|
|
967
|
+
return this._nativeInstance.stopVoiceMem(vfo);
|
|
968
|
+
} else {
|
|
969
|
+
return this._nativeInstance.stopVoiceMem();
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
// Complex Split Frequency/Mode Operations
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Set split frequency and mode simultaneously
|
|
977
|
+
* @param {number} txFrequency - TX frequency in Hz
|
|
978
|
+
* @param {string} txMode - TX mode ('USB', 'LSB', 'FM', etc.)
|
|
979
|
+
* @param {number} txWidth - TX bandwidth in Hz
|
|
980
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
981
|
+
*/
|
|
982
|
+
async setSplitFreqMode(txFrequency, txMode, txWidth, vfo) {
|
|
983
|
+
if (vfo) {
|
|
984
|
+
return this._nativeInstance.setSplitFreqMode(txFrequency, txMode, txWidth, vfo);
|
|
985
|
+
} else {
|
|
986
|
+
return this._nativeInstance.setSplitFreqMode(txFrequency, txMode, txWidth);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Get split frequency and mode information
|
|
992
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
993
|
+
* @returns {Object} Object containing TX frequency, mode, and width
|
|
994
|
+
*/
|
|
995
|
+
async getSplitFreqMode(vfo) {
|
|
996
|
+
if (vfo) {
|
|
997
|
+
return this._nativeInstance.getSplitFreqMode(vfo);
|
|
998
|
+
} else {
|
|
999
|
+
return this._nativeInstance.getSplitFreqMode();
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// Antenna Control
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* Set antenna selection
|
|
1007
|
+
* @param {number} antenna - Antenna number to select (1-based)
|
|
1008
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
1009
|
+
* @returns {Promise<number>} Success status
|
|
1010
|
+
* @example
|
|
1011
|
+
* await rig.setAntenna(1); // Select antenna 1
|
|
1012
|
+
* await rig.setAntenna(2); // Select antenna 2
|
|
1013
|
+
*/
|
|
1014
|
+
async setAntenna(antenna, vfo) {
|
|
1015
|
+
if (vfo) {
|
|
1016
|
+
return this._nativeInstance.setAntenna(antenna, vfo);
|
|
1017
|
+
} else {
|
|
1018
|
+
return this._nativeInstance.setAntenna(antenna);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Get comprehensive antenna information
|
|
1024
|
+
* @param {string} [vfo] - Optional VFO ('VFO-A' or 'VFO-B')
|
|
1025
|
+
* @returns {Promise<Object>} Antenna information object containing:
|
|
1026
|
+
* - currentAntenna: Currently selected antenna
|
|
1027
|
+
* - txAntenna: TX antenna selection
|
|
1028
|
+
* - rxAntenna: RX antenna selection
|
|
1029
|
+
* - option: Additional antenna option/parameter
|
|
1030
|
+
* @example
|
|
1031
|
+
* const antennaInfo = await rig.getAntenna();
|
|
1032
|
+
* console.log(`Current: ${antennaInfo.currentAntenna}, TX: ${antennaInfo.txAntenna}, RX: ${antennaInfo.rxAntenna}`);
|
|
1033
|
+
*/
|
|
1034
|
+
async getAntenna(vfo) {
|
|
1035
|
+
if (vfo) {
|
|
1036
|
+
return this._nativeInstance.getAntenna(vfo);
|
|
1037
|
+
} else {
|
|
1038
|
+
return this._nativeInstance.getAntenna();
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// Power Conversion Functions
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* Convert power level to milliwatts
|
|
1046
|
+
* @param {number} power - Power level (0.0-1.0)
|
|
1047
|
+
* @param {number} frequency - Frequency in Hz
|
|
1048
|
+
* @param {string} mode - Radio mode ('USB', 'LSB', 'FM', etc.)
|
|
1049
|
+
* @returns {Promise<number>} Power in milliwatts
|
|
1050
|
+
* @example
|
|
1051
|
+
* const milliwatts = await rig.power2mW(0.5, 14205000, 'USB');
|
|
1052
|
+
* console.log(`50% power = ${milliwatts} mW`);
|
|
1053
|
+
*/
|
|
1054
|
+
async power2mW(power, frequency, mode) {
|
|
1055
|
+
return this._nativeInstance.power2mW(power, frequency, mode);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Convert milliwatts to power level
|
|
1060
|
+
* @param {number} milliwatts - Power in milliwatts
|
|
1061
|
+
* @param {number} frequency - Frequency in Hz
|
|
1062
|
+
* @param {string} mode - Radio mode ('USB', 'LSB', 'FM', etc.)
|
|
1063
|
+
* @returns {Promise<number>} Power level (0.0-1.0)
|
|
1064
|
+
* @example
|
|
1065
|
+
* const powerLevel = await rig.mW2power(5000, 14205000, 'USB');
|
|
1066
|
+
* console.log(`5000 mW = ${(powerLevel * 100).toFixed(1)}% power`);
|
|
1067
|
+
*/
|
|
1068
|
+
async mW2power(milliwatts, frequency, mode) {
|
|
1069
|
+
return this._nativeInstance.mW2power(milliwatts, frequency, mode);
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
// Reset Function
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* Reset radio to default state
|
|
1076
|
+
* @param {string} [resetType='SOFT'] - Reset type ('NONE', 'SOFT', 'VFO', 'MCALL', 'MASTER')
|
|
1077
|
+
*/
|
|
1078
|
+
async reset(resetType = 'SOFT') {
|
|
1079
|
+
return this._nativeInstance.reset(resetType);
|
|
1080
|
+
}
|
|
576
1081
|
}
|
|
577
1082
|
|
|
578
1083
|
// Export for CommonJS
|