hamlib 0.1.26 → 0.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/src/hamlib.cpp CHANGED
@@ -1,25 +1,15 @@
1
1
  #include "hamlib.h"
2
- #include "hamlib_compat.h"
2
+ #include "shim/hamlib_shim.h"
3
3
  #include <string>
4
4
  #include <vector>
5
5
  #include <memory>
6
6
  #include <algorithm>
7
7
 
8
- // Cross-platform compatibility for hamlib token types
9
- // Linux versions use token_t, some others use hamlib_token_t
10
- #ifndef HAMLIB_TOKEN_T
11
- #ifdef __linux__
12
- #define HAMLIB_TOKEN_T token_t
13
- #else
14
- #define HAMLIB_TOKEN_T hamlib_token_t
15
- #endif
16
- #endif
17
-
18
8
  // 安全宏 - 检查RIG指针有效性,防止空指针解引用和已销毁对象访问
19
9
  #define CHECK_RIG_VALID() \
20
10
  do { \
21
11
  if (!hamlib_instance_ || !hamlib_instance_->my_rig) { \
22
- result_code_ = -RIG_EINVAL; \
12
+ result_code_ = SHIM_RIG_EINVAL; \
23
13
  error_message_ = "RIG is not initialized or has been destroyed"; \
24
14
  return; \
25
15
  } \
@@ -49,24 +39,24 @@ public:
49
39
  void Execute() override {
50
40
  CHECK_RIG_VALID();
51
41
 
52
- result_code_ = rig_open(hamlib_instance_->my_rig);
53
- if (result_code_ != RIG_OK) {
54
- error_message_ = rigerror(result_code_);
42
+ result_code_ = shim_rig_open(hamlib_instance_->my_rig);
43
+ if (result_code_ != SHIM_RIG_OK) {
44
+ error_message_ = shim_rigerror(result_code_);
55
45
  } else {
56
- rig_set_freq_callback(hamlib_instance_->my_rig, NodeHamLib::freq_change_cb, hamlib_instance_);
57
- auto ppt_cb = +[](RIG *rig, vfo_t vfo, ptt_t ptt, rig_ptr_t arg) {
46
+ shim_rig_set_freq_callback(hamlib_instance_->my_rig, NodeHamLib::freq_change_cb, hamlib_instance_);
47
+ auto ppt_cb = +[](void* handle, int vfo, int ptt, void* arg) -> int {
58
48
  printf("PPT pushed!");
59
49
  return 0;
60
50
  };
61
- int cb_result = rig_set_ptt_callback(hamlib_instance_->my_rig, ppt_cb, NULL);
62
- rig_set_trn(hamlib_instance_->my_rig, RIG_TRN_POLL);
51
+ int cb_result = shim_rig_set_ptt_callback(hamlib_instance_->my_rig, ppt_cb, NULL);
52
+ shim_rig_set_trn(hamlib_instance_->my_rig, SHIM_RIG_TRN_POLL);
63
53
  hamlib_instance_->rig_is_open = true;
64
54
  }
65
55
  }
66
-
56
+
67
57
  void OnOK() override {
68
58
  Napi::Env env = Env();
69
- if (result_code_ != RIG_OK && !error_message_.empty()) {
59
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
70
60
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
71
61
  } else {
72
62
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -81,21 +71,21 @@ public:
81
71
 
82
72
  class SetFrequencyAsyncWorker : public HamLibAsyncWorker {
83
73
  public:
84
- SetFrequencyAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, freq_t freq, vfo_t vfo)
74
+ SetFrequencyAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, double freq, int vfo)
85
75
  : HamLibAsyncWorker(env, hamlib_instance), freq_(freq), vfo_(vfo) {}
86
76
 
87
77
  void Execute() override {
88
78
  CHECK_RIG_VALID();
89
79
 
90
- result_code_ = rig_set_freq(hamlib_instance_->my_rig, vfo_, freq_);
91
- if (result_code_ != RIG_OK) {
92
- error_message_ = rigerror(result_code_);
80
+ result_code_ = shim_rig_set_freq(hamlib_instance_->my_rig, vfo_, freq_);
81
+ if (result_code_ != SHIM_RIG_OK) {
82
+ error_message_ = shim_rigerror(result_code_);
93
83
  }
94
84
  }
95
85
 
96
86
  void OnOK() override {
97
87
  Napi::Env env = Env();
98
- if (result_code_ != RIG_OK && !error_message_.empty()) {
88
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
99
89
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
100
90
  } else {
101
91
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -108,27 +98,27 @@ public:
108
98
  }
109
99
 
110
100
  private:
111
- freq_t freq_;
112
- vfo_t vfo_;
101
+ double freq_;
102
+ int vfo_;
113
103
  };
114
104
 
115
105
  class GetFrequencyAsyncWorker : public HamLibAsyncWorker {
116
106
  public:
117
- GetFrequencyAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
107
+ GetFrequencyAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
118
108
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), freq_(0) {}
119
109
 
120
110
  void Execute() override {
121
111
  CHECK_RIG_VALID();
122
112
 
123
- result_code_ = rig_get_freq(hamlib_instance_->my_rig, vfo_, &freq_);
124
- if (result_code_ != RIG_OK) {
125
- error_message_ = rigerror(result_code_);
113
+ result_code_ = shim_rig_get_freq(hamlib_instance_->my_rig, vfo_, &freq_);
114
+ if (result_code_ != SHIM_RIG_OK) {
115
+ error_message_ = shim_rigerror(result_code_);
126
116
  }
127
117
  }
128
118
 
129
119
  void OnOK() override {
130
120
  Napi::Env env = Env();
131
- if (result_code_ != RIG_OK && !error_message_.empty()) {
121
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
132
122
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
133
123
  } else {
134
124
  deferred_.Resolve(Napi::Number::New(env, freq_));
@@ -141,27 +131,27 @@ public:
141
131
  }
142
132
 
143
133
  private:
144
- vfo_t vfo_;
145
- freq_t freq_;
134
+ int vfo_;
135
+ double freq_;
146
136
  };
147
137
 
148
138
  class SetModeAsyncWorker : public HamLibAsyncWorker {
149
139
  public:
150
- SetModeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, rmode_t mode, pbwidth_t width, vfo_t vfo = RIG_VFO_CURR)
140
+ SetModeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int mode, int width, int vfo = SHIM_RIG_VFO_CURR)
151
141
  : HamLibAsyncWorker(env, hamlib_instance), mode_(mode), width_(width), vfo_(vfo) {}
152
142
 
153
143
  void Execute() override {
154
144
  CHECK_RIG_VALID();
155
145
 
156
- result_code_ = rig_set_mode(hamlib_instance_->my_rig, vfo_, mode_, width_);
157
- if (result_code_ != RIG_OK) {
158
- error_message_ = rigerror(result_code_);
146
+ result_code_ = shim_rig_set_mode(hamlib_instance_->my_rig, vfo_, mode_, width_);
147
+ if (result_code_ != SHIM_RIG_OK) {
148
+ error_message_ = shim_rigerror(result_code_);
159
149
  }
160
150
  }
161
151
 
162
152
  void OnOK() override {
163
153
  Napi::Env env = Env();
164
- if (result_code_ != RIG_OK && !error_message_.empty()) {
154
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
165
155
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
166
156
  } else {
167
157
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -174,9 +164,9 @@ public:
174
164
  }
175
165
 
176
166
  private:
177
- rmode_t mode_;
178
- pbwidth_t width_;
179
- vfo_t vfo_;
167
+ int mode_;
168
+ int width_;
169
+ int vfo_;
180
170
  };
181
171
 
182
172
  class GetModeAsyncWorker : public HamLibAsyncWorker {
@@ -187,20 +177,20 @@ public:
187
177
  void Execute() override {
188
178
  CHECK_RIG_VALID();
189
179
 
190
- result_code_ = rig_get_mode(hamlib_instance_->my_rig, RIG_VFO_CURR, &mode_, &width_);
191
- if (result_code_ != RIG_OK) {
192
- error_message_ = rigerror(result_code_);
180
+ result_code_ = shim_rig_get_mode(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, &mode_, &width_);
181
+ if (result_code_ != SHIM_RIG_OK) {
182
+ error_message_ = shim_rigerror(result_code_);
193
183
  }
194
184
  }
195
185
 
196
186
  void OnOK() override {
197
187
  Napi::Env env = Env();
198
- if (result_code_ != RIG_OK && !error_message_.empty()) {
188
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
199
189
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
200
190
  } else {
201
191
  Napi::Object obj = Napi::Object::New(env);
202
192
  // Convert mode to string using rig_strrmode
203
- const char* mode_str = rig_strrmode(mode_);
193
+ const char* mode_str = shim_rig_strrmode(mode_);
204
194
  obj.Set(Napi::String::New(env, "mode"), Napi::String::New(env, mode_str));
205
195
  obj.Set(Napi::String::New(env, "bandwidth"), width_);
206
196
  deferred_.Resolve(obj);
@@ -213,27 +203,27 @@ public:
213
203
  }
214
204
 
215
205
  private:
216
- rmode_t mode_;
217
- pbwidth_t width_;
206
+ int mode_;
207
+ int width_;
218
208
  };
219
209
 
220
210
  class SetPttAsyncWorker : public HamLibAsyncWorker {
221
211
  public:
222
- SetPttAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, ptt_t ptt)
212
+ SetPttAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int ptt)
223
213
  : HamLibAsyncWorker(env, hamlib_instance), ptt_(ptt) {}
224
214
 
225
215
  void Execute() override {
226
216
  CHECK_RIG_VALID();
227
217
 
228
- result_code_ = rig_set_ptt(hamlib_instance_->my_rig, RIG_VFO_CURR, ptt_);
229
- if (result_code_ != RIG_OK) {
230
- error_message_ = rigerror(result_code_);
218
+ result_code_ = shim_rig_set_ptt(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, ptt_);
219
+ if (result_code_ != SHIM_RIG_OK) {
220
+ error_message_ = shim_rigerror(result_code_);
231
221
  }
232
222
  }
233
223
 
234
224
  void OnOK() override {
235
225
  Napi::Env env = Env();
236
- if (result_code_ != RIG_OK && !error_message_.empty()) {
226
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
237
227
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
238
228
  } else {
239
229
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -246,26 +236,26 @@ public:
246
236
  }
247
237
 
248
238
  private:
249
- ptt_t ptt_;
239
+ int ptt_;
250
240
  };
251
241
 
252
242
  class GetStrengthAsyncWorker : public HamLibAsyncWorker {
253
243
  public:
254
- GetStrengthAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
244
+ GetStrengthAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
255
245
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), strength_(0) {}
256
246
 
257
247
  void Execute() override {
258
248
  CHECK_RIG_VALID();
259
249
 
260
- result_code_ = rig_get_strength(hamlib_instance_->my_rig, vfo_, &strength_);
261
- if (result_code_ != RIG_OK) {
262
- error_message_ = rigerror(result_code_);
250
+ result_code_ = shim_rig_get_strength(hamlib_instance_->my_rig, vfo_, &strength_);
251
+ if (result_code_ != SHIM_RIG_OK) {
252
+ error_message_ = shim_rigerror(result_code_);
263
253
  }
264
254
  }
265
255
 
266
256
  void OnOK() override {
267
257
  Napi::Env env = Env();
268
- if (result_code_ != RIG_OK && !error_message_.empty()) {
258
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
269
259
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
270
260
  } else {
271
261
  deferred_.Resolve(Napi::Number::New(env, strength_));
@@ -278,95 +268,93 @@ public:
278
268
  }
279
269
 
280
270
  private:
281
- vfo_t vfo_;
271
+ int vfo_;
282
272
  int strength_;
283
273
  };
284
274
 
285
275
  class SetLevelAsyncWorker : public HamLibAsyncWorker {
286
276
  public:
287
- SetLevelAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, setting_t level_type, value_t value)
277
+ SetLevelAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, uint64_t level_type, float value)
288
278
  : HamLibAsyncWorker(env, hamlib_instance), level_type_(level_type), value_(value) {}
289
-
279
+
290
280
  void Execute() override {
291
281
  CHECK_RIG_VALID();
292
-
293
- result_code_ = rig_set_level(hamlib_instance_->my_rig, RIG_VFO_CURR, level_type_, value_);
294
- if (result_code_ != RIG_OK) {
295
- error_message_ = rigerror(result_code_);
282
+
283
+ result_code_ = shim_rig_set_level_f(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, level_type_, value_);
284
+ if (result_code_ != SHIM_RIG_OK) {
285
+ error_message_ = shim_rigerror(result_code_);
296
286
  }
297
287
  }
298
-
288
+
299
289
  void OnOK() override {
300
290
  Napi::Env env = Env();
301
- if (result_code_ != RIG_OK && !error_message_.empty()) {
291
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
302
292
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
303
293
  } else {
304
294
  deferred_.Resolve(Napi::Number::New(env, result_code_));
305
295
  }
306
296
  }
307
-
297
+
308
298
  void OnError(const Napi::Error& e) override {
309
299
  Napi::Env env = Env();
310
300
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
311
301
  }
312
-
302
+
313
303
  private:
314
- setting_t level_type_;
315
- value_t value_;
304
+ uint64_t level_type_;
305
+ float value_;
316
306
  };
317
307
 
318
308
  class GetLevelAsyncWorker : public HamLibAsyncWorker {
319
309
  public:
320
- GetLevelAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, setting_t level_type)
321
- : HamLibAsyncWorker(env, hamlib_instance), level_type_(level_type) {
322
- value_.f = 0.0;
323
- }
324
-
310
+ GetLevelAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, uint64_t level_type)
311
+ : HamLibAsyncWorker(env, hamlib_instance), level_type_(level_type), value_(0.0f) {}
312
+
325
313
  void Execute() override {
326
314
  CHECK_RIG_VALID();
327
-
328
- result_code_ = rig_get_level(hamlib_instance_->my_rig, RIG_VFO_CURR, level_type_, &value_);
329
- if (result_code_ != RIG_OK) {
330
- error_message_ = rigerror(result_code_);
315
+
316
+ result_code_ = shim_rig_get_level_f(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, level_type_, &value_);
317
+ if (result_code_ != SHIM_RIG_OK) {
318
+ error_message_ = shim_rigerror(result_code_);
331
319
  }
332
320
  }
333
-
321
+
334
322
  void OnOK() override {
335
323
  Napi::Env env = Env();
336
- if (result_code_ != RIG_OK && !error_message_.empty()) {
324
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
337
325
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
338
326
  } else {
339
- deferred_.Resolve(Napi::Number::New(env, value_.f));
327
+ deferred_.Resolve(Napi::Number::New(env, value_));
340
328
  }
341
329
  }
342
-
330
+
343
331
  void OnError(const Napi::Error& e) override {
344
332
  Napi::Env env = Env();
345
333
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
346
334
  }
347
-
335
+
348
336
  private:
349
- setting_t level_type_;
350
- value_t value_;
337
+ uint64_t level_type_;
338
+ float value_;
351
339
  };
352
340
 
353
341
  class SetFunctionAsyncWorker : public HamLibAsyncWorker {
354
342
  public:
355
- SetFunctionAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, setting_t func_type, int enable)
343
+ SetFunctionAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, uint64_t func_type, int enable)
356
344
  : HamLibAsyncWorker(env, hamlib_instance), func_type_(func_type), enable_(enable) {}
357
345
 
358
346
  void Execute() override {
359
347
  CHECK_RIG_VALID();
360
348
 
361
- result_code_ = rig_set_func(hamlib_instance_->my_rig, RIG_VFO_CURR, func_type_, enable_);
362
- if (result_code_ != RIG_OK) {
363
- error_message_ = rigerror(result_code_);
349
+ result_code_ = shim_rig_set_func(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, func_type_, enable_);
350
+ if (result_code_ != SHIM_RIG_OK) {
351
+ error_message_ = shim_rigerror(result_code_);
364
352
  }
365
353
  }
366
354
 
367
355
  void OnOK() override {
368
356
  Napi::Env env = Env();
369
- if (result_code_ != RIG_OK && !error_message_.empty()) {
357
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
370
358
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
371
359
  } else {
372
360
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -379,27 +367,27 @@ public:
379
367
  }
380
368
 
381
369
  private:
382
- setting_t func_type_;
370
+ uint64_t func_type_;
383
371
  int enable_;
384
372
  };
385
373
 
386
374
  class GetFunctionAsyncWorker : public HamLibAsyncWorker {
387
375
  public:
388
- GetFunctionAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, setting_t func_type)
376
+ GetFunctionAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, uint64_t func_type)
389
377
  : HamLibAsyncWorker(env, hamlib_instance), func_type_(func_type), state_(0) {}
390
378
 
391
379
  void Execute() override {
392
380
  CHECK_RIG_VALID();
393
381
 
394
- result_code_ = rig_get_func(hamlib_instance_->my_rig, RIG_VFO_CURR, func_type_, &state_);
395
- if (result_code_ != RIG_OK) {
396
- error_message_ = rigerror(result_code_);
382
+ result_code_ = shim_rig_get_func(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, func_type_, &state_);
383
+ if (result_code_ != SHIM_RIG_OK) {
384
+ error_message_ = shim_rigerror(result_code_);
397
385
  }
398
386
  }
399
387
 
400
388
  void OnOK() override {
401
389
  Napi::Env env = Env();
402
- if (result_code_ != RIG_OK && !error_message_.empty()) {
390
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
403
391
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
404
392
  } else {
405
393
  deferred_.Resolve(Napi::Boolean::New(env, state_ != 0));
@@ -412,27 +400,27 @@ public:
412
400
  }
413
401
 
414
402
  private:
415
- setting_t func_type_;
403
+ uint64_t func_type_;
416
404
  int state_;
417
405
  };
418
406
 
419
407
  class SetMemoryChannelAsyncWorker : public HamLibAsyncWorker {
420
408
  public:
421
- SetMemoryChannelAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, const channel_t& chan)
409
+ SetMemoryChannelAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, const shim_channel_t& chan)
422
410
  : HamLibAsyncWorker(env, hamlib_instance), chan_(chan) {}
423
411
 
424
412
  void Execute() override {
425
413
  CHECK_RIG_VALID();
426
414
 
427
- result_code_ = rig_set_channel(hamlib_instance_->my_rig, RIG_VFO_MEM, &chan_);
428
- if (result_code_ != RIG_OK) {
429
- error_message_ = rigerror(result_code_);
415
+ result_code_ = shim_rig_set_channel(hamlib_instance_->my_rig, SHIM_RIG_VFO_MEM, &chan_);
416
+ if (result_code_ != SHIM_RIG_OK) {
417
+ error_message_ = shim_rigerror(result_code_);
430
418
  }
431
419
  }
432
420
 
433
421
  void OnOK() override {
434
422
  Napi::Env env = Env();
435
- if (result_code_ != RIG_OK && !error_message_.empty()) {
423
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
436
424
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
437
425
  } else {
438
426
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -445,7 +433,7 @@ public:
445
433
  }
446
434
 
447
435
  private:
448
- channel_t chan_;
436
+ shim_channel_t chan_;
449
437
  };
450
438
 
451
439
  class GetMemoryChannelAsyncWorker : public HamLibAsyncWorker {
@@ -459,10 +447,10 @@ public:
459
447
  CHECK_RIG_VALID();
460
448
 
461
449
  chan_.channel_num = channel_num_;
462
- chan_.vfo = RIG_VFO_MEM;
463
- result_code_ = rig_get_channel(hamlib_instance_->my_rig, RIG_VFO_MEM, &chan_, read_only_);
464
- if (result_code_ != RIG_OK) {
465
- error_message_ = rigerror(result_code_);
450
+ chan_.vfo = SHIM_RIG_VFO_MEM;
451
+ result_code_ = shim_rig_get_channel(hamlib_instance_->my_rig, SHIM_RIG_VFO_MEM, &chan_, read_only_);
452
+ if (result_code_ != SHIM_RIG_OK) {
453
+ error_message_ = shim_rigerror(result_code_);
466
454
  }
467
455
  }
468
456
 
@@ -473,8 +461,8 @@ public:
473
461
  obj.Set(Napi::String::New(env, "channelNumber"), chan_.channel_num);
474
462
  obj.Set(Napi::String::New(env, "frequency"), chan_.freq);
475
463
 
476
- if (chan_.mode != RIG_MODE_NONE) {
477
- const char* mode_str = rig_strrmode(chan_.mode);
464
+ if (chan_.mode != SHIM_RIG_MODE_NONE) {
465
+ const char* mode_str = shim_rig_strrmode(chan_.mode);
478
466
  obj.Set(Napi::String::New(env, "mode"), Napi::String::New(env, mode_str));
479
467
  }
480
468
 
@@ -484,7 +472,7 @@ public:
484
472
  obj.Set(Napi::String::New(env, "description"), Napi::String::New(env, chan_.channel_desc));
485
473
  }
486
474
 
487
- if (chan_.split == RIG_SPLIT_ON) {
475
+ if (chan_.split == SHIM_RIG_SPLIT_ON) {
488
476
  obj.Set(Napi::String::New(env, "txFrequency"), chan_.tx_freq);
489
477
  }
490
478
 
@@ -503,7 +491,7 @@ public:
503
491
  private:
504
492
  int channel_num_;
505
493
  bool read_only_;
506
- channel_t chan_;
494
+ shim_channel_t chan_;
507
495
  };
508
496
 
509
497
  class SelectMemoryChannelAsyncWorker : public HamLibAsyncWorker {
@@ -514,15 +502,15 @@ public:
514
502
  void Execute() override {
515
503
  CHECK_RIG_VALID();
516
504
 
517
- result_code_ = rig_set_mem(hamlib_instance_->my_rig, RIG_VFO_CURR, channel_num_);
518
- if (result_code_ != RIG_OK) {
519
- error_message_ = rigerror(result_code_);
505
+ result_code_ = shim_rig_set_mem(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, channel_num_);
506
+ if (result_code_ != SHIM_RIG_OK) {
507
+ error_message_ = shim_rigerror(result_code_);
520
508
  }
521
509
  }
522
510
 
523
511
  void OnOK() override {
524
512
  Napi::Env env = Env();
525
- if (result_code_ != RIG_OK && !error_message_.empty()) {
513
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
526
514
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
527
515
  } else {
528
516
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -540,21 +528,21 @@ private:
540
528
 
541
529
  class SetRitAsyncWorker : public HamLibAsyncWorker {
542
530
  public:
543
- SetRitAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, shortfreq_t rit_offset)
531
+ SetRitAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int rit_offset)
544
532
  : HamLibAsyncWorker(env, hamlib_instance), rit_offset_(rit_offset) {}
545
533
 
546
534
  void Execute() override {
547
535
  CHECK_RIG_VALID();
548
536
 
549
- result_code_ = rig_set_rit(hamlib_instance_->my_rig, RIG_VFO_CURR, rit_offset_);
550
- if (result_code_ != RIG_OK) {
551
- error_message_ = rigerror(result_code_);
537
+ result_code_ = shim_rig_set_rit(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, rit_offset_);
538
+ if (result_code_ != SHIM_RIG_OK) {
539
+ error_message_ = shim_rigerror(result_code_);
552
540
  }
553
541
  }
554
542
 
555
543
  void OnOK() override {
556
544
  Napi::Env env = Env();
557
- if (result_code_ != RIG_OK && !error_message_.empty()) {
545
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
558
546
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
559
547
  } else {
560
548
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -567,7 +555,7 @@ public:
567
555
  }
568
556
 
569
557
  private:
570
- shortfreq_t rit_offset_;
558
+ int rit_offset_;
571
559
  };
572
560
 
573
561
  class GetRitAsyncWorker : public HamLibAsyncWorker {
@@ -578,15 +566,15 @@ public:
578
566
  void Execute() override {
579
567
  CHECK_RIG_VALID();
580
568
 
581
- result_code_ = rig_get_rit(hamlib_instance_->my_rig, RIG_VFO_CURR, &rit_offset_);
582
- if (result_code_ != RIG_OK) {
583
- error_message_ = rigerror(result_code_);
569
+ result_code_ = shim_rig_get_rit(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, &rit_offset_);
570
+ if (result_code_ != SHIM_RIG_OK) {
571
+ error_message_ = shim_rigerror(result_code_);
584
572
  }
585
573
  }
586
574
 
587
575
  void OnOK() override {
588
576
  Napi::Env env = Env();
589
- if (result_code_ != RIG_OK && !error_message_.empty()) {
577
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
590
578
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
591
579
  } else {
592
580
  deferred_.Resolve(Napi::Number::New(env, rit_offset_));
@@ -599,26 +587,26 @@ public:
599
587
  }
600
588
 
601
589
  private:
602
- shortfreq_t rit_offset_;
590
+ int rit_offset_;
603
591
  };
604
592
 
605
593
  class SetXitAsyncWorker : public HamLibAsyncWorker {
606
594
  public:
607
- SetXitAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, shortfreq_t xit_offset)
595
+ SetXitAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int xit_offset)
608
596
  : HamLibAsyncWorker(env, hamlib_instance), xit_offset_(xit_offset) {}
609
597
 
610
598
  void Execute() override {
611
599
  CHECK_RIG_VALID();
612
600
 
613
- result_code_ = rig_set_xit(hamlib_instance_->my_rig, RIG_VFO_CURR, xit_offset_);
614
- if (result_code_ != RIG_OK) {
615
- error_message_ = rigerror(result_code_);
601
+ result_code_ = shim_rig_set_xit(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, xit_offset_);
602
+ if (result_code_ != SHIM_RIG_OK) {
603
+ error_message_ = shim_rigerror(result_code_);
616
604
  }
617
605
  }
618
606
 
619
607
  void OnOK() override {
620
608
  Napi::Env env = Env();
621
- if (result_code_ != RIG_OK && !error_message_.empty()) {
609
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
622
610
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
623
611
  } else {
624
612
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -631,7 +619,7 @@ public:
631
619
  }
632
620
 
633
621
  private:
634
- shortfreq_t xit_offset_;
622
+ int xit_offset_;
635
623
  };
636
624
 
637
625
  class GetXitAsyncWorker : public HamLibAsyncWorker {
@@ -642,15 +630,15 @@ public:
642
630
  void Execute() override {
643
631
  CHECK_RIG_VALID();
644
632
 
645
- result_code_ = rig_get_xit(hamlib_instance_->my_rig, RIG_VFO_CURR, &xit_offset_);
646
- if (result_code_ != RIG_OK) {
647
- error_message_ = rigerror(result_code_);
633
+ result_code_ = shim_rig_get_xit(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, &xit_offset_);
634
+ if (result_code_ != SHIM_RIG_OK) {
635
+ error_message_ = shim_rigerror(result_code_);
648
636
  }
649
637
  }
650
638
 
651
639
  void OnOK() override {
652
640
  Napi::Env env = Env();
653
- if (result_code_ != RIG_OK && !error_message_.empty()) {
641
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
654
642
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
655
643
  } else {
656
644
  deferred_.Resolve(Napi::Number::New(env, xit_offset_));
@@ -663,7 +651,7 @@ public:
663
651
  }
664
652
 
665
653
  private:
666
- shortfreq_t xit_offset_;
654
+ int xit_offset_;
667
655
  };
668
656
 
669
657
  class ClearRitXitAsyncWorker : public HamLibAsyncWorker {
@@ -674,23 +662,23 @@ public:
674
662
  void Execute() override {
675
663
  CHECK_RIG_VALID();
676
664
 
677
- int ritCode = rig_set_rit(hamlib_instance_->my_rig, RIG_VFO_CURR, 0);
678
- int xitCode = rig_set_xit(hamlib_instance_->my_rig, RIG_VFO_CURR, 0);
665
+ int ritCode = shim_rig_set_rit(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, 0);
666
+ int xitCode = shim_rig_set_xit(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, 0);
679
667
 
680
- if (ritCode != RIG_OK) {
668
+ if (ritCode != SHIM_RIG_OK) {
681
669
  result_code_ = ritCode;
682
- error_message_ = rigerror(ritCode);
683
- } else if (xitCode != RIG_OK) {
670
+ error_message_ = shim_rigerror(ritCode);
671
+ } else if (xitCode != SHIM_RIG_OK) {
684
672
  result_code_ = xitCode;
685
- error_message_ = rigerror(xitCode);
673
+ error_message_ = shim_rigerror(xitCode);
686
674
  } else {
687
- result_code_ = RIG_OK;
675
+ result_code_ = SHIM_RIG_OK;
688
676
  }
689
677
  }
690
678
 
691
679
  void OnOK() override {
692
680
  Napi::Env env = Env();
693
- if (result_code_ != RIG_OK && !error_message_.empty()) {
681
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
694
682
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
695
683
  } else {
696
684
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -705,21 +693,21 @@ public:
705
693
 
706
694
  class SetSplitFreqAsyncWorker : public HamLibAsyncWorker {
707
695
  public:
708
- SetSplitFreqAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, freq_t tx_freq, vfo_t vfo = RIG_VFO_CURR)
696
+ SetSplitFreqAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, double tx_freq, int vfo = SHIM_RIG_VFO_CURR)
709
697
  : HamLibAsyncWorker(env, hamlib_instance), tx_freq_(tx_freq), vfo_(vfo) {}
710
698
 
711
699
  void Execute() override {
712
700
  CHECK_RIG_VALID();
713
701
 
714
- result_code_ = rig_set_split_freq(hamlib_instance_->my_rig, vfo_, tx_freq_);
715
- if (result_code_ != RIG_OK) {
716
- error_message_ = rigerror(result_code_);
702
+ result_code_ = shim_rig_set_split_freq(hamlib_instance_->my_rig, vfo_, tx_freq_);
703
+ if (result_code_ != SHIM_RIG_OK) {
704
+ error_message_ = shim_rigerror(result_code_);
717
705
  }
718
706
  }
719
707
 
720
708
  void OnOK() override {
721
709
  Napi::Env env = Env();
722
- if (result_code_ != RIG_OK && !error_message_.empty()) {
710
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
723
711
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
724
712
  } else {
725
713
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -732,27 +720,27 @@ public:
732
720
  }
733
721
 
734
722
  private:
735
- freq_t tx_freq_;
736
- vfo_t vfo_;
723
+ double tx_freq_;
724
+ int vfo_;
737
725
  };
738
726
 
739
727
  class GetSplitFreqAsyncWorker : public HamLibAsyncWorker {
740
728
  public:
741
- GetSplitFreqAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo = RIG_VFO_CURR)
729
+ GetSplitFreqAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo = SHIM_RIG_VFO_CURR)
742
730
  : HamLibAsyncWorker(env, hamlib_instance), tx_freq_(0), vfo_(vfo) {}
743
731
 
744
732
  void Execute() override {
745
733
  CHECK_RIG_VALID();
746
734
 
747
- result_code_ = rig_get_split_freq(hamlib_instance_->my_rig, vfo_, &tx_freq_);
748
- if (result_code_ != RIG_OK) {
749
- error_message_ = rigerror(result_code_);
735
+ result_code_ = shim_rig_get_split_freq(hamlib_instance_->my_rig, vfo_, &tx_freq_);
736
+ if (result_code_ != SHIM_RIG_OK) {
737
+ error_message_ = shim_rigerror(result_code_);
750
738
  }
751
739
  }
752
740
 
753
741
  void OnOK() override {
754
742
  Napi::Env env = Env();
755
- if (result_code_ != RIG_OK && !error_message_.empty()) {
743
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
756
744
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
757
745
  } else {
758
746
  deferred_.Resolve(Napi::Number::New(env, tx_freq_));
@@ -765,27 +753,27 @@ public:
765
753
  }
766
754
 
767
755
  private:
768
- freq_t tx_freq_;
769
- vfo_t vfo_;
756
+ double tx_freq_;
757
+ int vfo_;
770
758
  };
771
759
 
772
760
  class SetSplitAsyncWorker : public HamLibAsyncWorker {
773
761
  public:
774
- SetSplitAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t rx_vfo, split_t split, vfo_t tx_vfo)
762
+ SetSplitAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int rx_vfo, int split, int tx_vfo)
775
763
  : HamLibAsyncWorker(env, hamlib_instance), rx_vfo_(rx_vfo), split_(split), tx_vfo_(tx_vfo) {}
776
764
 
777
765
  void Execute() override {
778
766
  CHECK_RIG_VALID();
779
767
 
780
- result_code_ = rig_set_split_vfo(hamlib_instance_->my_rig, rx_vfo_, split_, tx_vfo_);
781
- if (result_code_ != RIG_OK) {
782
- error_message_ = rigerror(result_code_);
768
+ result_code_ = shim_rig_set_split_vfo(hamlib_instance_->my_rig, rx_vfo_, split_, tx_vfo_);
769
+ if (result_code_ != SHIM_RIG_OK) {
770
+ error_message_ = shim_rigerror(result_code_);
783
771
  }
784
772
  }
785
773
 
786
774
  void OnOK() override {
787
775
  Napi::Env env = Env();
788
- if (result_code_ != RIG_OK && !error_message_.empty()) {
776
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
789
777
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
790
778
  } else {
791
779
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -798,35 +786,35 @@ public:
798
786
  }
799
787
 
800
788
  private:
801
- vfo_t rx_vfo_;
802
- split_t split_;
803
- vfo_t tx_vfo_;
789
+ int rx_vfo_;
790
+ int split_;
791
+ int tx_vfo_;
804
792
  };
805
793
 
806
794
  class GetSplitAsyncWorker : public HamLibAsyncWorker {
807
795
  public:
808
- GetSplitAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo = RIG_VFO_CURR)
809
- : HamLibAsyncWorker(env, hamlib_instance), split_(RIG_SPLIT_OFF), tx_vfo_(RIG_VFO_B), vfo_(vfo) {}
796
+ GetSplitAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo = SHIM_RIG_VFO_CURR)
797
+ : HamLibAsyncWorker(env, hamlib_instance), split_(SHIM_RIG_SPLIT_OFF), tx_vfo_(SHIM_RIG_VFO_B), vfo_(vfo) {}
810
798
 
811
799
  void Execute() override {
812
800
  CHECK_RIG_VALID();
813
801
 
814
- result_code_ = rig_get_split_vfo(hamlib_instance_->my_rig, vfo_, &split_, &tx_vfo_);
815
- if (result_code_ != RIG_OK) {
816
- error_message_ = rigerror(result_code_);
802
+ result_code_ = shim_rig_get_split_vfo(hamlib_instance_->my_rig, vfo_, &split_, &tx_vfo_);
803
+ if (result_code_ != SHIM_RIG_OK) {
804
+ error_message_ = shim_rigerror(result_code_);
817
805
  }
818
806
  }
819
807
 
820
808
  void OnOK() override {
821
809
  Napi::Env env = Env();
822
- if (result_code_ != RIG_OK && !error_message_.empty()) {
810
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
823
811
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
824
812
  } else {
825
813
  Napi::Object obj = Napi::Object::New(env);
826
- obj.Set(Napi::String::New(env, "enabled"), Napi::Boolean::New(env, split_ == RIG_SPLIT_ON));
814
+ obj.Set(Napi::String::New(env, "enabled"), Napi::Boolean::New(env, split_ == SHIM_RIG_SPLIT_ON));
827
815
 
828
816
  const char* vfo_str = "VFO-B";
829
- if (tx_vfo_ == RIG_VFO_A) {
817
+ if (tx_vfo_ == SHIM_RIG_VFO_A) {
830
818
  vfo_str = "VFO-A";
831
819
  }
832
820
  obj.Set(Napi::String::New(env, "txVfo"), Napi::String::New(env, vfo_str));
@@ -841,28 +829,28 @@ public:
841
829
  }
842
830
 
843
831
  private:
844
- split_t split_;
845
- vfo_t tx_vfo_;
846
- vfo_t vfo_;
832
+ int split_;
833
+ int tx_vfo_;
834
+ int vfo_;
847
835
  };
848
836
 
849
837
  class SetVfoAsyncWorker : public HamLibAsyncWorker {
850
838
  public:
851
- SetVfoAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
839
+ SetVfoAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
852
840
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo) {}
853
841
 
854
842
  void Execute() override {
855
843
  CHECK_RIG_VALID();
856
844
 
857
- result_code_ = rig_set_vfo(hamlib_instance_->my_rig, vfo_);
858
- if (result_code_ != RIG_OK) {
859
- error_message_ = rigerror(result_code_);
845
+ result_code_ = shim_rig_set_vfo(hamlib_instance_->my_rig, vfo_);
846
+ if (result_code_ != SHIM_RIG_OK) {
847
+ error_message_ = shim_rigerror(result_code_);
860
848
  }
861
849
  }
862
850
 
863
851
  void OnOK() override {
864
852
  Napi::Env env = Env();
865
- if (result_code_ != RIG_OK && !error_message_.empty()) {
853
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
866
854
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
867
855
  } else {
868
856
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -875,7 +863,7 @@ public:
875
863
  }
876
864
 
877
865
  private:
878
- vfo_t vfo_;
866
+ int vfo_;
879
867
  };
880
868
 
881
869
  class GetVfoAsyncWorker : public HamLibAsyncWorker {
@@ -886,21 +874,20 @@ public:
886
874
  void Execute() override {
887
875
  CHECK_RIG_VALID();
888
876
 
889
- result_code_ = rig_get_vfo(hamlib_instance_->my_rig, &vfo_);
890
- if (result_code_ != RIG_OK) {
877
+ result_code_ = shim_rig_get_vfo(hamlib_instance_->my_rig, &vfo_);
878
+ if (result_code_ != SHIM_RIG_OK) {
891
879
  // 提供更清晰的错误信息
892
880
  switch (result_code_) {
893
- case RIG_ENAVAIL:
894
- case -11: // Feature not available
881
+ case SHIM_RIG_ENAVAIL:
895
882
  error_message_ = "VFO query not supported by this radio";
896
883
  break;
897
- case RIG_EIO:
884
+ case SHIM_RIG_EIO:
898
885
  error_message_ = "I/O error during VFO query";
899
886
  break;
900
- case RIG_ETIMEOUT:
887
+ case SHIM_RIG_ETIMEOUT:
901
888
  error_message_ = "Timeout during VFO query";
902
889
  break;
903
- case RIG_EPROTO:
890
+ case SHIM_RIG_EPROTO:
904
891
  error_message_ = "Protocol error during VFO query";
905
892
  break;
906
893
  default:
@@ -914,19 +901,19 @@ public:
914
901
  Napi::Env env = Env();
915
902
 
916
903
  // 如果API调用失败,reject Promise
917
- if (result_code_ != RIG_OK) {
904
+ if (result_code_ != SHIM_RIG_OK) {
918
905
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
919
906
  return;
920
907
  }
921
908
 
922
909
  const char* vfo_str = "VFO-CURR"; // 默认值
923
- if (vfo_ == RIG_VFO_A) {
910
+ if (vfo_ == SHIM_RIG_VFO_A) {
924
911
  vfo_str = "VFO-A";
925
- } else if (vfo_ == RIG_VFO_B) {
912
+ } else if (vfo_ == SHIM_RIG_VFO_B) {
926
913
  vfo_str = "VFO-B";
927
- } else if (vfo_ == RIG_VFO_CURR) {
914
+ } else if (vfo_ == SHIM_RIG_VFO_CURR) {
928
915
  vfo_str = "VFO-CURR";
929
- } else if (vfo_ == RIG_VFO_MEM) {
916
+ } else if (vfo_ == SHIM_RIG_VFO_MEM) {
930
917
  vfo_str = "VFO-MEM";
931
918
  }
932
919
  deferred_.Resolve(Napi::String::New(env, vfo_str));
@@ -938,7 +925,7 @@ public:
938
925
  }
939
926
 
940
927
  private:
941
- vfo_t vfo_;
928
+ int vfo_;
942
929
  };
943
930
 
944
931
  class CloseAsyncWorker : public HamLibAsyncWorker {
@@ -951,13 +938,13 @@ public:
951
938
 
952
939
  // 检查rig是否已经关闭
953
940
  if (!hamlib_instance_->rig_is_open) {
954
- result_code_ = RIG_OK; // 已经关闭,返回成功
941
+ result_code_ = SHIM_RIG_OK; // 已经关闭,返回成功
955
942
  return;
956
943
  }
957
944
 
958
- result_code_ = rig_close(hamlib_instance_->my_rig);
959
- if (result_code_ != RIG_OK) {
960
- error_message_ = rigerror(result_code_);
945
+ result_code_ = shim_rig_close(hamlib_instance_->my_rig);
946
+ if (result_code_ != SHIM_RIG_OK) {
947
+ error_message_ = shim_rigerror(result_code_);
961
948
  } else {
962
949
  hamlib_instance_->rig_is_open = false;
963
950
  }
@@ -965,7 +952,7 @@ public:
965
952
 
966
953
  void OnOK() override {
967
954
  Napi::Env env = Env();
968
- if (result_code_ != RIG_OK && !error_message_.empty()) {
955
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
969
956
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
970
957
  } else {
971
958
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -987,9 +974,9 @@ public:
987
974
  CHECK_RIG_VALID();
988
975
 
989
976
  // rig_cleanup会自动调用rig_close,所以我们不需要重复调用
990
- result_code_ = rig_cleanup(hamlib_instance_->my_rig);
991
- if (result_code_ != RIG_OK) {
992
- error_message_ = rigerror(result_code_);
977
+ result_code_ = shim_rig_cleanup(hamlib_instance_->my_rig);
978
+ if (result_code_ != SHIM_RIG_OK) {
979
+ error_message_ = shim_rigerror(result_code_);
993
980
  } else {
994
981
  hamlib_instance_->rig_is_open = false;
995
982
  hamlib_instance_->my_rig = nullptr; // 重要:清空指针防止重复释放
@@ -998,7 +985,7 @@ public:
998
985
 
999
986
  void OnOK() override {
1000
987
  Napi::Env env = Env();
1001
- if (result_code_ != RIG_OK && !error_message_.empty()) {
988
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1002
989
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1003
990
  } else {
1004
991
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -1014,21 +1001,21 @@ public:
1014
1001
  // Start Scan AsyncWorker
1015
1002
  class StartScanAsyncWorker : public HamLibAsyncWorker {
1016
1003
  public:
1017
- StartScanAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, scan_t scan_type, int channel)
1018
- : HamLibAsyncWorker(env, hamlib_instance), scan_type_(scan_type), channel_(channel) {}
1004
+ StartScanAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int intype, int channel)
1005
+ : HamLibAsyncWorker(env, hamlib_instance), intype_(intype), channel_(channel) {}
1019
1006
 
1020
1007
  void Execute() override {
1021
1008
  CHECK_RIG_VALID();
1022
1009
 
1023
- result_code_ = rig_scan(hamlib_instance_->my_rig, RIG_VFO_CURR, scan_type_, channel_);
1024
- if (result_code_ != RIG_OK) {
1025
- error_message_ = rigerror(result_code_);
1010
+ result_code_ = shim_rig_scan(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, intype_, channel_);
1011
+ if (result_code_ != SHIM_RIG_OK) {
1012
+ error_message_ = shim_rigerror(result_code_);
1026
1013
  }
1027
1014
  }
1028
1015
 
1029
1016
  void OnOK() override {
1030
1017
  Napi::Env env = Env();
1031
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1018
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1032
1019
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1033
1020
  } else {
1034
1021
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -1041,7 +1028,7 @@ public:
1041
1028
  }
1042
1029
 
1043
1030
  private:
1044
- scan_t scan_type_;
1031
+ int intype_;
1045
1032
  int channel_;
1046
1033
  };
1047
1034
 
@@ -1054,15 +1041,15 @@ public:
1054
1041
  void Execute() override {
1055
1042
  CHECK_RIG_VALID();
1056
1043
 
1057
- result_code_ = rig_scan(hamlib_instance_->my_rig, RIG_VFO_CURR, RIG_SCAN_STOP, 0);
1058
- if (result_code_ != RIG_OK) {
1059
- error_message_ = rigerror(result_code_);
1044
+ result_code_ = shim_rig_scan(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, SHIM_RIG_SCAN_STOP, 0);
1045
+ if (result_code_ != SHIM_RIG_OK) {
1046
+ error_message_ = shim_rigerror(result_code_);
1060
1047
  }
1061
1048
  }
1062
1049
 
1063
1050
  void OnOK() override {
1064
1051
  Napi::Env env = Env();
1065
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1052
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1066
1053
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1067
1054
  } else {
1068
1055
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -1078,21 +1065,21 @@ public:
1078
1065
  // VFO Operation AsyncWorker
1079
1066
  class VfoOperationAsyncWorker : public HamLibAsyncWorker {
1080
1067
  public:
1081
- VfoOperationAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_op_t vfo_op)
1068
+ VfoOperationAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo_op)
1082
1069
  : HamLibAsyncWorker(env, hamlib_instance), vfo_op_(vfo_op) {}
1083
1070
 
1084
1071
  void Execute() override {
1085
1072
  CHECK_RIG_VALID();
1086
1073
 
1087
- result_code_ = rig_vfo_op(hamlib_instance_->my_rig, RIG_VFO_CURR, vfo_op_);
1088
- if (result_code_ != RIG_OK) {
1089
- error_message_ = rigerror(result_code_);
1074
+ result_code_ = shim_rig_vfo_op(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, vfo_op_);
1075
+ if (result_code_ != SHIM_RIG_OK) {
1076
+ error_message_ = shim_rigerror(result_code_);
1090
1077
  }
1091
1078
  }
1092
1079
 
1093
1080
  void OnOK() override {
1094
1081
  Napi::Env env = Env();
1095
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1082
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1096
1083
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1097
1084
  } else {
1098
1085
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -1105,109 +1092,109 @@ public:
1105
1092
  }
1106
1093
 
1107
1094
  private:
1108
- vfo_op_t vfo_op_;
1095
+ int vfo_op_;
1109
1096
  };
1110
1097
 
1111
1098
  // Set Antenna AsyncWorker
1112
1099
  class SetAntennaAsyncWorker : public HamLibAsyncWorker {
1113
1100
  public:
1114
- SetAntennaAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, ant_t antenna, vfo_t vfo, value_t option)
1101
+ SetAntennaAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int antenna, int vfo, float option)
1115
1102
  : HamLibAsyncWorker(env, hamlib_instance), antenna_(antenna), vfo_(vfo), option_(option) {}
1116
-
1103
+
1117
1104
  void Execute() override {
1118
1105
  CHECK_RIG_VALID();
1119
-
1120
- result_code_ = rig_set_ant(hamlib_instance_->my_rig, vfo_, antenna_, option_);
1121
- if (result_code_ != RIG_OK) {
1122
- error_message_ = rigerror(result_code_);
1106
+
1107
+ result_code_ = shim_rig_set_ant(hamlib_instance_->my_rig, vfo_, antenna_, option_);
1108
+ if (result_code_ != SHIM_RIG_OK) {
1109
+ error_message_ = shim_rigerror(result_code_);
1123
1110
  }
1124
1111
  }
1125
-
1112
+
1126
1113
  void OnOK() override {
1127
1114
  Napi::Env env = Env();
1128
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1115
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1129
1116
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1130
1117
  } else {
1131
1118
  deferred_.Resolve(Napi::Number::New(env, result_code_));
1132
1119
  }
1133
1120
  }
1134
-
1121
+
1135
1122
  void OnError(const Napi::Error& e) override {
1136
1123
  Napi::Env env = Env();
1137
1124
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1138
1125
  }
1139
-
1126
+
1140
1127
  private:
1141
- ant_t antenna_;
1142
- vfo_t vfo_;
1143
- value_t option_;
1128
+ int antenna_;
1129
+ int vfo_;
1130
+ float option_;
1144
1131
  };
1145
1132
 
1146
1133
  // Get Antenna AsyncWorker
1147
1134
  class GetAntennaAsyncWorker : public HamLibAsyncWorker {
1148
1135
  public:
1149
- GetAntennaAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, ant_t antenna)
1136
+ GetAntennaAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, int antenna)
1150
1137
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), antenna_(antenna), antenna_curr_(0), antenna_tx_(0), antenna_rx_(0) {}
1151
1138
 
1152
1139
  void Execute() override {
1153
1140
  CHECK_RIG_VALID();
1154
1141
 
1155
- option_ = {0};
1156
-
1157
- result_code_ = rig_get_ant(hamlib_instance_->my_rig, vfo_, antenna_, &option_, &antenna_curr_, &antenna_tx_, &antenna_rx_);
1158
- if (result_code_ != RIG_OK) {
1159
- error_message_ = rigerror(result_code_);
1142
+ option_ = 0.0f;
1143
+
1144
+ result_code_ = shim_rig_get_ant(hamlib_instance_->my_rig, vfo_, antenna_, &option_, &antenna_curr_, &antenna_tx_, &antenna_rx_);
1145
+ if (result_code_ != SHIM_RIG_OK) {
1146
+ error_message_ = shim_rigerror(result_code_);
1160
1147
  }
1161
1148
  }
1162
-
1149
+
1163
1150
  void OnOK() override {
1164
1151
  Napi::Env env = Env();
1165
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1152
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1166
1153
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1167
1154
  } else {
1168
1155
  Napi::Object result = Napi::Object::New(env);
1169
-
1156
+
1170
1157
  result.Set("currentAntenna", Napi::Number::New(env, antenna_curr_));
1171
1158
  result.Set("txAntenna", Napi::Number::New(env, antenna_tx_));
1172
1159
  result.Set("rxAntenna", Napi::Number::New(env, antenna_rx_));
1173
- result.Set("option", Napi::Number::New(env, option_.f));
1174
-
1160
+ result.Set("option", Napi::Number::New(env, option_));
1161
+
1175
1162
  deferred_.Resolve(result);
1176
1163
  }
1177
1164
  }
1178
-
1165
+
1179
1166
  void OnError(const Napi::Error& e) override {
1180
1167
  Napi::Env env = Env();
1181
1168
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1182
1169
  }
1183
-
1170
+
1184
1171
  private:
1185
- vfo_t vfo_;
1186
- ant_t antenna_;
1187
- ant_t antenna_curr_;
1188
- ant_t antenna_tx_;
1189
- ant_t antenna_rx_;
1190
- value_t option_;
1172
+ int vfo_;
1173
+ int antenna_;
1174
+ int antenna_curr_;
1175
+ int antenna_tx_;
1176
+ int antenna_rx_;
1177
+ float option_;
1191
1178
  };
1192
1179
 
1193
1180
  // Power to mW Conversion AsyncWorker
1194
1181
  class Power2mWAsyncWorker : public HamLibAsyncWorker {
1195
1182
  public:
1196
- Power2mWAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, float power, freq_t freq, rmode_t mode)
1183
+ Power2mWAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, float power, double freq, int mode)
1197
1184
  : HamLibAsyncWorker(env, hamlib_instance), power_(power), freq_(freq), mode_(mode), mwpower_(0) {}
1198
1185
 
1199
1186
  void Execute() override {
1200
1187
  CHECK_RIG_VALID();
1201
1188
 
1202
- result_code_ = rig_power2mW(hamlib_instance_->my_rig, &mwpower_, power_, freq_, mode_);
1203
- if (result_code_ != RIG_OK) {
1204
- error_message_ = rigerror(result_code_);
1189
+ result_code_ = shim_rig_power2mW(hamlib_instance_->my_rig, &mwpower_, power_, freq_, mode_);
1190
+ if (result_code_ != SHIM_RIG_OK) {
1191
+ error_message_ = shim_rigerror(result_code_);
1205
1192
  }
1206
1193
  }
1207
1194
 
1208
1195
  void OnOK() override {
1209
1196
  Napi::Env env = Env();
1210
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1197
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1211
1198
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1212
1199
  } else {
1213
1200
  deferred_.Resolve(Napi::Number::New(env, mwpower_));
@@ -1221,29 +1208,29 @@ public:
1221
1208
 
1222
1209
  private:
1223
1210
  float power_;
1224
- freq_t freq_;
1225
- rmode_t mode_;
1211
+ double freq_;
1212
+ int mode_;
1226
1213
  unsigned int mwpower_;
1227
1214
  };
1228
1215
 
1229
1216
  // mW to Power Conversion AsyncWorker
1230
1217
  class MW2PowerAsyncWorker : public HamLibAsyncWorker {
1231
1218
  public:
1232
- MW2PowerAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, unsigned int mwpower, freq_t freq, rmode_t mode)
1219
+ MW2PowerAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, unsigned int mwpower, double freq, int mode)
1233
1220
  : HamLibAsyncWorker(env, hamlib_instance), mwpower_(mwpower), freq_(freq), mode_(mode), power_(0.0) {}
1234
1221
 
1235
1222
  void Execute() override {
1236
1223
  CHECK_RIG_VALID();
1237
1224
 
1238
- result_code_ = rig_mW2power(hamlib_instance_->my_rig, &power_, mwpower_, freq_, mode_);
1239
- if (result_code_ != RIG_OK) {
1240
- error_message_ = rigerror(result_code_);
1225
+ result_code_ = shim_rig_mW2power(hamlib_instance_->my_rig, &power_, mwpower_, freq_, mode_);
1226
+ if (result_code_ != SHIM_RIG_OK) {
1227
+ error_message_ = shim_rigerror(result_code_);
1241
1228
  }
1242
1229
  }
1243
1230
 
1244
1231
  void OnOK() override {
1245
1232
  Napi::Env env = Env();
1246
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1233
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1247
1234
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1248
1235
  } else {
1249
1236
  deferred_.Resolve(Napi::Number::New(env, power_));
@@ -1257,29 +1244,29 @@ public:
1257
1244
 
1258
1245
  private:
1259
1246
  unsigned int mwpower_;
1260
- freq_t freq_;
1261
- rmode_t mode_;
1247
+ double freq_;
1248
+ int mode_;
1262
1249
  float power_;
1263
1250
  };
1264
1251
 
1265
1252
  // Set Split Mode AsyncWorker
1266
1253
  class SetSplitModeAsyncWorker : public HamLibAsyncWorker {
1267
1254
  public:
1268
- SetSplitModeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, rmode_t tx_mode, pbwidth_t tx_width, vfo_t vfo = RIG_VFO_CURR)
1255
+ SetSplitModeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int tx_mode, int tx_width, int vfo = SHIM_RIG_VFO_CURR)
1269
1256
  : HamLibAsyncWorker(env, hamlib_instance), tx_mode_(tx_mode), tx_width_(tx_width), vfo_(vfo) {}
1270
1257
 
1271
1258
  void Execute() override {
1272
1259
  CHECK_RIG_VALID();
1273
1260
 
1274
- result_code_ = rig_set_split_mode(hamlib_instance_->my_rig, vfo_, tx_mode_, tx_width_);
1275
- if (result_code_ != RIG_OK) {
1276
- error_message_ = rigerror(result_code_);
1261
+ result_code_ = shim_rig_set_split_mode(hamlib_instance_->my_rig, vfo_, tx_mode_, tx_width_);
1262
+ if (result_code_ != SHIM_RIG_OK) {
1263
+ error_message_ = shim_rigerror(result_code_);
1277
1264
  }
1278
1265
  }
1279
1266
 
1280
1267
  void OnOK() override {
1281
1268
  Napi::Env env = Env();
1282
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1269
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1283
1270
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1284
1271
  } else {
1285
1272
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -1292,34 +1279,34 @@ public:
1292
1279
  }
1293
1280
 
1294
1281
  private:
1295
- rmode_t tx_mode_;
1296
- pbwidth_t tx_width_;
1297
- vfo_t vfo_;
1282
+ int tx_mode_;
1283
+ int tx_width_;
1284
+ int vfo_;
1298
1285
  };
1299
1286
 
1300
1287
  // Get Split Mode AsyncWorker
1301
1288
  class GetSplitModeAsyncWorker : public HamLibAsyncWorker {
1302
1289
  public:
1303
- GetSplitModeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo = RIG_VFO_CURR)
1290
+ GetSplitModeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo = SHIM_RIG_VFO_CURR)
1304
1291
  : HamLibAsyncWorker(env, hamlib_instance), tx_mode_(0), tx_width_(0), vfo_(vfo) {}
1305
1292
 
1306
1293
  void Execute() override {
1307
1294
  CHECK_RIG_VALID();
1308
1295
 
1309
- result_code_ = rig_get_split_mode(hamlib_instance_->my_rig, vfo_, &tx_mode_, &tx_width_);
1310
- if (result_code_ != RIG_OK) {
1311
- error_message_ = rigerror(result_code_);
1296
+ result_code_ = shim_rig_get_split_mode(hamlib_instance_->my_rig, vfo_, &tx_mode_, &tx_width_);
1297
+ if (result_code_ != SHIM_RIG_OK) {
1298
+ error_message_ = shim_rigerror(result_code_);
1312
1299
  }
1313
1300
  }
1314
1301
 
1315
1302
  void OnOK() override {
1316
1303
  Napi::Env env = Env();
1317
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1304
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1318
1305
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1319
1306
  } else {
1320
1307
  Napi::Object obj = Napi::Object::New(env);
1321
1308
  // Convert mode to string using rig_strrmode
1322
- const char* mode_str = rig_strrmode(tx_mode_);
1309
+ const char* mode_str = shim_rig_strrmode(tx_mode_);
1323
1310
  obj.Set(Napi::String::New(env, "mode"), Napi::String::New(env, mode_str));
1324
1311
  obj.Set(Napi::String::New(env, "width"), tx_width_);
1325
1312
  deferred_.Resolve(obj);
@@ -1332,9 +1319,9 @@ public:
1332
1319
  }
1333
1320
 
1334
1321
  private:
1335
- rmode_t tx_mode_;
1336
- pbwidth_t tx_width_;
1337
- vfo_t vfo_;
1322
+ int tx_mode_;
1323
+ int tx_width_;
1324
+ int vfo_;
1338
1325
  };
1339
1326
 
1340
1327
  // Set Serial Config AsyncWorker
@@ -1349,137 +1336,137 @@ public:
1349
1336
  // Apply serial configuration parameter
1350
1337
  if (param_name_ == "data_bits") {
1351
1338
  int data_bits = std::stoi(param_value_);
1352
- hamlib_instance_->my_rig->state.rigport.parm.serial.data_bits = data_bits;
1353
- result_code_ = RIG_OK;
1339
+ shim_rig_set_serial_data_bits(hamlib_instance_->my_rig, data_bits);
1340
+ result_code_ = SHIM_RIG_OK;
1354
1341
  } else if (param_name_ == "stop_bits") {
1355
1342
  int stop_bits = std::stoi(param_value_);
1356
- hamlib_instance_->my_rig->state.rigport.parm.serial.stop_bits = stop_bits;
1357
- result_code_ = RIG_OK;
1343
+ shim_rig_set_serial_stop_bits(hamlib_instance_->my_rig, stop_bits);
1344
+ result_code_ = SHIM_RIG_OK;
1358
1345
  } else if (param_name_ == "serial_parity") {
1359
- enum serial_parity_e parity;
1346
+ int parity;
1360
1347
  if (param_value_ == "None") {
1361
- parity = RIG_PARITY_NONE;
1348
+ parity = SHIM_RIG_PARITY_NONE;
1362
1349
  } else if (param_value_ == "Even") {
1363
- parity = RIG_PARITY_EVEN;
1350
+ parity = SHIM_RIG_PARITY_EVEN;
1364
1351
  } else if (param_value_ == "Odd") {
1365
- parity = RIG_PARITY_ODD;
1352
+ parity = SHIM_RIG_PARITY_ODD;
1366
1353
  } else {
1367
- result_code_ = -RIG_EINVAL;
1354
+ result_code_ = SHIM_RIG_EINVAL;
1368
1355
  error_message_ = "Invalid parity value";
1369
1356
  return;
1370
1357
  }
1371
- hamlib_instance_->my_rig->state.rigport.parm.serial.parity = parity;
1372
- result_code_ = RIG_OK;
1358
+ shim_rig_set_serial_parity(hamlib_instance_->my_rig, parity);
1359
+ result_code_ = SHIM_RIG_OK;
1373
1360
  } else if (param_name_ == "serial_handshake") {
1374
- enum serial_handshake_e handshake;
1361
+ int handshake;
1375
1362
  if (param_value_ == "None") {
1376
- handshake = RIG_HANDSHAKE_NONE;
1363
+ handshake = SHIM_RIG_HANDSHAKE_NONE;
1377
1364
  } else if (param_value_ == "Hardware") {
1378
- handshake = RIG_HANDSHAKE_HARDWARE;
1365
+ handshake = SHIM_RIG_HANDSHAKE_HARDWARE;
1379
1366
  } else if (param_value_ == "Software") {
1380
- handshake = RIG_HANDSHAKE_XONXOFF;
1367
+ handshake = SHIM_RIG_HANDSHAKE_XONXOFF;
1381
1368
  } else {
1382
- result_code_ = -RIG_EINVAL;
1369
+ result_code_ = SHIM_RIG_EINVAL;
1383
1370
  error_message_ = "Invalid handshake value";
1384
1371
  return;
1385
1372
  }
1386
- hamlib_instance_->my_rig->state.rigport.parm.serial.handshake = handshake;
1387
- result_code_ = RIG_OK;
1373
+ shim_rig_set_serial_handshake(hamlib_instance_->my_rig, handshake);
1374
+ result_code_ = SHIM_RIG_OK;
1388
1375
  } else if (param_name_ == "rts_state") {
1389
- enum serial_control_state_e state;
1376
+ int state;
1390
1377
  if (param_value_ == "ON") {
1391
- state = RIG_SIGNAL_ON;
1378
+ state = SHIM_RIG_SIGNAL_ON;
1392
1379
  } else if (param_value_ == "OFF") {
1393
- state = RIG_SIGNAL_OFF;
1380
+ state = SHIM_RIG_SIGNAL_OFF;
1394
1381
  } else {
1395
- result_code_ = -RIG_EINVAL;
1382
+ result_code_ = SHIM_RIG_EINVAL;
1396
1383
  error_message_ = "Invalid RTS state value";
1397
1384
  return;
1398
1385
  }
1399
- hamlib_instance_->my_rig->state.rigport.parm.serial.rts_state = state;
1400
- result_code_ = RIG_OK;
1386
+ shim_rig_set_serial_rts_state(hamlib_instance_->my_rig, state);
1387
+ result_code_ = SHIM_RIG_OK;
1401
1388
  } else if (param_name_ == "dtr_state") {
1402
- enum serial_control_state_e state;
1389
+ int state;
1403
1390
  if (param_value_ == "ON") {
1404
- state = RIG_SIGNAL_ON;
1391
+ state = SHIM_RIG_SIGNAL_ON;
1405
1392
  } else if (param_value_ == "OFF") {
1406
- state = RIG_SIGNAL_OFF;
1393
+ state = SHIM_RIG_SIGNAL_OFF;
1407
1394
  } else {
1408
- result_code_ = -RIG_EINVAL;
1395
+ result_code_ = SHIM_RIG_EINVAL;
1409
1396
  error_message_ = "Invalid DTR state value";
1410
1397
  return;
1411
1398
  }
1412
- hamlib_instance_->my_rig->state.rigport.parm.serial.dtr_state = state;
1413
- result_code_ = RIG_OK;
1399
+ shim_rig_set_serial_dtr_state(hamlib_instance_->my_rig, state);
1400
+ result_code_ = SHIM_RIG_OK;
1414
1401
  } else if (param_name_ == "rate") {
1415
1402
  int rate = std::stoi(param_value_);
1416
1403
  // Validate supported baud rates based on common values in Hamlib
1417
- std::vector<int> valid_rates = {150, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200,
1418
- 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000,
1404
+ std::vector<int> valid_rates = {150, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200,
1405
+ 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000,
1419
1406
  2000000, 2500000, 3000000, 3500000, 4000000};
1420
1407
  if (std::find(valid_rates.begin(), valid_rates.end(), rate) != valid_rates.end()) {
1421
- hamlib_instance_->my_rig->state.rigport.parm.serial.rate = rate;
1422
- result_code_ = RIG_OK;
1408
+ shim_rig_set_serial_rate(hamlib_instance_->my_rig, rate);
1409
+ result_code_ = SHIM_RIG_OK;
1423
1410
  } else {
1424
- result_code_ = -RIG_EINVAL;
1411
+ result_code_ = SHIM_RIG_EINVAL;
1425
1412
  error_message_ = "Invalid baud rate value";
1426
1413
  }
1427
1414
  } else if (param_name_ == "timeout") {
1428
1415
  int timeout_val = std::stoi(param_value_);
1429
1416
  if (timeout_val >= 0) {
1430
- hamlib_instance_->my_rig->state.rigport.timeout = timeout_val;
1431
- result_code_ = RIG_OK;
1417
+ shim_rig_set_port_timeout(hamlib_instance_->my_rig, timeout_val);
1418
+ result_code_ = SHIM_RIG_OK;
1432
1419
  } else {
1433
- result_code_ = -RIG_EINVAL;
1420
+ result_code_ = SHIM_RIG_EINVAL;
1434
1421
  error_message_ = "Timeout must be non-negative";
1435
1422
  }
1436
1423
  } else if (param_name_ == "retry") {
1437
1424
  int retry_val = std::stoi(param_value_);
1438
1425
  if (retry_val >= 0) {
1439
- hamlib_instance_->my_rig->state.rigport.retry = (short)retry_val;
1440
- result_code_ = RIG_OK;
1426
+ shim_rig_set_port_retry(hamlib_instance_->my_rig, retry_val);
1427
+ result_code_ = SHIM_RIG_OK;
1441
1428
  } else {
1442
- result_code_ = -RIG_EINVAL;
1429
+ result_code_ = SHIM_RIG_EINVAL;
1443
1430
  error_message_ = "Retry count must be non-negative";
1444
1431
  }
1445
1432
  } else if (param_name_ == "write_delay") {
1446
1433
  int delay = std::stoi(param_value_);
1447
1434
  if (delay >= 0) {
1448
- hamlib_instance_->my_rig->state.rigport.write_delay = delay;
1449
- result_code_ = RIG_OK;
1435
+ shim_rig_set_port_write_delay(hamlib_instance_->my_rig, delay);
1436
+ result_code_ = SHIM_RIG_OK;
1450
1437
  } else {
1451
- result_code_ = -RIG_EINVAL;
1438
+ result_code_ = SHIM_RIG_EINVAL;
1452
1439
  error_message_ = "Write delay must be non-negative";
1453
1440
  }
1454
1441
  } else if (param_name_ == "post_write_delay") {
1455
1442
  int delay = std::stoi(param_value_);
1456
1443
  if (delay >= 0) {
1457
- hamlib_instance_->my_rig->state.rigport.post_write_delay = delay;
1458
- result_code_ = RIG_OK;
1444
+ shim_rig_set_port_post_write_delay(hamlib_instance_->my_rig, delay);
1445
+ result_code_ = SHIM_RIG_OK;
1459
1446
  } else {
1460
- result_code_ = -RIG_EINVAL;
1447
+ result_code_ = SHIM_RIG_EINVAL;
1461
1448
  error_message_ = "Post write delay must be non-negative";
1462
1449
  }
1463
1450
  } else if (param_name_ == "flushx") {
1464
1451
  if (param_value_ == "true" || param_value_ == "1") {
1465
- hamlib_instance_->my_rig->state.rigport.flushx = 1;
1466
- result_code_ = RIG_OK;
1452
+ shim_rig_set_port_flushx(hamlib_instance_->my_rig, 1);
1453
+ result_code_ = SHIM_RIG_OK;
1467
1454
  } else if (param_value_ == "false" || param_value_ == "0") {
1468
- hamlib_instance_->my_rig->state.rigport.flushx = 0;
1469
- result_code_ = RIG_OK;
1455
+ shim_rig_set_port_flushx(hamlib_instance_->my_rig, 0);
1456
+ result_code_ = SHIM_RIG_OK;
1470
1457
  } else {
1471
- result_code_ = -RIG_EINVAL;
1458
+ result_code_ = SHIM_RIG_EINVAL;
1472
1459
  error_message_ = "Flushx must be true/false or 1/0";
1473
1460
  }
1474
1461
  } else {
1475
- result_code_ = -RIG_EINVAL;
1462
+ result_code_ = SHIM_RIG_EINVAL;
1476
1463
  error_message_ = "Unknown serial configuration parameter";
1477
1464
  }
1478
1465
  }
1479
1466
 
1480
1467
  void OnOK() override {
1481
1468
  Napi::Env env = Env();
1482
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1469
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1483
1470
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1484
1471
  } else {
1485
1472
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -1507,96 +1494,96 @@ public:
1507
1494
 
1508
1495
  // Get serial configuration parameter
1509
1496
  if (param_name_ == "data_bits") {
1510
- param_value_ = std::to_string(hamlib_instance_->my_rig->state.rigport.parm.serial.data_bits);
1511
- result_code_ = RIG_OK;
1497
+ param_value_ = std::to_string(shim_rig_get_serial_data_bits(hamlib_instance_->my_rig));
1498
+ result_code_ = SHIM_RIG_OK;
1512
1499
  } else if (param_name_ == "stop_bits") {
1513
- param_value_ = std::to_string(hamlib_instance_->my_rig->state.rigport.parm.serial.stop_bits);
1514
- result_code_ = RIG_OK;
1500
+ param_value_ = std::to_string(shim_rig_get_serial_stop_bits(hamlib_instance_->my_rig));
1501
+ result_code_ = SHIM_RIG_OK;
1515
1502
  } else if (param_name_ == "serial_parity") {
1516
- switch (hamlib_instance_->my_rig->state.rigport.parm.serial.parity) {
1517
- case RIG_PARITY_NONE:
1503
+ switch (shim_rig_get_serial_parity(hamlib_instance_->my_rig)) {
1504
+ case SHIM_RIG_PARITY_NONE:
1518
1505
  param_value_ = "None";
1519
1506
  break;
1520
- case RIG_PARITY_EVEN:
1507
+ case SHIM_RIG_PARITY_EVEN:
1521
1508
  param_value_ = "Even";
1522
1509
  break;
1523
- case RIG_PARITY_ODD:
1510
+ case SHIM_RIG_PARITY_ODD:
1524
1511
  param_value_ = "Odd";
1525
1512
  break;
1526
1513
  default:
1527
1514
  param_value_ = "Unknown";
1528
1515
  break;
1529
1516
  }
1530
- result_code_ = RIG_OK;
1517
+ result_code_ = SHIM_RIG_OK;
1531
1518
  } else if (param_name_ == "serial_handshake") {
1532
- switch (hamlib_instance_->my_rig->state.rigport.parm.serial.handshake) {
1533
- case RIG_HANDSHAKE_NONE:
1519
+ switch (shim_rig_get_serial_handshake(hamlib_instance_->my_rig)) {
1520
+ case SHIM_RIG_HANDSHAKE_NONE:
1534
1521
  param_value_ = "None";
1535
1522
  break;
1536
- case RIG_HANDSHAKE_HARDWARE:
1523
+ case SHIM_RIG_HANDSHAKE_HARDWARE:
1537
1524
  param_value_ = "Hardware";
1538
1525
  break;
1539
- case RIG_HANDSHAKE_XONXOFF:
1526
+ case SHIM_RIG_HANDSHAKE_XONXOFF:
1540
1527
  param_value_ = "Software";
1541
1528
  break;
1542
1529
  default:
1543
1530
  param_value_ = "Unknown";
1544
1531
  break;
1545
1532
  }
1546
- result_code_ = RIG_OK;
1533
+ result_code_ = SHIM_RIG_OK;
1547
1534
  } else if (param_name_ == "rts_state") {
1548
- switch (hamlib_instance_->my_rig->state.rigport.parm.serial.rts_state) {
1549
- case RIG_SIGNAL_ON:
1535
+ switch (shim_rig_get_serial_rts_state(hamlib_instance_->my_rig)) {
1536
+ case SHIM_RIG_SIGNAL_ON:
1550
1537
  param_value_ = "ON";
1551
1538
  break;
1552
- case RIG_SIGNAL_OFF:
1539
+ case SHIM_RIG_SIGNAL_OFF:
1553
1540
  param_value_ = "OFF";
1554
1541
  break;
1555
1542
  default:
1556
1543
  param_value_ = "Unknown";
1557
1544
  break;
1558
1545
  }
1559
- result_code_ = RIG_OK;
1546
+ result_code_ = SHIM_RIG_OK;
1560
1547
  } else if (param_name_ == "dtr_state") {
1561
- switch (hamlib_instance_->my_rig->state.rigport.parm.serial.dtr_state) {
1562
- case RIG_SIGNAL_ON:
1548
+ switch (shim_rig_get_serial_dtr_state(hamlib_instance_->my_rig)) {
1549
+ case SHIM_RIG_SIGNAL_ON:
1563
1550
  param_value_ = "ON";
1564
1551
  break;
1565
- case RIG_SIGNAL_OFF:
1552
+ case SHIM_RIG_SIGNAL_OFF:
1566
1553
  param_value_ = "OFF";
1567
1554
  break;
1568
1555
  default:
1569
1556
  param_value_ = "Unknown";
1570
1557
  break;
1571
1558
  }
1572
- result_code_ = RIG_OK;
1559
+ result_code_ = SHIM_RIG_OK;
1573
1560
  } else if (param_name_ == "rate") {
1574
- param_value_ = std::to_string(hamlib_instance_->my_rig->state.rigport.parm.serial.rate);
1575
- result_code_ = RIG_OK;
1561
+ param_value_ = std::to_string(shim_rig_get_serial_rate(hamlib_instance_->my_rig));
1562
+ result_code_ = SHIM_RIG_OK;
1576
1563
  } else if (param_name_ == "timeout") {
1577
- param_value_ = std::to_string(hamlib_instance_->my_rig->state.rigport.timeout);
1578
- result_code_ = RIG_OK;
1564
+ param_value_ = std::to_string(shim_rig_get_port_timeout(hamlib_instance_->my_rig));
1565
+ result_code_ = SHIM_RIG_OK;
1579
1566
  } else if (param_name_ == "retry") {
1580
- param_value_ = std::to_string(hamlib_instance_->my_rig->state.rigport.retry);
1581
- result_code_ = RIG_OK;
1567
+ param_value_ = std::to_string(shim_rig_get_port_retry(hamlib_instance_->my_rig));
1568
+ result_code_ = SHIM_RIG_OK;
1582
1569
  } else if (param_name_ == "write_delay") {
1583
- param_value_ = std::to_string(hamlib_instance_->my_rig->state.rigport.write_delay);
1584
- result_code_ = RIG_OK;
1570
+ param_value_ = std::to_string(shim_rig_get_port_write_delay(hamlib_instance_->my_rig));
1571
+ result_code_ = SHIM_RIG_OK;
1585
1572
  } else if (param_name_ == "post_write_delay") {
1586
- param_value_ = std::to_string(hamlib_instance_->my_rig->state.rigport.post_write_delay);
1587
- result_code_ = RIG_OK;
1573
+ param_value_ = std::to_string(shim_rig_get_port_post_write_delay(hamlib_instance_->my_rig));
1574
+ result_code_ = SHIM_RIG_OK;
1588
1575
  } else if (param_name_ == "flushx") {
1589
- param_value_ = hamlib_instance_->my_rig->state.rigport.flushx ? "true" : "false";
1590
- result_code_ = RIG_OK;
1576
+ param_value_ = shim_rig_get_port_flushx(hamlib_instance_->my_rig) ? "true" : "false";
1577
+ result_code_ = SHIM_RIG_OK;
1591
1578
  } else {
1592
- result_code_ = -RIG_EINVAL;
1579
+ result_code_ = SHIM_RIG_EINVAL;
1593
1580
  error_message_ = "Unknown serial configuration parameter";
1594
1581
  }
1595
1582
  }
1596
1583
 
1597
1584
  void OnOK() override {
1598
1585
  Napi::Env env = Env();
1599
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1586
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1600
1587
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1601
1588
  } else {
1602
1589
  deferred_.Resolve(Napi::String::New(env, param_value_));
@@ -1616,42 +1603,42 @@ private:
1616
1603
  // Set PTT Type AsyncWorker
1617
1604
  class SetPttTypeAsyncWorker : public HamLibAsyncWorker {
1618
1605
  public:
1619
- SetPttTypeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, const std::string& ptt_type)
1620
- : HamLibAsyncWorker(env, hamlib_instance), ptt_type_(ptt_type) {}
1606
+ SetPttTypeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, const std::string& intype)
1607
+ : HamLibAsyncWorker(env, hamlib_instance), intype_(intype) {}
1621
1608
 
1622
1609
  void Execute() override {
1623
1610
  CHECK_RIG_VALID();
1624
1611
 
1625
- ptt_type_t ptt_type;
1626
- if (ptt_type_ == "RIG") {
1627
- ptt_type = RIG_PTT_RIG;
1628
- } else if (ptt_type_ == "DTR") {
1629
- ptt_type = RIG_PTT_SERIAL_DTR;
1630
- } else if (ptt_type_ == "RTS") {
1631
- ptt_type = RIG_PTT_SERIAL_RTS;
1632
- } else if (ptt_type_ == "PARALLEL") {
1633
- ptt_type = RIG_PTT_PARALLEL;
1634
- } else if (ptt_type_ == "CM108") {
1635
- ptt_type = RIG_PTT_CM108;
1636
- } else if (ptt_type_ == "GPIO") {
1637
- ptt_type = RIG_PTT_GPIO;
1638
- } else if (ptt_type_ == "GPION") {
1639
- ptt_type = RIG_PTT_GPION;
1640
- } else if (ptt_type_ == "NONE") {
1641
- ptt_type = RIG_PTT_NONE;
1612
+ int intype;
1613
+ if (intype_ == "RIG") {
1614
+ intype = SHIM_RIG_PTT_RIG;
1615
+ } else if (intype_ == "DTR") {
1616
+ intype = SHIM_RIG_PTT_SERIAL_DTR;
1617
+ } else if (intype_ == "RTS") {
1618
+ intype = SHIM_RIG_PTT_SERIAL_RTS;
1619
+ } else if (intype_ == "PARALLEL") {
1620
+ intype = SHIM_RIG_PTT_PARALLEL;
1621
+ } else if (intype_ == "CM108") {
1622
+ intype = SHIM_RIG_PTT_CM108;
1623
+ } else if (intype_ == "GPIO") {
1624
+ intype = SHIM_RIG_PTT_GPIO;
1625
+ } else if (intype_ == "GPION") {
1626
+ intype = SHIM_RIG_PTT_GPION;
1627
+ } else if (intype_ == "NONE") {
1628
+ intype = SHIM_RIG_PTT_NONE;
1642
1629
  } else {
1643
- result_code_ = -RIG_EINVAL;
1630
+ result_code_ = SHIM_RIG_EINVAL;
1644
1631
  error_message_ = "Invalid PTT type";
1645
1632
  return;
1646
1633
  }
1647
1634
 
1648
- hamlib_instance_->my_rig->state.pttport.type.ptt = ptt_type;
1649
- result_code_ = RIG_OK;
1635
+ shim_rig_set_ptt_type(hamlib_instance_->my_rig, intype);
1636
+ result_code_ = SHIM_RIG_OK;
1650
1637
  }
1651
1638
 
1652
1639
  void OnOK() override {
1653
1640
  Napi::Env env = Env();
1654
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1641
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1655
1642
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1656
1643
  } else {
1657
1644
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -1664,7 +1651,7 @@ public:
1664
1651
  }
1665
1652
 
1666
1653
  private:
1667
- std::string ptt_type_;
1654
+ std::string intype_;
1668
1655
  };
1669
1656
 
1670
1657
  // Get PTT Type AsyncWorker
@@ -1676,46 +1663,46 @@ public:
1676
1663
  void Execute() override {
1677
1664
  CHECK_RIG_VALID();
1678
1665
 
1679
- ptt_type_t ptt_type = hamlib_instance_->my_rig->state.pttport.type.ptt;
1666
+ int intype = shim_rig_get_ptt_type(hamlib_instance_->my_rig);
1680
1667
 
1681
- switch (ptt_type) {
1682
- case RIG_PTT_RIG:
1683
- ptt_type_str_ = "RIG";
1668
+ switch (intype) {
1669
+ case SHIM_RIG_PTT_RIG:
1670
+ intype_str_ = "RIG";
1684
1671
  break;
1685
- case RIG_PTT_SERIAL_DTR:
1686
- ptt_type_str_ = "DTR";
1672
+ case SHIM_RIG_PTT_SERIAL_DTR:
1673
+ intype_str_ = "DTR";
1687
1674
  break;
1688
- case RIG_PTT_SERIAL_RTS:
1689
- ptt_type_str_ = "RTS";
1675
+ case SHIM_RIG_PTT_SERIAL_RTS:
1676
+ intype_str_ = "RTS";
1690
1677
  break;
1691
- case RIG_PTT_PARALLEL:
1692
- ptt_type_str_ = "PARALLEL";
1678
+ case SHIM_RIG_PTT_PARALLEL:
1679
+ intype_str_ = "PARALLEL";
1693
1680
  break;
1694
- case RIG_PTT_CM108:
1695
- ptt_type_str_ = "CM108";
1681
+ case SHIM_RIG_PTT_CM108:
1682
+ intype_str_ = "CM108";
1696
1683
  break;
1697
- case RIG_PTT_GPIO:
1698
- ptt_type_str_ = "GPIO";
1684
+ case SHIM_RIG_PTT_GPIO:
1685
+ intype_str_ = "GPIO";
1699
1686
  break;
1700
- case RIG_PTT_GPION:
1701
- ptt_type_str_ = "GPION";
1687
+ case SHIM_RIG_PTT_GPION:
1688
+ intype_str_ = "GPION";
1702
1689
  break;
1703
- case RIG_PTT_NONE:
1704
- ptt_type_str_ = "NONE";
1690
+ case SHIM_RIG_PTT_NONE:
1691
+ intype_str_ = "NONE";
1705
1692
  break;
1706
1693
  default:
1707
- ptt_type_str_ = "Unknown";
1694
+ intype_str_ = "Unknown";
1708
1695
  break;
1709
1696
  }
1710
- result_code_ = RIG_OK;
1697
+ result_code_ = SHIM_RIG_OK;
1711
1698
  }
1712
1699
 
1713
1700
  void OnOK() override {
1714
1701
  Napi::Env env = Env();
1715
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1702
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1716
1703
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1717
1704
  } else {
1718
- deferred_.Resolve(Napi::String::New(env, ptt_type_str_));
1705
+ deferred_.Resolve(Napi::String::New(env, intype_str_));
1719
1706
  }
1720
1707
  }
1721
1708
 
@@ -1725,50 +1712,50 @@ public:
1725
1712
  }
1726
1713
 
1727
1714
  private:
1728
- std::string ptt_type_str_;
1715
+ std::string intype_str_;
1729
1716
  };
1730
1717
 
1731
1718
  // Set DCD Type AsyncWorker
1732
1719
  class SetDcdTypeAsyncWorker : public HamLibAsyncWorker {
1733
1720
  public:
1734
- SetDcdTypeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, const std::string& dcd_type)
1735
- : HamLibAsyncWorker(env, hamlib_instance), dcd_type_(dcd_type) {}
1721
+ SetDcdTypeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, const std::string& intype)
1722
+ : HamLibAsyncWorker(env, hamlib_instance), intype_(intype) {}
1736
1723
 
1737
1724
  void Execute() override {
1738
1725
  CHECK_RIG_VALID();
1739
1726
 
1740
- dcd_type_t dcd_type;
1741
- if (dcd_type_ == "RIG") {
1742
- dcd_type = RIG_DCD_RIG;
1743
- } else if (dcd_type_ == "DSR") {
1744
- dcd_type = RIG_DCD_SERIAL_DSR;
1745
- } else if (dcd_type_ == "CTS") {
1746
- dcd_type = RIG_DCD_SERIAL_CTS;
1747
- } else if (dcd_type_ == "CD") {
1748
- dcd_type = RIG_DCD_SERIAL_CAR;
1749
- } else if (dcd_type_ == "PARALLEL") {
1750
- dcd_type = RIG_DCD_PARALLEL;
1751
- } else if (dcd_type_ == "CM108") {
1752
- dcd_type = RIG_DCD_CM108;
1753
- } else if (dcd_type_ == "GPIO") {
1754
- dcd_type = RIG_DCD_GPIO;
1755
- } else if (dcd_type_ == "GPION") {
1756
- dcd_type = RIG_DCD_GPION;
1757
- } else if (dcd_type_ == "NONE") {
1758
- dcd_type = RIG_DCD_NONE;
1727
+ int intype;
1728
+ if (intype_ == "RIG") {
1729
+ intype = SHIM_RIG_DCD_RIG;
1730
+ } else if (intype_ == "DSR") {
1731
+ intype = SHIM_RIG_DCD_SERIAL_DSR;
1732
+ } else if (intype_ == "CTS") {
1733
+ intype = SHIM_RIG_DCD_SERIAL_CTS;
1734
+ } else if (intype_ == "CD") {
1735
+ intype = SHIM_RIG_DCD_SERIAL_CAR;
1736
+ } else if (intype_ == "PARALLEL") {
1737
+ intype = SHIM_RIG_DCD_PARALLEL;
1738
+ } else if (intype_ == "CM108") {
1739
+ intype = SHIM_RIG_DCD_CM108;
1740
+ } else if (intype_ == "GPIO") {
1741
+ intype = SHIM_RIG_DCD_GPIO;
1742
+ } else if (intype_ == "GPION") {
1743
+ intype = SHIM_RIG_DCD_GPION;
1744
+ } else if (intype_ == "NONE") {
1745
+ intype = SHIM_RIG_DCD_NONE;
1759
1746
  } else {
1760
- result_code_ = -RIG_EINVAL;
1747
+ result_code_ = SHIM_RIG_EINVAL;
1761
1748
  error_message_ = "Invalid DCD type";
1762
1749
  return;
1763
1750
  }
1764
1751
 
1765
- hamlib_instance_->my_rig->state.dcdport.type.dcd = dcd_type;
1766
- result_code_ = RIG_OK;
1752
+ shim_rig_set_dcd_type(hamlib_instance_->my_rig, intype);
1753
+ result_code_ = SHIM_RIG_OK;
1767
1754
  }
1768
1755
 
1769
1756
  void OnOK() override {
1770
1757
  Napi::Env env = Env();
1771
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1758
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1772
1759
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1773
1760
  } else {
1774
1761
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -1781,7 +1768,7 @@ public:
1781
1768
  }
1782
1769
 
1783
1770
  private:
1784
- std::string dcd_type_;
1771
+ std::string intype_;
1785
1772
  };
1786
1773
 
1787
1774
  // Get DCD Type AsyncWorker
@@ -1793,49 +1780,49 @@ public:
1793
1780
  void Execute() override {
1794
1781
  CHECK_RIG_VALID();
1795
1782
 
1796
- dcd_type_t dcd_type = hamlib_instance_->my_rig->state.dcdport.type.dcd;
1783
+ int intype = shim_rig_get_dcd_type(hamlib_instance_->my_rig);
1797
1784
 
1798
- switch (dcd_type) {
1799
- case RIG_DCD_RIG:
1800
- dcd_type_str_ = "RIG";
1785
+ switch (intype) {
1786
+ case SHIM_RIG_DCD_RIG:
1787
+ intype_str_ = "RIG";
1801
1788
  break;
1802
- case RIG_DCD_SERIAL_DSR:
1803
- dcd_type_str_ = "DSR";
1789
+ case SHIM_RIG_DCD_SERIAL_DSR:
1790
+ intype_str_ = "DSR";
1804
1791
  break;
1805
- case RIG_DCD_SERIAL_CTS:
1806
- dcd_type_str_ = "CTS";
1792
+ case SHIM_RIG_DCD_SERIAL_CTS:
1793
+ intype_str_ = "CTS";
1807
1794
  break;
1808
- case RIG_DCD_SERIAL_CAR:
1809
- dcd_type_str_ = "CD";
1795
+ case SHIM_RIG_DCD_SERIAL_CAR:
1796
+ intype_str_ = "CD";
1810
1797
  break;
1811
- case RIG_DCD_PARALLEL:
1812
- dcd_type_str_ = "PARALLEL";
1798
+ case SHIM_RIG_DCD_PARALLEL:
1799
+ intype_str_ = "PARALLEL";
1813
1800
  break;
1814
- case RIG_DCD_CM108:
1815
- dcd_type_str_ = "CM108";
1801
+ case SHIM_RIG_DCD_CM108:
1802
+ intype_str_ = "CM108";
1816
1803
  break;
1817
- case RIG_DCD_GPIO:
1818
- dcd_type_str_ = "GPIO";
1804
+ case SHIM_RIG_DCD_GPIO:
1805
+ intype_str_ = "GPIO";
1819
1806
  break;
1820
- case RIG_DCD_GPION:
1821
- dcd_type_str_ = "GPION";
1807
+ case SHIM_RIG_DCD_GPION:
1808
+ intype_str_ = "GPION";
1822
1809
  break;
1823
- case RIG_DCD_NONE:
1824
- dcd_type_str_ = "NONE";
1810
+ case SHIM_RIG_DCD_NONE:
1811
+ intype_str_ = "NONE";
1825
1812
  break;
1826
1813
  default:
1827
- dcd_type_str_ = "Unknown";
1814
+ intype_str_ = "Unknown";
1828
1815
  break;
1829
1816
  }
1830
- result_code_ = RIG_OK;
1817
+ result_code_ = SHIM_RIG_OK;
1831
1818
  }
1832
1819
 
1833
1820
  void OnOK() override {
1834
1821
  Napi::Env env = Env();
1835
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1822
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1836
1823
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1837
1824
  } else {
1838
- deferred_.Resolve(Napi::String::New(env, dcd_type_str_));
1825
+ deferred_.Resolve(Napi::String::New(env, intype_str_));
1839
1826
  }
1840
1827
  }
1841
1828
 
@@ -1845,27 +1832,27 @@ public:
1845
1832
  }
1846
1833
 
1847
1834
  private:
1848
- std::string dcd_type_str_;
1835
+ std::string intype_str_;
1849
1836
  };
1850
1837
 
1851
1838
  // Power Control AsyncWorker classes
1852
1839
  class SetPowerstatAsyncWorker : public HamLibAsyncWorker {
1853
1840
  public:
1854
- SetPowerstatAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, powerstat_t status)
1841
+ SetPowerstatAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int status)
1855
1842
  : HamLibAsyncWorker(env, hamlib_instance), status_(status) {}
1856
1843
 
1857
1844
  void Execute() override {
1858
1845
  CHECK_RIG_VALID();
1859
1846
 
1860
- result_code_ = rig_set_powerstat(hamlib_instance_->my_rig, status_);
1861
- if (result_code_ != RIG_OK) {
1862
- error_message_ = rigerror(result_code_);
1847
+ result_code_ = shim_rig_set_powerstat(hamlib_instance_->my_rig, status_);
1848
+ if (result_code_ != SHIM_RIG_OK) {
1849
+ error_message_ = shim_rigerror(result_code_);
1863
1850
  }
1864
1851
  }
1865
1852
 
1866
1853
  void OnOK() override {
1867
1854
  Napi::Env env = Env();
1868
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1855
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1869
1856
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1870
1857
  } else {
1871
1858
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -1878,26 +1865,26 @@ public:
1878
1865
  }
1879
1866
 
1880
1867
  private:
1881
- powerstat_t status_;
1868
+ int status_;
1882
1869
  };
1883
1870
 
1884
1871
  class GetPowerstatAsyncWorker : public HamLibAsyncWorker {
1885
1872
  public:
1886
1873
  GetPowerstatAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance)
1887
- : HamLibAsyncWorker(env, hamlib_instance), status_(RIG_POWER_UNKNOWN) {}
1874
+ : HamLibAsyncWorker(env, hamlib_instance), status_(SHIM_RIG_POWER_UNKNOWN) {}
1888
1875
 
1889
1876
  void Execute() override {
1890
1877
  CHECK_RIG_VALID();
1891
1878
 
1892
- result_code_ = rig_get_powerstat(hamlib_instance_->my_rig, &status_);
1893
- if (result_code_ != RIG_OK) {
1894
- error_message_ = rigerror(result_code_);
1879
+ result_code_ = shim_rig_get_powerstat(hamlib_instance_->my_rig, &status_);
1880
+ if (result_code_ != SHIM_RIG_OK) {
1881
+ error_message_ = shim_rigerror(result_code_);
1895
1882
  }
1896
1883
  }
1897
1884
 
1898
1885
  void OnOK() override {
1899
1886
  Napi::Env env = Env();
1900
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1887
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1901
1888
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1902
1889
  } else {
1903
1890
  deferred_.Resolve(Napi::Number::New(env, static_cast<int>(status_)));
@@ -1910,30 +1897,30 @@ public:
1910
1897
  }
1911
1898
 
1912
1899
  private:
1913
- powerstat_t status_;
1900
+ int status_;
1914
1901
  };
1915
1902
 
1916
1903
  // PTT Status Detection AsyncWorker
1917
1904
  class GetPttAsyncWorker : public HamLibAsyncWorker {
1918
1905
  public:
1919
- GetPttAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
1920
- : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ptt_(RIG_PTT_OFF) {}
1906
+ GetPttAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
1907
+ : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ptt_(SHIM_RIG_PTT_OFF) {}
1921
1908
 
1922
1909
  void Execute() override {
1923
1910
  CHECK_RIG_VALID();
1924
1911
 
1925
- result_code_ = rig_get_ptt(hamlib_instance_->my_rig, vfo_, &ptt_);
1926
- if (result_code_ != RIG_OK) {
1927
- error_message_ = rigerror(result_code_);
1912
+ result_code_ = shim_rig_get_ptt(hamlib_instance_->my_rig, vfo_, &ptt_);
1913
+ if (result_code_ != SHIM_RIG_OK) {
1914
+ error_message_ = shim_rigerror(result_code_);
1928
1915
  }
1929
1916
  }
1930
1917
 
1931
1918
  void OnOK() override {
1932
1919
  Napi::Env env = Env();
1933
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1920
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1934
1921
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1935
1922
  } else {
1936
- deferred_.Resolve(Napi::Boolean::New(env, ptt_ == RIG_PTT_ON));
1923
+ deferred_.Resolve(Napi::Boolean::New(env, ptt_ == SHIM_RIG_PTT_ON));
1937
1924
  }
1938
1925
  }
1939
1926
 
@@ -1943,31 +1930,31 @@ public:
1943
1930
  }
1944
1931
 
1945
1932
  private:
1946
- vfo_t vfo_;
1947
- ptt_t ptt_;
1933
+ int vfo_;
1934
+ int ptt_;
1948
1935
  };
1949
1936
 
1950
1937
  // Data Carrier Detect AsyncWorker
1951
1938
  class GetDcdAsyncWorker : public HamLibAsyncWorker {
1952
1939
  public:
1953
- GetDcdAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
1954
- : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), dcd_(RIG_DCD_OFF) {}
1940
+ GetDcdAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
1941
+ : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), dcd_(SHIM_RIG_DCD_OFF) {}
1955
1942
 
1956
1943
  void Execute() override {
1957
1944
  CHECK_RIG_VALID();
1958
1945
 
1959
- result_code_ = rig_get_dcd(hamlib_instance_->my_rig, vfo_, &dcd_);
1960
- if (result_code_ != RIG_OK) {
1961
- error_message_ = rigerror(result_code_);
1946
+ result_code_ = shim_rig_get_dcd(hamlib_instance_->my_rig, vfo_, &dcd_);
1947
+ if (result_code_ != SHIM_RIG_OK) {
1948
+ error_message_ = shim_rigerror(result_code_);
1962
1949
  }
1963
1950
  }
1964
1951
 
1965
1952
  void OnOK() override {
1966
1953
  Napi::Env env = Env();
1967
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1954
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
1968
1955
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
1969
1956
  } else {
1970
- deferred_.Resolve(Napi::Boolean::New(env, dcd_ == RIG_DCD_ON));
1957
+ deferred_.Resolve(Napi::Boolean::New(env, dcd_ == SHIM_RIG_DCD_ON));
1971
1958
  }
1972
1959
  }
1973
1960
 
@@ -1977,28 +1964,28 @@ public:
1977
1964
  }
1978
1965
 
1979
1966
  private:
1980
- vfo_t vfo_;
1981
- dcd_t dcd_;
1967
+ int vfo_;
1968
+ int dcd_;
1982
1969
  };
1983
1970
 
1984
1971
  // Tuning Step Control AsyncWorker classes
1985
1972
  class SetTuningStepAsyncWorker : public HamLibAsyncWorker {
1986
1973
  public:
1987
- SetTuningStepAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, shortfreq_t ts)
1974
+ SetTuningStepAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, int ts)
1988
1975
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ts_(ts) {}
1989
1976
 
1990
1977
  void Execute() override {
1991
1978
  CHECK_RIG_VALID();
1992
1979
 
1993
- result_code_ = rig_set_ts(hamlib_instance_->my_rig, vfo_, ts_);
1994
- if (result_code_ != RIG_OK) {
1995
- error_message_ = rigerror(result_code_);
1980
+ result_code_ = shim_rig_set_ts(hamlib_instance_->my_rig, vfo_, ts_);
1981
+ if (result_code_ != SHIM_RIG_OK) {
1982
+ error_message_ = shim_rigerror(result_code_);
1996
1983
  }
1997
1984
  }
1998
1985
 
1999
1986
  void OnOK() override {
2000
1987
  Napi::Env env = Env();
2001
- if (result_code_ != RIG_OK && !error_message_.empty()) {
1988
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
2002
1989
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
2003
1990
  } else {
2004
1991
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -2011,27 +1998,27 @@ public:
2011
1998
  }
2012
1999
 
2013
2000
  private:
2014
- vfo_t vfo_;
2015
- shortfreq_t ts_;
2001
+ int vfo_;
2002
+ int ts_;
2016
2003
  };
2017
2004
 
2018
2005
  class GetTuningStepAsyncWorker : public HamLibAsyncWorker {
2019
2006
  public:
2020
- GetTuningStepAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
2007
+ GetTuningStepAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
2021
2008
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ts_(0) {}
2022
2009
 
2023
2010
  void Execute() override {
2024
2011
  CHECK_RIG_VALID();
2025
2012
 
2026
- result_code_ = rig_get_ts(hamlib_instance_->my_rig, vfo_, &ts_);
2027
- if (result_code_ != RIG_OK) {
2028
- error_message_ = rigerror(result_code_);
2013
+ result_code_ = shim_rig_get_ts(hamlib_instance_->my_rig, vfo_, &ts_);
2014
+ if (result_code_ != SHIM_RIG_OK) {
2015
+ error_message_ = shim_rigerror(result_code_);
2029
2016
  }
2030
2017
  }
2031
2018
 
2032
2019
  void OnOK() override {
2033
2020
  Napi::Env env = Env();
2034
- if (result_code_ != RIG_OK && !error_message_.empty()) {
2021
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
2035
2022
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
2036
2023
  } else {
2037
2024
  deferred_.Resolve(Napi::Number::New(env, ts_));
@@ -2044,28 +2031,28 @@ public:
2044
2031
  }
2045
2032
 
2046
2033
  private:
2047
- vfo_t vfo_;
2048
- shortfreq_t ts_;
2034
+ int vfo_;
2035
+ int ts_;
2049
2036
  };
2050
2037
 
2051
2038
  // Repeater Control AsyncWorker classes
2052
2039
  class SetRepeaterShiftAsyncWorker : public HamLibAsyncWorker {
2053
2040
  public:
2054
- SetRepeaterShiftAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, rptr_shift_t shift)
2041
+ SetRepeaterShiftAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, int shift)
2055
2042
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), shift_(shift) {}
2056
2043
 
2057
2044
  void Execute() override {
2058
2045
  CHECK_RIG_VALID();
2059
2046
 
2060
- result_code_ = rig_set_rptr_shift(hamlib_instance_->my_rig, vfo_, shift_);
2061
- if (result_code_ != RIG_OK) {
2062
- error_message_ = rigerror(result_code_);
2047
+ result_code_ = shim_rig_set_rptr_shift(hamlib_instance_->my_rig, vfo_, shift_);
2048
+ if (result_code_ != SHIM_RIG_OK) {
2049
+ error_message_ = shim_rigerror(result_code_);
2063
2050
  }
2064
2051
  }
2065
2052
 
2066
2053
  void OnOK() override {
2067
2054
  Napi::Env env = Env();
2068
- if (result_code_ != RIG_OK && !error_message_.empty()) {
2055
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
2069
2056
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
2070
2057
  } else {
2071
2058
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -2078,27 +2065,27 @@ public:
2078
2065
  }
2079
2066
 
2080
2067
  private:
2081
- vfo_t vfo_;
2082
- rptr_shift_t shift_;
2068
+ int vfo_;
2069
+ int shift_;
2083
2070
  };
2084
2071
 
2085
2072
  class GetRepeaterShiftAsyncWorker : public HamLibAsyncWorker {
2086
2073
  public:
2087
- GetRepeaterShiftAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
2088
- : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), shift_(RIG_RPT_SHIFT_NONE) {}
2074
+ GetRepeaterShiftAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
2075
+ : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), shift_(SHIM_RIG_RPT_SHIFT_NONE) {}
2089
2076
 
2090
2077
  void Execute() override {
2091
2078
  CHECK_RIG_VALID();
2092
2079
 
2093
- result_code_ = rig_get_rptr_shift(hamlib_instance_->my_rig, vfo_, &shift_);
2094
- if (result_code_ != RIG_OK) {
2095
- error_message_ = rigerror(result_code_);
2080
+ result_code_ = shim_rig_get_rptr_shift(hamlib_instance_->my_rig, vfo_, &shift_);
2081
+ if (result_code_ != SHIM_RIG_OK) {
2082
+ error_message_ = shim_rigerror(result_code_);
2096
2083
  }
2097
2084
  }
2098
2085
 
2099
2086
  void OnOK() override {
2100
2087
  Napi::Env env = Env();
2101
- const char* shift_str = rig_strptrshift(shift_);
2088
+ const char* shift_str = shim_rig_strptrshift(shift_);
2102
2089
  deferred_.Resolve(Napi::String::New(env, shift_str));
2103
2090
  }
2104
2091
 
@@ -2108,27 +2095,27 @@ public:
2108
2095
  }
2109
2096
 
2110
2097
  private:
2111
- vfo_t vfo_;
2112
- rptr_shift_t shift_;
2098
+ int vfo_;
2099
+ int shift_;
2113
2100
  };
2114
2101
 
2115
2102
  class SetRepeaterOffsetAsyncWorker : public HamLibAsyncWorker {
2116
2103
  public:
2117
- SetRepeaterOffsetAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, shortfreq_t offset)
2104
+ SetRepeaterOffsetAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, int offset)
2118
2105
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), offset_(offset) {}
2119
2106
 
2120
2107
  void Execute() override {
2121
2108
  CHECK_RIG_VALID();
2122
2109
 
2123
- result_code_ = rig_set_rptr_offs(hamlib_instance_->my_rig, vfo_, offset_);
2124
- if (result_code_ != RIG_OK) {
2125
- error_message_ = rigerror(result_code_);
2110
+ result_code_ = shim_rig_set_rptr_offs(hamlib_instance_->my_rig, vfo_, offset_);
2111
+ if (result_code_ != SHIM_RIG_OK) {
2112
+ error_message_ = shim_rigerror(result_code_);
2126
2113
  }
2127
2114
  }
2128
2115
 
2129
2116
  void OnOK() override {
2130
2117
  Napi::Env env = Env();
2131
- if (result_code_ != RIG_OK && !error_message_.empty()) {
2118
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
2132
2119
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
2133
2120
  } else {
2134
2121
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -2141,27 +2128,27 @@ public:
2141
2128
  }
2142
2129
 
2143
2130
  private:
2144
- vfo_t vfo_;
2145
- shortfreq_t offset_;
2131
+ int vfo_;
2132
+ int offset_;
2146
2133
  };
2147
2134
 
2148
2135
  class GetRepeaterOffsetAsyncWorker : public HamLibAsyncWorker {
2149
2136
  public:
2150
- GetRepeaterOffsetAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
2137
+ GetRepeaterOffsetAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
2151
2138
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), offset_(0) {}
2152
2139
 
2153
2140
  void Execute() override {
2154
2141
  CHECK_RIG_VALID();
2155
2142
 
2156
- result_code_ = rig_get_rptr_offs(hamlib_instance_->my_rig, vfo_, &offset_);
2157
- if (result_code_ != RIG_OK) {
2158
- error_message_ = rigerror(result_code_);
2143
+ result_code_ = shim_rig_get_rptr_offs(hamlib_instance_->my_rig, vfo_, &offset_);
2144
+ if (result_code_ != SHIM_RIG_OK) {
2145
+ error_message_ = shim_rigerror(result_code_);
2159
2146
  }
2160
2147
  }
2161
2148
 
2162
2149
  void OnOK() override {
2163
2150
  Napi::Env env = Env();
2164
- if (result_code_ != RIG_OK && !error_message_.empty()) {
2151
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
2165
2152
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
2166
2153
  } else {
2167
2154
  deferred_.Resolve(Napi::Number::New(env, offset_));
@@ -2174,18 +2161,18 @@ public:
2174
2161
  }
2175
2162
 
2176
2163
  private:
2177
- vfo_t vfo_;
2178
- shortfreq_t offset_;
2164
+ int vfo_;
2165
+ int offset_;
2179
2166
  };
2180
2167
 
2181
2168
  // Helper function to parse VFO parameter from JavaScript
2182
- vfo_t parseVfoParameter(const Napi::CallbackInfo& info, int index, vfo_t defaultVfo = RIG_VFO_CURR) {
2169
+ int parseVfoParameter(const Napi::CallbackInfo& info, int index, int defaultVfo = SHIM_RIG_VFO_CURR) {
2183
2170
  if (info.Length() > index && info[index].IsString()) {
2184
2171
  std::string vfoStr = info[index].As<Napi::String>().Utf8Value();
2185
2172
  if (vfoStr == "VFO-A") {
2186
- return RIG_VFO_A;
2173
+ return SHIM_RIG_VFO_A;
2187
2174
  } else if (vfoStr == "VFO-B") {
2188
- return RIG_VFO_B;
2175
+ return SHIM_RIG_VFO_B;
2189
2176
  }
2190
2177
  }
2191
2178
  return defaultVfo;
@@ -2205,67 +2192,66 @@ NodeHamLib::NodeHamLib(const Napi::CallbackInfo & info): ObjectWrap(info) {
2205
2192
  }
2206
2193
 
2207
2194
  // Set default port path if not provided
2208
- strncpy(port_path, "/dev/ttyUSB0", HAMLIB_FILPATHLEN - 1);
2209
- port_path[HAMLIB_FILPATHLEN - 1] = '\0';
2195
+ strncpy(port_path, "/dev/ttyUSB0", SHIM_HAMLIB_FILPATHLEN - 1);
2196
+ port_path[SHIM_HAMLIB_FILPATHLEN - 1] = '\0';
2210
2197
 
2211
2198
  // Check if port path is provided as second argument
2212
2199
  if (info.Length() >= 2) {
2213
2200
  if (info[1].IsString()) {
2214
2201
  std::string portStr = info[1].As<Napi::String>().Utf8Value();
2215
- strncpy(port_path, portStr.c_str(), HAMLIB_FILPATHLEN - 1);
2216
- port_path[HAMLIB_FILPATHLEN - 1] = '\0';
2217
- } else {
2218
- // If second argument exists but is not a string, treat it as debug level (backward compatibility)
2219
- rig_set_debug_level(RIG_DEBUG_NONE);
2202
+ strncpy(port_path, portStr.c_str(), SHIM_HAMLIB_FILPATHLEN - 1);
2203
+ port_path[SHIM_HAMLIB_FILPATHLEN - 1] = '\0';
2220
2204
  }
2221
- } else {
2222
- rig_set_debug_level(RIG_DEBUG_NONE);
2205
+ // Note: Debug level is now controlled globally via HamLib.setDebugLevel()
2206
+ // and set to RIG_DEBUG_NONE by default in addon initialization
2223
2207
  }
2224
- //rig_model_t myrig_model;
2208
+ //unsigned int myrig_model;
2225
2209
  // hamlib_port_t myport;
2226
2210
  // /* may be overriden by backend probe */
2227
2211
  // myport.type.rig = RIG_PORT_SERIAL;
2228
2212
  // myport.parm.serial.rate = 38400;
2229
2213
  // myport.parm.serial.data_bits = 8;
2230
2214
  // myport.parm.serial.stop_bits = 2;
2231
- // myport.parm.serial.parity = RIG_PARITY_NONE;
2232
- // myport.parm.serial.handshake = RIG_HANDSHAKE_HARDWARE;
2233
- // strncpy(myport.pathname, "/dev/ttyUSB0", HAMLIB_FILPATHLEN - 1);
2215
+ // myport.parm.serial.parity = SHIM_RIG_PARITY_NONE;
2216
+ // myport.parm.serial.handshake = SHIM_RIG_HANDSHAKE_HARDWARE;
2217
+ // strncpy(myport.pathname, "/dev/ttyUSB0", SHIM_HAMLIB_FILPATHLEN - 1);
2234
2218
 
2235
- // rig_load_all_backends();
2219
+ // shim_rig_load_all_backends();
2236
2220
  // myrig_model = rig_probe(&myport);
2237
2221
  // fprintf(stderr, "Got Rig Model %d \n", myrig_model);
2238
2222
 
2239
- rig_model_t myrig_model = info[0].As < Napi::Number > ().DoubleValue();
2223
+ unsigned int myrig_model = info[0].As < Napi::Number > ().DoubleValue();
2240
2224
  original_model = myrig_model;
2241
2225
 
2242
2226
  // Check if port_path is a network address (contains colon)
2243
2227
  is_network_rig = isNetworkAddress(port_path);
2244
-
2228
+
2245
2229
  if (is_network_rig) {
2246
2230
  // Use NETRIGCTL model for network connections
2247
2231
  myrig_model = 2; // RIG_MODEL_NETRIGCTL
2248
- printf("Using network connection to %s\n", port_path);
2232
+ // Network connection will be established on open()
2249
2233
  }
2250
2234
 
2251
- my_rig = rig_init(myrig_model);
2235
+ my_rig = shim_rig_init(myrig_model);
2252
2236
  //int retcode = 0;
2253
2237
  if (!my_rig) {
2254
- fprintf(stderr, "Unknown rig num: %d\n", myrig_model);
2255
- fprintf(stderr, "Please check riglist.h\n");
2256
- Napi::TypeError::New(env, "Unable to Init Rig").ThrowAsJavaScriptException();
2238
+ // Create detailed error message
2239
+ std::string errorMsg = "Unable to initialize rig (model: " +
2240
+ std::to_string(myrig_model) +
2241
+ "). Please check if the model number is valid.";
2242
+ Napi::TypeError::New(env, errorMsg).ThrowAsJavaScriptException();
2257
2243
  }
2258
2244
 
2259
2245
  // Set port path and type based on connection type
2260
- strncpy(my_rig -> state.rigport.pathname, port_path, HAMLIB_FILPATHLEN - 1);
2261
-
2246
+ shim_rig_set_port_path(my_rig, port_path);
2247
+
2262
2248
  if (is_network_rig) {
2263
- my_rig -> state.rigport.type.rig = RIG_PORT_NETWORK;
2249
+ shim_rig_set_port_type(my_rig, SHIM_RIG_PORT_NETWORK);
2264
2250
  } else {
2265
- my_rig -> state.rigport.type.rig = RIG_PORT_SERIAL;
2251
+ shim_rig_set_port_type(my_rig, SHIM_RIG_PORT_SERIAL);
2266
2252
  }
2267
2253
 
2268
- // this->freq_emit_cb = [info](freq_t freq) {
2254
+ // this->freq_emit_cb = [info](double freq) {
2269
2255
  // Napi::Env env = info.Env();
2270
2256
  // Napi::Function emit = info.This().As<Napi::Object>().Get("emit").As<Napi::Function>();
2271
2257
  // emit.Call(
@@ -2282,16 +2268,16 @@ NodeHamLib::~NodeHamLib() {
2282
2268
  if (my_rig) {
2283
2269
  // 如果rig是打开状态,先关闭
2284
2270
  if (rig_is_open) {
2285
- rig_close(my_rig);
2271
+ shim_rig_close(my_rig);
2286
2272
  rig_is_open = false;
2287
2273
  }
2288
2274
  // 清理rig资源
2289
- rig_cleanup(my_rig);
2275
+ shim_rig_cleanup(my_rig);
2290
2276
  my_rig = nullptr;
2291
2277
  }
2292
2278
  }
2293
2279
 
2294
- int NodeHamLib::freq_change_cb(RIG *rig, vfo_t vfo, freq_t freq, void* arg) {
2280
+ int NodeHamLib::freq_change_cb(void *handle, int vfo, double freq, void* arg) {
2295
2281
  auto instance = static_cast<NodeHamLib*>(arg);
2296
2282
  printf("Rig changed freq to %0.7f Hz\n", freq);
2297
2283
  Napi::Env env = instance->m_currentInfo->Env();
@@ -2337,12 +2323,12 @@ Napi::Value NodeHamLib::SetVFO(const Napi::CallbackInfo & info) {
2337
2323
  }
2338
2324
 
2339
2325
  std::string name = info[0].As<Napi::String>().Utf8Value();
2340
- vfo_t vfo;
2326
+ int vfo;
2341
2327
 
2342
2328
  if (name == "VFO-A") {
2343
- vfo = RIG_VFO_A;
2329
+ vfo = SHIM_RIG_VFO_A;
2344
2330
  } else if (name == "VFO-B") {
2345
- vfo = RIG_VFO_B;
2331
+ vfo = SHIM_RIG_VFO_B;
2346
2332
  } else {
2347
2333
  Napi::TypeError::New(env, "Invalid VFO name")
2348
2334
  .ThrowAsJavaScriptException();
@@ -2376,7 +2362,7 @@ Napi::Value NodeHamLib::SetFrequency(const Napi::CallbackInfo & info) {
2376
2362
  return env.Null();
2377
2363
  }
2378
2364
 
2379
- freq_t freq = info[0].As<Napi::Number>().DoubleValue();
2365
+ double freq = info[0].As<Napi::Number>().DoubleValue();
2380
2366
 
2381
2367
  // Basic frequency range validation
2382
2368
  if (freq < 1000 || freq > 10000000000) { // 1 kHz to 10 GHz reasonable range
@@ -2385,14 +2371,14 @@ Napi::Value NodeHamLib::SetFrequency(const Napi::CallbackInfo & info) {
2385
2371
  }
2386
2372
 
2387
2373
  // Support optional VFO parameter
2388
- vfo_t vfo = RIG_VFO_CURR;
2374
+ int vfo = SHIM_RIG_VFO_CURR;
2389
2375
 
2390
2376
  if (info.Length() >= 2 && info[1].IsString()) {
2391
2377
  std::string vfostr = info[1].As<Napi::String>().Utf8Value();
2392
2378
  if (vfostr == "VFO-A") {
2393
- vfo = RIG_VFO_A;
2379
+ vfo = SHIM_RIG_VFO_A;
2394
2380
  } else if (vfostr == "VFO-B") {
2395
- vfo = RIG_VFO_B;
2381
+ vfo = SHIM_RIG_VFO_B;
2396
2382
  }
2397
2383
  }
2398
2384
 
@@ -2424,32 +2410,32 @@ Napi::Value NodeHamLib::SetMode(const Napi::CallbackInfo & info) {
2424
2410
  }
2425
2411
 
2426
2412
  std::string modestr = info[0].As<Napi::String>().Utf8Value();
2427
- rmode_t mode = rig_parse_mode(modestr.c_str());
2413
+ int mode = shim_rig_parse_mode(modestr.c_str());
2428
2414
 
2429
- if (mode == RIG_MODE_NONE) {
2415
+ if (mode == SHIM_RIG_MODE_NONE) {
2430
2416
  Napi::Error::New(env, "Invalid mode: " + modestr).ThrowAsJavaScriptException();
2431
2417
  return env.Null();
2432
2418
  }
2433
2419
 
2434
- pbwidth_t bandwidth = RIG_PASSBAND_NORMAL;
2435
- vfo_t vfo = RIG_VFO_CURR;
2420
+ int bandwidth = SHIM_RIG_PASSBAND_NORMAL;
2421
+ int vfo = SHIM_RIG_VFO_CURR;
2436
2422
 
2437
2423
  // Parse parameters: setMode(mode) or setMode(mode, bandwidth) or setMode(mode, bandwidth, vfo)
2438
2424
  if (info.Length() >= 2 && info[1].IsString()) {
2439
2425
  std::string bandstr = info[1].As<Napi::String>().Utf8Value();
2440
2426
  if (bandstr == "narrow") {
2441
- bandwidth = rig_passband_narrow(my_rig, mode);
2427
+ bandwidth = shim_rig_passband_narrow(my_rig, mode);
2442
2428
  } else if (bandstr == "wide") {
2443
- bandwidth = rig_passband_wide(my_rig, mode);
2429
+ bandwidth = shim_rig_passband_wide(my_rig, mode);
2444
2430
  } else {
2445
2431
  // If second parameter is not "narrow" or "wide", might be VFO
2446
- vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
2432
+ vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
2447
2433
  }
2448
2434
  }
2449
2435
 
2450
2436
  // Check for third parameter (VFO) if bandwidth was specified
2451
2437
  if (info.Length() >= 3) {
2452
- vfo = parseVfoParameter(info, 2, RIG_VFO_CURR);
2438
+ vfo = parseVfoParameter(info, 2, SHIM_RIG_VFO_CURR);
2453
2439
  }
2454
2440
 
2455
2441
  SetModeAsyncWorker* worker = new SetModeAsyncWorker(env, this, mode, bandwidth, vfo);
@@ -2481,7 +2467,7 @@ Napi::Value NodeHamLib::SetPtt(const Napi::CallbackInfo & info) {
2481
2467
 
2482
2468
  bool ptt_state = info[0].As<Napi::Boolean>();
2483
2469
 
2484
- ptt_t ptt = ptt_state ? RIG_PTT_ON : RIG_PTT_OFF;
2470
+ int ptt = ptt_state ? SHIM_RIG_PTT_ON : SHIM_RIG_PTT_OFF;
2485
2471
  SetPttAsyncWorker* worker = new SetPttAsyncWorker(env, this, ptt);
2486
2472
  worker->Queue();
2487
2473
 
@@ -2513,14 +2499,14 @@ Napi::Value NodeHamLib::GetFrequency(const Napi::CallbackInfo & info) {
2513
2499
  }
2514
2500
 
2515
2501
  // Support optional VFO parameter
2516
- vfo_t vfo = RIG_VFO_CURR;
2502
+ int vfo = SHIM_RIG_VFO_CURR;
2517
2503
 
2518
2504
  if (info.Length() >= 1 && info[0].IsString()) {
2519
2505
  std::string vfostr = info[0].As<Napi::String>().Utf8Value();
2520
2506
  if (vfostr == "VFO-A") {
2521
- vfo = RIG_VFO_A;
2507
+ vfo = SHIM_RIG_VFO_A;
2522
2508
  } else if (vfostr == "VFO-B") {
2523
- vfo = RIG_VFO_B;
2509
+ vfo = SHIM_RIG_VFO_B;
2524
2510
  }
2525
2511
  }
2526
2512
 
@@ -2555,10 +2541,10 @@ Napi::Value NodeHamLib::GetStrength(const Napi::CallbackInfo & info) {
2555
2541
  }
2556
2542
 
2557
2543
  // Support optional VFO parameter: getStrength() or getStrength(vfo)
2558
- vfo_t vfo = RIG_VFO_CURR;
2544
+ int vfo = SHIM_RIG_VFO_CURR;
2559
2545
 
2560
2546
  if (info.Length() >= 1 && info[0].IsString()) {
2561
- vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
2547
+ vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
2562
2548
  }
2563
2549
 
2564
2550
  GetStrengthAsyncWorker* worker = new GetStrengthAsyncWorker(env, this, vfo);
@@ -2627,11 +2613,11 @@ Napi::Value NodeHamLib::SetMemoryChannel(const Napi::CallbackInfo & info) {
2627
2613
  Napi::Object chanObj = info[1].As<Napi::Object>();
2628
2614
 
2629
2615
  // Create channel structure
2630
- channel_t chan;
2616
+ shim_channel_t chan;
2631
2617
  memset(&chan, 0, sizeof(chan));
2632
2618
 
2633
2619
  chan.channel_num = channel_num;
2634
- chan.vfo = RIG_VFO_MEM;
2620
+ chan.vfo = SHIM_RIG_VFO_MEM;
2635
2621
 
2636
2622
  // Extract frequency
2637
2623
  if (chanObj.Has("frequency")) {
@@ -2641,14 +2627,14 @@ Napi::Value NodeHamLib::SetMemoryChannel(const Napi::CallbackInfo & info) {
2641
2627
  // Extract mode
2642
2628
  if (chanObj.Has("mode")) {
2643
2629
  std::string modeStr = chanObj.Get("mode").As<Napi::String>().Utf8Value();
2644
- chan.mode = rig_parse_mode(modeStr.c_str());
2630
+ chan.mode = shim_rig_parse_mode(modeStr.c_str());
2645
2631
  }
2646
2632
 
2647
2633
  // Extract bandwidth
2648
2634
  if (chanObj.Has("bandwidth")) {
2649
2635
  chan.width = chanObj.Get("bandwidth").As<Napi::Number>().Int32Value();
2650
2636
  } else {
2651
- chan.width = RIG_PASSBAND_NORMAL;
2637
+ chan.width = SHIM_RIG_PASSBAND_NORMAL;
2652
2638
  }
2653
2639
 
2654
2640
  // Extract channel description
@@ -2661,7 +2647,7 @@ Napi::Value NodeHamLib::SetMemoryChannel(const Napi::CallbackInfo & info) {
2661
2647
  // Extract TX frequency for split operation
2662
2648
  if (chanObj.Has("txFrequency")) {
2663
2649
  chan.tx_freq = chanObj.Get("txFrequency").As<Napi::Number>().DoubleValue();
2664
- chan.split = RIG_SPLIT_ON;
2650
+ chan.split = SHIM_RIG_SPLIT_ON;
2665
2651
  }
2666
2652
 
2667
2653
  // Extract CTCSS tone
@@ -2737,7 +2723,7 @@ Napi::Value NodeHamLib::SetRit(const Napi::CallbackInfo & info) {
2737
2723
  return env.Null();
2738
2724
  }
2739
2725
 
2740
- shortfreq_t rit_offset = info[0].As<Napi::Number>().Int32Value();
2726
+ int rit_offset = info[0].As<Napi::Number>().Int32Value();
2741
2727
 
2742
2728
  SetRitAsyncWorker* worker = new SetRitAsyncWorker(env, this, rit_offset);
2743
2729
  worker->Queue();
@@ -2772,7 +2758,7 @@ Napi::Value NodeHamLib::SetXit(const Napi::CallbackInfo & info) {
2772
2758
  return env.Null();
2773
2759
  }
2774
2760
 
2775
- shortfreq_t xit_offset = info[0].As<Napi::Number>().Int32Value();
2761
+ int xit_offset = info[0].As<Napi::Number>().Int32Value();
2776
2762
 
2777
2763
  SetXitAsyncWorker* worker = new SetXitAsyncWorker(env, this, xit_offset);
2778
2764
  worker->Queue();
@@ -2823,18 +2809,18 @@ Napi::Value NodeHamLib::StartScan(const Napi::CallbackInfo & info) {
2823
2809
  }
2824
2810
 
2825
2811
  std::string scanTypeStr = info[0].As<Napi::String>().Utf8Value();
2826
- scan_t scanType;
2812
+ int scanType;
2827
2813
 
2828
2814
  if (scanTypeStr == "VFO") {
2829
- scanType = RIG_SCAN_VFO;
2815
+ scanType = SHIM_RIG_SCAN_VFO;
2830
2816
  } else if (scanTypeStr == "MEM") {
2831
- scanType = RIG_SCAN_MEM;
2817
+ scanType = SHIM_RIG_SCAN_MEM;
2832
2818
  } else if (scanTypeStr == "PROG") {
2833
- scanType = RIG_SCAN_PROG;
2819
+ scanType = SHIM_RIG_SCAN_PROG;
2834
2820
  } else if (scanTypeStr == "DELTA") {
2835
- scanType = RIG_SCAN_DELTA;
2821
+ scanType = SHIM_RIG_SCAN_DELTA;
2836
2822
  } else if (scanTypeStr == "PRIO") {
2837
- scanType = RIG_SCAN_PRIO;
2823
+ scanType = SHIM_RIG_SCAN_PRIO;
2838
2824
  } else {
2839
2825
  Napi::TypeError::New(env, "Invalid scan type").ThrowAsJavaScriptException();
2840
2826
  return env.Null();
@@ -2881,56 +2867,54 @@ Napi::Value NodeHamLib::SetLevel(const Napi::CallbackInfo & info) {
2881
2867
  double levelValue = info[1].As<Napi::Number>().DoubleValue();
2882
2868
 
2883
2869
  // Map level type strings to hamlib constants
2884
- setting_t levelType;
2870
+ uint64_t levelType;
2885
2871
  if (levelTypeStr == "AF") {
2886
- levelType = RIG_LEVEL_AF;
2872
+ levelType = SHIM_RIG_LEVEL_AF;
2887
2873
  } else if (levelTypeStr == "RF") {
2888
- levelType = RIG_LEVEL_RF;
2874
+ levelType = SHIM_RIG_LEVEL_RF;
2889
2875
  } else if (levelTypeStr == "SQL") {
2890
- levelType = RIG_LEVEL_SQL;
2876
+ levelType = SHIM_RIG_LEVEL_SQL;
2891
2877
  } else if (levelTypeStr == "RFPOWER") {
2892
- levelType = RIG_LEVEL_RFPOWER;
2878
+ levelType = SHIM_RIG_LEVEL_RFPOWER;
2893
2879
  } else if (levelTypeStr == "MICGAIN") {
2894
- levelType = RIG_LEVEL_MICGAIN;
2880
+ levelType = SHIM_RIG_LEVEL_MICGAIN;
2895
2881
  } else if (levelTypeStr == "IF") {
2896
- levelType = RIG_LEVEL_IF;
2882
+ levelType = SHIM_RIG_LEVEL_IF;
2897
2883
  } else if (levelTypeStr == "APF") {
2898
- levelType = RIG_LEVEL_APF;
2884
+ levelType = SHIM_RIG_LEVEL_APF;
2899
2885
  } else if (levelTypeStr == "NR") {
2900
- levelType = RIG_LEVEL_NR;
2886
+ levelType = SHIM_RIG_LEVEL_NR;
2901
2887
  } else if (levelTypeStr == "PBT_IN") {
2902
- levelType = RIG_LEVEL_PBT_IN;
2888
+ levelType = SHIM_RIG_LEVEL_PBT_IN;
2903
2889
  } else if (levelTypeStr == "PBT_OUT") {
2904
- levelType = RIG_LEVEL_PBT_OUT;
2890
+ levelType = SHIM_RIG_LEVEL_PBT_OUT;
2905
2891
  } else if (levelTypeStr == "CWPITCH") {
2906
- levelType = RIG_LEVEL_CWPITCH;
2892
+ levelType = SHIM_RIG_LEVEL_CWPITCH;
2907
2893
  } else if (levelTypeStr == "KEYSPD") {
2908
- levelType = RIG_LEVEL_KEYSPD;
2894
+ levelType = SHIM_RIG_LEVEL_KEYSPD;
2909
2895
  } else if (levelTypeStr == "NOTCHF") {
2910
- levelType = RIG_LEVEL_NOTCHF;
2896
+ levelType = SHIM_RIG_LEVEL_NOTCHF;
2911
2897
  } else if (levelTypeStr == "COMP") {
2912
- levelType = RIG_LEVEL_COMP;
2898
+ levelType = SHIM_RIG_LEVEL_COMP;
2913
2899
  } else if (levelTypeStr == "AGC") {
2914
- levelType = RIG_LEVEL_AGC;
2900
+ levelType = SHIM_RIG_LEVEL_AGC;
2915
2901
  } else if (levelTypeStr == "BKINDL") {
2916
- levelType = RIG_LEVEL_BKINDL;
2902
+ levelType = SHIM_RIG_LEVEL_BKINDL;
2917
2903
  } else if (levelTypeStr == "BALANCE") {
2918
- levelType = RIG_LEVEL_BALANCE;
2904
+ levelType = SHIM_RIG_LEVEL_BALANCE;
2919
2905
  } else if (levelTypeStr == "VOXGAIN") {
2920
- levelType = RIG_LEVEL_VOXGAIN;
2906
+ levelType = SHIM_RIG_LEVEL_VOXGAIN;
2921
2907
  } else if (levelTypeStr == "VOXDELAY") {
2922
- levelType = RIG_LEVEL_VOXDELAY;
2908
+ levelType = SHIM_RIG_LEVEL_VOXDELAY;
2923
2909
  } else if (levelTypeStr == "ANTIVOX") {
2924
- levelType = RIG_LEVEL_ANTIVOX;
2910
+ levelType = SHIM_RIG_LEVEL_ANTIVOX;
2925
2911
  } else {
2926
2912
  Napi::TypeError::New(env, "Invalid level type").ThrowAsJavaScriptException();
2927
2913
  return env.Null();
2928
2914
  }
2929
2915
 
2930
- // Create value union
2931
- value_t val;
2932
- val.f = levelValue;
2933
-
2916
+ float val = static_cast<float>(levelValue);
2917
+
2934
2918
  SetLevelAsyncWorker* worker = new SetLevelAsyncWorker(env, this, levelType, val);
2935
2919
  worker->Queue();
2936
2920
 
@@ -2953,35 +2937,35 @@ Napi::Value NodeHamLib::GetLevel(const Napi::CallbackInfo & info) {
2953
2937
  std::string levelTypeStr = info[0].As<Napi::String>().Utf8Value();
2954
2938
 
2955
2939
  // Map level type strings to hamlib constants
2956
- setting_t levelType;
2940
+ uint64_t levelType;
2957
2941
  if (levelTypeStr == "AF") {
2958
- levelType = RIG_LEVEL_AF;
2942
+ levelType = SHIM_RIG_LEVEL_AF;
2959
2943
  } else if (levelTypeStr == "RF") {
2960
- levelType = RIG_LEVEL_RF;
2944
+ levelType = SHIM_RIG_LEVEL_RF;
2961
2945
  } else if (levelTypeStr == "SQL") {
2962
- levelType = RIG_LEVEL_SQL;
2946
+ levelType = SHIM_RIG_LEVEL_SQL;
2963
2947
  } else if (levelTypeStr == "RFPOWER") {
2964
- levelType = RIG_LEVEL_RFPOWER;
2948
+ levelType = SHIM_RIG_LEVEL_RFPOWER;
2965
2949
  } else if (levelTypeStr == "MICGAIN") {
2966
- levelType = RIG_LEVEL_MICGAIN;
2950
+ levelType = SHIM_RIG_LEVEL_MICGAIN;
2967
2951
  } else if (levelTypeStr == "SWR") {
2968
- levelType = RIG_LEVEL_SWR;
2952
+ levelType = SHIM_RIG_LEVEL_SWR;
2969
2953
  } else if (levelTypeStr == "ALC") {
2970
- levelType = RIG_LEVEL_ALC;
2954
+ levelType = SHIM_RIG_LEVEL_ALC;
2971
2955
  } else if (levelTypeStr == "STRENGTH") {
2972
- levelType = RIG_LEVEL_STRENGTH;
2956
+ levelType = SHIM_RIG_LEVEL_STRENGTH;
2973
2957
  } else if (levelTypeStr == "RAWSTR") {
2974
- levelType = RIG_LEVEL_RAWSTR;
2958
+ levelType = SHIM_RIG_LEVEL_RAWSTR;
2975
2959
  } else if (levelTypeStr == "RFPOWER_METER") {
2976
- levelType = RIG_LEVEL_RFPOWER_METER;
2960
+ levelType = SHIM_RIG_LEVEL_RFPOWER_METER;
2977
2961
  } else if (levelTypeStr == "COMP_METER") {
2978
- levelType = RIG_LEVEL_COMP_METER;
2962
+ levelType = SHIM_RIG_LEVEL_COMP_METER;
2979
2963
  } else if (levelTypeStr == "VD_METER") {
2980
- levelType = RIG_LEVEL_VD_METER;
2964
+ levelType = SHIM_RIG_LEVEL_VD_METER;
2981
2965
  } else if (levelTypeStr == "ID_METER") {
2982
- levelType = RIG_LEVEL_ID_METER;
2966
+ levelType = SHIM_RIG_LEVEL_ID_METER;
2983
2967
  } else if (levelTypeStr == "TEMP_METER") {
2984
- levelType = RIG_LEVEL_TEMP_METER;
2968
+ levelType = SHIM_RIG_LEVEL_TEMP_METER;
2985
2969
  } else {
2986
2970
  Napi::TypeError::New(env, "Invalid level type").ThrowAsJavaScriptException();
2987
2971
  return env.Null();
@@ -2997,40 +2981,40 @@ Napi::Value NodeHamLib::GetSupportedLevels(const Napi::CallbackInfo & info) {
2997
2981
  Napi::Env env = info.Env();
2998
2982
 
2999
2983
  // Get capabilities from rig caps instead of state (doesn't require rig to be open)
3000
- setting_t levels = my_rig->caps->has_get_level | my_rig->caps->has_set_level;
2984
+ uint64_t levels = shim_rig_get_caps_has_get_level(my_rig) | shim_rig_get_caps_has_set_level(my_rig);
3001
2985
  Napi::Array levelArray = Napi::Array::New(env);
3002
2986
  uint32_t index = 0;
3003
2987
 
3004
2988
  // Check each level type
3005
- if (levels & RIG_LEVEL_AF) levelArray[index++] = Napi::String::New(env, "AF");
3006
- if (levels & RIG_LEVEL_RF) levelArray[index++] = Napi::String::New(env, "RF");
3007
- if (levels & RIG_LEVEL_SQL) levelArray[index++] = Napi::String::New(env, "SQL");
3008
- if (levels & RIG_LEVEL_RFPOWER) levelArray[index++] = Napi::String::New(env, "RFPOWER");
3009
- if (levels & RIG_LEVEL_MICGAIN) levelArray[index++] = Napi::String::New(env, "MICGAIN");
3010
- if (levels & RIG_LEVEL_IF) levelArray[index++] = Napi::String::New(env, "IF");
3011
- if (levels & RIG_LEVEL_APF) levelArray[index++] = Napi::String::New(env, "APF");
3012
- if (levels & RIG_LEVEL_NR) levelArray[index++] = Napi::String::New(env, "NR");
3013
- if (levels & RIG_LEVEL_PBT_IN) levelArray[index++] = Napi::String::New(env, "PBT_IN");
3014
- if (levels & RIG_LEVEL_PBT_OUT) levelArray[index++] = Napi::String::New(env, "PBT_OUT");
3015
- if (levels & RIG_LEVEL_CWPITCH) levelArray[index++] = Napi::String::New(env, "CWPITCH");
3016
- if (levels & RIG_LEVEL_KEYSPD) levelArray[index++] = Napi::String::New(env, "KEYSPD");
3017
- if (levels & RIG_LEVEL_NOTCHF) levelArray[index++] = Napi::String::New(env, "NOTCHF");
3018
- if (levels & RIG_LEVEL_COMP) levelArray[index++] = Napi::String::New(env, "COMP");
3019
- if (levels & RIG_LEVEL_AGC) levelArray[index++] = Napi::String::New(env, "AGC");
3020
- if (levels & RIG_LEVEL_BKINDL) levelArray[index++] = Napi::String::New(env, "BKINDL");
3021
- if (levels & RIG_LEVEL_BALANCE) levelArray[index++] = Napi::String::New(env, "BALANCE");
3022
- if (levels & RIG_LEVEL_VOXGAIN) levelArray[index++] = Napi::String::New(env, "VOXGAIN");
3023
- if (levels & RIG_LEVEL_VOXDELAY) levelArray[index++] = Napi::String::New(env, "VOXDELAY");
3024
- if (levels & RIG_LEVEL_ANTIVOX) levelArray[index++] = Napi::String::New(env, "ANTIVOX");
3025
- if (levels & RIG_LEVEL_STRENGTH) levelArray[index++] = Napi::String::New(env, "STRENGTH");
3026
- if (levels & RIG_LEVEL_RAWSTR) levelArray[index++] = Napi::String::New(env, "RAWSTR");
3027
- if (levels & RIG_LEVEL_SWR) levelArray[index++] = Napi::String::New(env, "SWR");
3028
- if (levels & RIG_LEVEL_ALC) levelArray[index++] = Napi::String::New(env, "ALC");
3029
- if (levels & RIG_LEVEL_RFPOWER_METER) levelArray[index++] = Napi::String::New(env, "RFPOWER_METER");
3030
- if (levels & RIG_LEVEL_COMP_METER) levelArray[index++] = Napi::String::New(env, "COMP_METER");
3031
- if (levels & RIG_LEVEL_VD_METER) levelArray[index++] = Napi::String::New(env, "VD_METER");
3032
- if (levels & RIG_LEVEL_ID_METER) levelArray[index++] = Napi::String::New(env, "ID_METER");
3033
- if (levels & RIG_LEVEL_TEMP_METER) levelArray[index++] = Napi::String::New(env, "TEMP_METER");
2989
+ if (levels & SHIM_RIG_LEVEL_AF) levelArray[index++] = Napi::String::New(env, "AF");
2990
+ if (levels & SHIM_RIG_LEVEL_RF) levelArray[index++] = Napi::String::New(env, "RF");
2991
+ if (levels & SHIM_RIG_LEVEL_SQL) levelArray[index++] = Napi::String::New(env, "SQL");
2992
+ if (levels & SHIM_RIG_LEVEL_RFPOWER) levelArray[index++] = Napi::String::New(env, "RFPOWER");
2993
+ if (levels & SHIM_RIG_LEVEL_MICGAIN) levelArray[index++] = Napi::String::New(env, "MICGAIN");
2994
+ if (levels & SHIM_RIG_LEVEL_IF) levelArray[index++] = Napi::String::New(env, "IF");
2995
+ if (levels & SHIM_RIG_LEVEL_APF) levelArray[index++] = Napi::String::New(env, "APF");
2996
+ if (levels & SHIM_RIG_LEVEL_NR) levelArray[index++] = Napi::String::New(env, "NR");
2997
+ if (levels & SHIM_RIG_LEVEL_PBT_IN) levelArray[index++] = Napi::String::New(env, "PBT_IN");
2998
+ if (levels & SHIM_RIG_LEVEL_PBT_OUT) levelArray[index++] = Napi::String::New(env, "PBT_OUT");
2999
+ if (levels & SHIM_RIG_LEVEL_CWPITCH) levelArray[index++] = Napi::String::New(env, "CWPITCH");
3000
+ if (levels & SHIM_RIG_LEVEL_KEYSPD) levelArray[index++] = Napi::String::New(env, "KEYSPD");
3001
+ if (levels & SHIM_RIG_LEVEL_NOTCHF) levelArray[index++] = Napi::String::New(env, "NOTCHF");
3002
+ if (levels & SHIM_RIG_LEVEL_COMP) levelArray[index++] = Napi::String::New(env, "COMP");
3003
+ if (levels & SHIM_RIG_LEVEL_AGC) levelArray[index++] = Napi::String::New(env, "AGC");
3004
+ if (levels & SHIM_RIG_LEVEL_BKINDL) levelArray[index++] = Napi::String::New(env, "BKINDL");
3005
+ if (levels & SHIM_RIG_LEVEL_BALANCE) levelArray[index++] = Napi::String::New(env, "BALANCE");
3006
+ if (levels & SHIM_RIG_LEVEL_VOXGAIN) levelArray[index++] = Napi::String::New(env, "VOXGAIN");
3007
+ if (levels & SHIM_RIG_LEVEL_VOXDELAY) levelArray[index++] = Napi::String::New(env, "VOXDELAY");
3008
+ if (levels & SHIM_RIG_LEVEL_ANTIVOX) levelArray[index++] = Napi::String::New(env, "ANTIVOX");
3009
+ if (levels & SHIM_RIG_LEVEL_STRENGTH) levelArray[index++] = Napi::String::New(env, "STRENGTH");
3010
+ if (levels & SHIM_RIG_LEVEL_RAWSTR) levelArray[index++] = Napi::String::New(env, "RAWSTR");
3011
+ if (levels & SHIM_RIG_LEVEL_SWR) levelArray[index++] = Napi::String::New(env, "SWR");
3012
+ if (levels & SHIM_RIG_LEVEL_ALC) levelArray[index++] = Napi::String::New(env, "ALC");
3013
+ if (levels & SHIM_RIG_LEVEL_RFPOWER_METER) levelArray[index++] = Napi::String::New(env, "RFPOWER_METER");
3014
+ if (levels & SHIM_RIG_LEVEL_COMP_METER) levelArray[index++] = Napi::String::New(env, "COMP_METER");
3015
+ if (levels & SHIM_RIG_LEVEL_VD_METER) levelArray[index++] = Napi::String::New(env, "VD_METER");
3016
+ if (levels & SHIM_RIG_LEVEL_ID_METER) levelArray[index++] = Napi::String::New(env, "ID_METER");
3017
+ if (levels & SHIM_RIG_LEVEL_TEMP_METER) levelArray[index++] = Napi::String::New(env, "TEMP_METER");
3034
3018
 
3035
3019
  return levelArray;
3036
3020
  }
@@ -3053,63 +3037,63 @@ Napi::Value NodeHamLib::SetFunction(const Napi::CallbackInfo & info) {
3053
3037
  bool enable = info[1].As<Napi::Boolean>().Value();
3054
3038
 
3055
3039
  // Map function type strings to hamlib constants
3056
- setting_t funcType;
3040
+ uint64_t funcType;
3057
3041
  if (funcTypeStr == "FAGC") {
3058
- funcType = RIG_FUNC_FAGC;
3042
+ funcType = SHIM_RIG_FUNC_FAGC;
3059
3043
  } else if (funcTypeStr == "NB") {
3060
- funcType = RIG_FUNC_NB;
3044
+ funcType = SHIM_RIG_FUNC_NB;
3061
3045
  } else if (funcTypeStr == "COMP") {
3062
- funcType = RIG_FUNC_COMP;
3046
+ funcType = SHIM_RIG_FUNC_COMP;
3063
3047
  } else if (funcTypeStr == "VOX") {
3064
- funcType = RIG_FUNC_VOX;
3048
+ funcType = SHIM_RIG_FUNC_VOX;
3065
3049
  } else if (funcTypeStr == "TONE") {
3066
- funcType = RIG_FUNC_TONE;
3050
+ funcType = SHIM_RIG_FUNC_TONE;
3067
3051
  } else if (funcTypeStr == "TSQL") {
3068
- funcType = RIG_FUNC_TSQL;
3052
+ funcType = SHIM_RIG_FUNC_TSQL;
3069
3053
  } else if (funcTypeStr == "SBKIN") {
3070
- funcType = RIG_FUNC_SBKIN;
3054
+ funcType = SHIM_RIG_FUNC_SBKIN;
3071
3055
  } else if (funcTypeStr == "FBKIN") {
3072
- funcType = RIG_FUNC_FBKIN;
3056
+ funcType = SHIM_RIG_FUNC_FBKIN;
3073
3057
  } else if (funcTypeStr == "ANF") {
3074
- funcType = RIG_FUNC_ANF;
3058
+ funcType = SHIM_RIG_FUNC_ANF;
3075
3059
  } else if (funcTypeStr == "NR") {
3076
- funcType = RIG_FUNC_NR;
3060
+ funcType = SHIM_RIG_FUNC_NR;
3077
3061
  } else if (funcTypeStr == "AIP") {
3078
- funcType = RIG_FUNC_AIP;
3062
+ funcType = SHIM_RIG_FUNC_AIP;
3079
3063
  } else if (funcTypeStr == "APF") {
3080
- funcType = RIG_FUNC_APF;
3064
+ funcType = SHIM_RIG_FUNC_APF;
3081
3065
  } else if (funcTypeStr == "TUNER") {
3082
- funcType = RIG_FUNC_TUNER;
3066
+ funcType = SHIM_RIG_FUNC_TUNER;
3083
3067
  } else if (funcTypeStr == "XIT") {
3084
- funcType = RIG_FUNC_XIT;
3068
+ funcType = SHIM_RIG_FUNC_XIT;
3085
3069
  } else if (funcTypeStr == "RIT") {
3086
- funcType = RIG_FUNC_RIT;
3070
+ funcType = SHIM_RIG_FUNC_RIT;
3087
3071
  } else if (funcTypeStr == "LOCK") {
3088
- funcType = RIG_FUNC_LOCK;
3072
+ funcType = SHIM_RIG_FUNC_LOCK;
3089
3073
  } else if (funcTypeStr == "MUTE") {
3090
- funcType = RIG_FUNC_MUTE;
3074
+ funcType = SHIM_RIG_FUNC_MUTE;
3091
3075
  } else if (funcTypeStr == "VSC") {
3092
- funcType = RIG_FUNC_VSC;
3076
+ funcType = SHIM_RIG_FUNC_VSC;
3093
3077
  } else if (funcTypeStr == "REV") {
3094
- funcType = RIG_FUNC_REV;
3078
+ funcType = SHIM_RIG_FUNC_REV;
3095
3079
  } else if (funcTypeStr == "SQL") {
3096
- funcType = RIG_FUNC_SQL;
3080
+ funcType = SHIM_RIG_FUNC_SQL;
3097
3081
  } else if (funcTypeStr == "ABM") {
3098
- funcType = RIG_FUNC_ABM;
3082
+ funcType = SHIM_RIG_FUNC_ABM;
3099
3083
  } else if (funcTypeStr == "BC") {
3100
- funcType = RIG_FUNC_BC;
3084
+ funcType = SHIM_RIG_FUNC_BC;
3101
3085
  } else if (funcTypeStr == "MBC") {
3102
- funcType = RIG_FUNC_MBC;
3086
+ funcType = SHIM_RIG_FUNC_MBC;
3103
3087
  } else if (funcTypeStr == "AFC") {
3104
- funcType = RIG_FUNC_AFC;
3088
+ funcType = SHIM_RIG_FUNC_AFC;
3105
3089
  } else if (funcTypeStr == "SATMODE") {
3106
- funcType = RIG_FUNC_SATMODE;
3090
+ funcType = SHIM_RIG_FUNC_SATMODE;
3107
3091
  } else if (funcTypeStr == "SCOPE") {
3108
- funcType = RIG_FUNC_SCOPE;
3092
+ funcType = SHIM_RIG_FUNC_SCOPE;
3109
3093
  } else if (funcTypeStr == "RESUME") {
3110
- funcType = RIG_FUNC_RESUME;
3094
+ funcType = SHIM_RIG_FUNC_RESUME;
3111
3095
  } else if (funcTypeStr == "TBURST") {
3112
- funcType = RIG_FUNC_TBURST;
3096
+ funcType = SHIM_RIG_FUNC_TBURST;
3113
3097
  } else {
3114
3098
  Napi::TypeError::New(env, "Invalid function type").ThrowAsJavaScriptException();
3115
3099
  return env.Null();
@@ -3137,63 +3121,63 @@ Napi::Value NodeHamLib::GetFunction(const Napi::CallbackInfo & info) {
3137
3121
  std::string funcTypeStr = info[0].As<Napi::String>().Utf8Value();
3138
3122
 
3139
3123
  // Map function type strings to hamlib constants (same as SetFunction)
3140
- setting_t funcType;
3124
+ uint64_t funcType;
3141
3125
  if (funcTypeStr == "FAGC") {
3142
- funcType = RIG_FUNC_FAGC;
3126
+ funcType = SHIM_RIG_FUNC_FAGC;
3143
3127
  } else if (funcTypeStr == "NB") {
3144
- funcType = RIG_FUNC_NB;
3128
+ funcType = SHIM_RIG_FUNC_NB;
3145
3129
  } else if (funcTypeStr == "COMP") {
3146
- funcType = RIG_FUNC_COMP;
3130
+ funcType = SHIM_RIG_FUNC_COMP;
3147
3131
  } else if (funcTypeStr == "VOX") {
3148
- funcType = RIG_FUNC_VOX;
3132
+ funcType = SHIM_RIG_FUNC_VOX;
3149
3133
  } else if (funcTypeStr == "TONE") {
3150
- funcType = RIG_FUNC_TONE;
3134
+ funcType = SHIM_RIG_FUNC_TONE;
3151
3135
  } else if (funcTypeStr == "TSQL") {
3152
- funcType = RIG_FUNC_TSQL;
3136
+ funcType = SHIM_RIG_FUNC_TSQL;
3153
3137
  } else if (funcTypeStr == "SBKIN") {
3154
- funcType = RIG_FUNC_SBKIN;
3138
+ funcType = SHIM_RIG_FUNC_SBKIN;
3155
3139
  } else if (funcTypeStr == "FBKIN") {
3156
- funcType = RIG_FUNC_FBKIN;
3140
+ funcType = SHIM_RIG_FUNC_FBKIN;
3157
3141
  } else if (funcTypeStr == "ANF") {
3158
- funcType = RIG_FUNC_ANF;
3142
+ funcType = SHIM_RIG_FUNC_ANF;
3159
3143
  } else if (funcTypeStr == "NR") {
3160
- funcType = RIG_FUNC_NR;
3144
+ funcType = SHIM_RIG_FUNC_NR;
3161
3145
  } else if (funcTypeStr == "AIP") {
3162
- funcType = RIG_FUNC_AIP;
3146
+ funcType = SHIM_RIG_FUNC_AIP;
3163
3147
  } else if (funcTypeStr == "APF") {
3164
- funcType = RIG_FUNC_APF;
3148
+ funcType = SHIM_RIG_FUNC_APF;
3165
3149
  } else if (funcTypeStr == "TUNER") {
3166
- funcType = RIG_FUNC_TUNER;
3150
+ funcType = SHIM_RIG_FUNC_TUNER;
3167
3151
  } else if (funcTypeStr == "XIT") {
3168
- funcType = RIG_FUNC_XIT;
3152
+ funcType = SHIM_RIG_FUNC_XIT;
3169
3153
  } else if (funcTypeStr == "RIT") {
3170
- funcType = RIG_FUNC_RIT;
3154
+ funcType = SHIM_RIG_FUNC_RIT;
3171
3155
  } else if (funcTypeStr == "LOCK") {
3172
- funcType = RIG_FUNC_LOCK;
3156
+ funcType = SHIM_RIG_FUNC_LOCK;
3173
3157
  } else if (funcTypeStr == "MUTE") {
3174
- funcType = RIG_FUNC_MUTE;
3158
+ funcType = SHIM_RIG_FUNC_MUTE;
3175
3159
  } else if (funcTypeStr == "VSC") {
3176
- funcType = RIG_FUNC_VSC;
3160
+ funcType = SHIM_RIG_FUNC_VSC;
3177
3161
  } else if (funcTypeStr == "REV") {
3178
- funcType = RIG_FUNC_REV;
3162
+ funcType = SHIM_RIG_FUNC_REV;
3179
3163
  } else if (funcTypeStr == "SQL") {
3180
- funcType = RIG_FUNC_SQL;
3164
+ funcType = SHIM_RIG_FUNC_SQL;
3181
3165
  } else if (funcTypeStr == "ABM") {
3182
- funcType = RIG_FUNC_ABM;
3166
+ funcType = SHIM_RIG_FUNC_ABM;
3183
3167
  } else if (funcTypeStr == "BC") {
3184
- funcType = RIG_FUNC_BC;
3168
+ funcType = SHIM_RIG_FUNC_BC;
3185
3169
  } else if (funcTypeStr == "MBC") {
3186
- funcType = RIG_FUNC_MBC;
3170
+ funcType = SHIM_RIG_FUNC_MBC;
3187
3171
  } else if (funcTypeStr == "AFC") {
3188
- funcType = RIG_FUNC_AFC;
3172
+ funcType = SHIM_RIG_FUNC_AFC;
3189
3173
  } else if (funcTypeStr == "SATMODE") {
3190
- funcType = RIG_FUNC_SATMODE;
3174
+ funcType = SHIM_RIG_FUNC_SATMODE;
3191
3175
  } else if (funcTypeStr == "SCOPE") {
3192
- funcType = RIG_FUNC_SCOPE;
3176
+ funcType = SHIM_RIG_FUNC_SCOPE;
3193
3177
  } else if (funcTypeStr == "RESUME") {
3194
- funcType = RIG_FUNC_RESUME;
3178
+ funcType = SHIM_RIG_FUNC_RESUME;
3195
3179
  } else if (funcTypeStr == "TBURST") {
3196
- funcType = RIG_FUNC_TBURST;
3180
+ funcType = SHIM_RIG_FUNC_TBURST;
3197
3181
  } else {
3198
3182
  Napi::TypeError::New(env, "Invalid function type").ThrowAsJavaScriptException();
3199
3183
  return env.Null();
@@ -3209,39 +3193,39 @@ Napi::Value NodeHamLib::GetSupportedFunctions(const Napi::CallbackInfo & info) {
3209
3193
  Napi::Env env = info.Env();
3210
3194
 
3211
3195
  // Get capabilities from rig caps instead of state (doesn't require rig to be open)
3212
- setting_t functions = my_rig->caps->has_get_func | my_rig->caps->has_set_func;
3196
+ uint64_t functions = shim_rig_get_caps_has_get_func(my_rig) | shim_rig_get_caps_has_set_func(my_rig);
3213
3197
  Napi::Array funcArray = Napi::Array::New(env);
3214
3198
  uint32_t index = 0;
3215
3199
 
3216
3200
  // Check each function type
3217
- if (functions & RIG_FUNC_FAGC) funcArray[index++] = Napi::String::New(env, "FAGC");
3218
- if (functions & RIG_FUNC_NB) funcArray[index++] = Napi::String::New(env, "NB");
3219
- if (functions & RIG_FUNC_COMP) funcArray[index++] = Napi::String::New(env, "COMP");
3220
- if (functions & RIG_FUNC_VOX) funcArray[index++] = Napi::String::New(env, "VOX");
3221
- if (functions & RIG_FUNC_TONE) funcArray[index++] = Napi::String::New(env, "TONE");
3222
- if (functions & RIG_FUNC_TSQL) funcArray[index++] = Napi::String::New(env, "TSQL");
3223
- if (functions & RIG_FUNC_SBKIN) funcArray[index++] = Napi::String::New(env, "SBKIN");
3224
- if (functions & RIG_FUNC_FBKIN) funcArray[index++] = Napi::String::New(env, "FBKIN");
3225
- if (functions & RIG_FUNC_ANF) funcArray[index++] = Napi::String::New(env, "ANF");
3226
- if (functions & RIG_FUNC_NR) funcArray[index++] = Napi::String::New(env, "NR");
3227
- if (functions & RIG_FUNC_AIP) funcArray[index++] = Napi::String::New(env, "AIP");
3228
- if (functions & RIG_FUNC_APF) funcArray[index++] = Napi::String::New(env, "APF");
3229
- if (functions & RIG_FUNC_TUNER) funcArray[index++] = Napi::String::New(env, "TUNER");
3230
- if (functions & RIG_FUNC_XIT) funcArray[index++] = Napi::String::New(env, "XIT");
3231
- if (functions & RIG_FUNC_RIT) funcArray[index++] = Napi::String::New(env, "RIT");
3232
- if (functions & RIG_FUNC_LOCK) funcArray[index++] = Napi::String::New(env, "LOCK");
3233
- if (functions & RIG_FUNC_MUTE) funcArray[index++] = Napi::String::New(env, "MUTE");
3234
- if (functions & RIG_FUNC_VSC) funcArray[index++] = Napi::String::New(env, "VSC");
3235
- if (functions & RIG_FUNC_REV) funcArray[index++] = Napi::String::New(env, "REV");
3236
- if (functions & RIG_FUNC_SQL) funcArray[index++] = Napi::String::New(env, "SQL");
3237
- if (functions & RIG_FUNC_ABM) funcArray[index++] = Napi::String::New(env, "ABM");
3238
- if (functions & RIG_FUNC_BC) funcArray[index++] = Napi::String::New(env, "BC");
3239
- if (functions & RIG_FUNC_MBC) funcArray[index++] = Napi::String::New(env, "MBC");
3240
- if (functions & RIG_FUNC_AFC) funcArray[index++] = Napi::String::New(env, "AFC");
3241
- if (functions & RIG_FUNC_SATMODE) funcArray[index++] = Napi::String::New(env, "SATMODE");
3242
- if (functions & RIG_FUNC_SCOPE) funcArray[index++] = Napi::String::New(env, "SCOPE");
3243
- if (functions & RIG_FUNC_RESUME) funcArray[index++] = Napi::String::New(env, "RESUME");
3244
- if (functions & RIG_FUNC_TBURST) funcArray[index++] = Napi::String::New(env, "TBURST");
3201
+ if (functions & SHIM_RIG_FUNC_FAGC) funcArray[index++] = Napi::String::New(env, "FAGC");
3202
+ if (functions & SHIM_RIG_FUNC_NB) funcArray[index++] = Napi::String::New(env, "NB");
3203
+ if (functions & SHIM_RIG_FUNC_COMP) funcArray[index++] = Napi::String::New(env, "COMP");
3204
+ if (functions & SHIM_RIG_FUNC_VOX) funcArray[index++] = Napi::String::New(env, "VOX");
3205
+ if (functions & SHIM_RIG_FUNC_TONE) funcArray[index++] = Napi::String::New(env, "TONE");
3206
+ if (functions & SHIM_RIG_FUNC_TSQL) funcArray[index++] = Napi::String::New(env, "TSQL");
3207
+ if (functions & SHIM_RIG_FUNC_SBKIN) funcArray[index++] = Napi::String::New(env, "SBKIN");
3208
+ if (functions & SHIM_RIG_FUNC_FBKIN) funcArray[index++] = Napi::String::New(env, "FBKIN");
3209
+ if (functions & SHIM_RIG_FUNC_ANF) funcArray[index++] = Napi::String::New(env, "ANF");
3210
+ if (functions & SHIM_RIG_FUNC_NR) funcArray[index++] = Napi::String::New(env, "NR");
3211
+ if (functions & SHIM_RIG_FUNC_AIP) funcArray[index++] = Napi::String::New(env, "AIP");
3212
+ if (functions & SHIM_RIG_FUNC_APF) funcArray[index++] = Napi::String::New(env, "APF");
3213
+ if (functions & SHIM_RIG_FUNC_TUNER) funcArray[index++] = Napi::String::New(env, "TUNER");
3214
+ if (functions & SHIM_RIG_FUNC_XIT) funcArray[index++] = Napi::String::New(env, "XIT");
3215
+ if (functions & SHIM_RIG_FUNC_RIT) funcArray[index++] = Napi::String::New(env, "RIT");
3216
+ if (functions & SHIM_RIG_FUNC_LOCK) funcArray[index++] = Napi::String::New(env, "LOCK");
3217
+ if (functions & SHIM_RIG_FUNC_MUTE) funcArray[index++] = Napi::String::New(env, "MUTE");
3218
+ if (functions & SHIM_RIG_FUNC_VSC) funcArray[index++] = Napi::String::New(env, "VSC");
3219
+ if (functions & SHIM_RIG_FUNC_REV) funcArray[index++] = Napi::String::New(env, "REV");
3220
+ if (functions & SHIM_RIG_FUNC_SQL) funcArray[index++] = Napi::String::New(env, "SQL");
3221
+ if (functions & SHIM_RIG_FUNC_ABM) funcArray[index++] = Napi::String::New(env, "ABM");
3222
+ if (functions & SHIM_RIG_FUNC_BC) funcArray[index++] = Napi::String::New(env, "BC");
3223
+ if (functions & SHIM_RIG_FUNC_MBC) funcArray[index++] = Napi::String::New(env, "MBC");
3224
+ if (functions & SHIM_RIG_FUNC_AFC) funcArray[index++] = Napi::String::New(env, "AFC");
3225
+ if (functions & SHIM_RIG_FUNC_SATMODE) funcArray[index++] = Napi::String::New(env, "SATMODE");
3226
+ if (functions & SHIM_RIG_FUNC_SCOPE) funcArray[index++] = Napi::String::New(env, "SCOPE");
3227
+ if (functions & SHIM_RIG_FUNC_RESUME) funcArray[index++] = Napi::String::New(env, "RESUME");
3228
+ if (functions & SHIM_RIG_FUNC_TBURST) funcArray[index++] = Napi::String::New(env, "TBURST");
3245
3229
 
3246
3230
  return funcArray;
3247
3231
  }
@@ -3251,16 +3235,16 @@ Napi::Value NodeHamLib::GetSupportedModes(const Napi::CallbackInfo & info) {
3251
3235
  Napi::Env env = info.Env();
3252
3236
 
3253
3237
  // Get mode list from rig state (populated during rig_open from rx/tx range lists)
3254
- rmode_t modes = my_rig->state.mode_list;
3238
+ uint64_t modes = shim_rig_get_mode_list(my_rig);
3255
3239
  Napi::Array modeArray = Napi::Array::New(env);
3256
3240
  uint32_t index = 0;
3257
3241
 
3258
3242
  // Iterate through all possible mode bits (similar to rig_sprintf_mode)
3259
- for (unsigned int i = 0; i < HAMLIB_MAX_MODES; i++) {
3260
- rmode_t mode_bit = modes & (1ULL << i);
3243
+ for (unsigned int i = 0; i < SHIM_HAMLIB_MAX_MODES; i++) {
3244
+ uint64_t mode_bit = modes & (1ULL << i);
3261
3245
 
3262
3246
  if (mode_bit) {
3263
- const char* mode_str = rig_strrmode(mode_bit);
3247
+ const char* mode_str = shim_rig_strrmode(mode_bit);
3264
3248
 
3265
3249
  // Skip empty or unknown modes
3266
3250
  if (mode_str && mode_str[0] != '\0') {
@@ -3286,7 +3270,7 @@ Napi::Value NodeHamLib::SetSplitFreq(const Napi::CallbackInfo & info) {
3286
3270
  return env.Null();
3287
3271
  }
3288
3272
 
3289
- freq_t tx_freq = info[0].As<Napi::Number>().DoubleValue();
3273
+ double tx_freq = info[0].As<Napi::Number>().DoubleValue();
3290
3274
 
3291
3275
  // Basic frequency range validation
3292
3276
  if (tx_freq < 1000 || tx_freq > 10000000000) { // 1 kHz to 10 GHz reasonable range
@@ -3294,11 +3278,11 @@ Napi::Value NodeHamLib::SetSplitFreq(const Napi::CallbackInfo & info) {
3294
3278
  return env.Null();
3295
3279
  }
3296
3280
 
3297
- vfo_t vfo = RIG_VFO_CURR;
3281
+ int vfo = SHIM_RIG_VFO_CURR;
3298
3282
 
3299
3283
  if (info.Length() >= 2 && info[1].IsString()) {
3300
3284
  // setSplitFreq(freq, vfo)
3301
- vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
3285
+ vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
3302
3286
  }
3303
3287
 
3304
3288
  SetSplitFreqAsyncWorker* asyncWorker = new SetSplitFreqAsyncWorker(env, this, tx_freq, vfo);
@@ -3314,13 +3298,13 @@ Napi::Value NodeHamLib::GetSplitFreq(const Napi::CallbackInfo & info) {
3314
3298
  return env.Null();
3315
3299
  }
3316
3300
 
3317
- vfo_t vfo = RIG_VFO_CURR;
3301
+ int vfo = SHIM_RIG_VFO_CURR;
3318
3302
 
3319
3303
  if (info.Length() >= 1 && info[0].IsString()) {
3320
3304
  // getSplitFreq(vfo)
3321
- vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
3305
+ vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
3322
3306
  }
3323
- // Otherwise use default RIG_VFO_CURR for getSplitFreq()
3307
+ // Otherwise use default SHIM_RIG_VFO_CURR for getSplitFreq()
3324
3308
 
3325
3309
  GetSplitFreqAsyncWorker* asyncWorker = new GetSplitFreqAsyncWorker(env, this, vfo);
3326
3310
  asyncWorker->Queue();
@@ -3341,21 +3325,21 @@ Napi::Value NodeHamLib::SetSplitMode(const Napi::CallbackInfo & info) {
3341
3325
  }
3342
3326
 
3343
3327
  std::string modeStr = info[0].As<Napi::String>().Utf8Value();
3344
- rmode_t tx_mode = rig_parse_mode(modeStr.c_str());
3328
+ int tx_mode = shim_rig_parse_mode(modeStr.c_str());
3345
3329
 
3346
- if (tx_mode == RIG_MODE_NONE) {
3330
+ if (tx_mode == SHIM_RIG_MODE_NONE) {
3347
3331
  Napi::Error::New(env, "Invalid mode: " + modeStr).ThrowAsJavaScriptException();
3348
3332
  return env.Null();
3349
3333
  }
3350
3334
 
3351
- pbwidth_t tx_width = RIG_PASSBAND_NORMAL;
3352
- vfo_t vfo = RIG_VFO_CURR;
3335
+ int tx_width = SHIM_RIG_PASSBAND_NORMAL;
3336
+ int vfo = SHIM_RIG_VFO_CURR;
3353
3337
 
3354
3338
  // Parse parameters: setSplitMode(mode) | setSplitMode(mode, vfo) | setSplitMode(mode, width) | setSplitMode(mode, width, vfo)
3355
3339
  if (info.Length() == 2) {
3356
3340
  if (info[1].IsString()) {
3357
3341
  // setSplitMode(mode, vfo)
3358
- vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
3342
+ vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
3359
3343
  } else if (info[1].IsNumber()) {
3360
3344
  // setSplitMode(mode, width)
3361
3345
  tx_width = info[1].As<Napi::Number>().Int32Value();
@@ -3363,7 +3347,7 @@ Napi::Value NodeHamLib::SetSplitMode(const Napi::CallbackInfo & info) {
3363
3347
  } else if (info.Length() == 3 && info[1].IsNumber() && info[2].IsString()) {
3364
3348
  // setSplitMode(mode, width, vfo)
3365
3349
  tx_width = info[1].As<Napi::Number>().Int32Value();
3366
- vfo = parseVfoParameter(info, 2, RIG_VFO_CURR);
3350
+ vfo = parseVfoParameter(info, 2, SHIM_RIG_VFO_CURR);
3367
3351
  }
3368
3352
 
3369
3353
  SetSplitModeAsyncWorker* asyncWorker = new SetSplitModeAsyncWorker(env, this, tx_mode, tx_width, vfo);
@@ -3379,13 +3363,13 @@ Napi::Value NodeHamLib::GetSplitMode(const Napi::CallbackInfo & info) {
3379
3363
  return env.Null();
3380
3364
  }
3381
3365
 
3382
- vfo_t vfo = RIG_VFO_CURR;
3366
+ int vfo = SHIM_RIG_VFO_CURR;
3383
3367
 
3384
3368
  if (info.Length() >= 1 && info[0].IsString()) {
3385
3369
  // getSplitMode(vfo)
3386
- vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
3370
+ vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
3387
3371
  }
3388
- // Otherwise use default RIG_VFO_CURR for getSplitMode()
3372
+ // Otherwise use default SHIM_RIG_VFO_CURR for getSplitMode()
3389
3373
 
3390
3374
  GetSplitModeAsyncWorker* asyncWorker = new GetSplitModeAsyncWorker(env, this, vfo);
3391
3375
  asyncWorker->Queue();
@@ -3406,11 +3390,11 @@ Napi::Value NodeHamLib::SetSplit(const Napi::CallbackInfo & info) {
3406
3390
  }
3407
3391
 
3408
3392
  bool split_enabled = info[0].As<Napi::Boolean>().Value();
3409
- split_t split = split_enabled ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
3393
+ int split = split_enabled ? SHIM_RIG_SPLIT_ON : SHIM_RIG_SPLIT_OFF;
3410
3394
 
3411
3395
  // Default values
3412
- vfo_t rx_vfo = RIG_VFO_CURR;
3413
- vfo_t tx_vfo = RIG_VFO_B; // Default TX VFO
3396
+ int rx_vfo = SHIM_RIG_VFO_CURR;
3397
+ int tx_vfo = SHIM_RIG_VFO_B; // Default TX VFO
3414
3398
 
3415
3399
  // ⚠️ CRITICAL HISTORICAL ISSUE WARNING ⚠️
3416
3400
  // This Split API had a severe parameter order bug that caused AI to repeatedly
@@ -3431,9 +3415,9 @@ Napi::Value NodeHamLib::SetSplit(const Napi::CallbackInfo & info) {
3431
3415
  // setSplit(enable, rxVfo) - treating vfo as RX VFO for current VFO operation
3432
3416
  std::string vfoStr = info[1].As<Napi::String>().Utf8Value();
3433
3417
  if (vfoStr == "VFO-A") {
3434
- rx_vfo = RIG_VFO_A;
3418
+ rx_vfo = SHIM_RIG_VFO_A;
3435
3419
  } else if (vfoStr == "VFO-B") {
3436
- rx_vfo = RIG_VFO_B;
3420
+ rx_vfo = SHIM_RIG_VFO_B;
3437
3421
  }
3438
3422
  } else if (info.Length() == 3 && info[1].IsString() && info[2].IsString()) {
3439
3423
  // setSplit(enable, rxVfo, txVfo)
@@ -3444,15 +3428,15 @@ Napi::Value NodeHamLib::SetSplit(const Napi::CallbackInfo & info) {
3444
3428
  std::string txVfoStr = info[2].As<Napi::String>().Utf8Value(); // ✅ CORRECT: info[2] is txVfo
3445
3429
 
3446
3430
  if (rxVfoStr == "VFO-A") {
3447
- rx_vfo = RIG_VFO_A;
3431
+ rx_vfo = SHIM_RIG_VFO_A;
3448
3432
  } else if (rxVfoStr == "VFO-B") {
3449
- rx_vfo = RIG_VFO_B;
3433
+ rx_vfo = SHIM_RIG_VFO_B;
3450
3434
  }
3451
3435
 
3452
3436
  if (txVfoStr == "VFO-A") {
3453
- tx_vfo = RIG_VFO_A;
3437
+ tx_vfo = SHIM_RIG_VFO_A;
3454
3438
  } else if (txVfoStr == "VFO-B") {
3455
- tx_vfo = RIG_VFO_B;
3439
+ tx_vfo = SHIM_RIG_VFO_B;
3456
3440
  }
3457
3441
  }
3458
3442
 
@@ -3469,13 +3453,13 @@ Napi::Value NodeHamLib::GetSplit(const Napi::CallbackInfo & info) {
3469
3453
  return env.Null();
3470
3454
  }
3471
3455
 
3472
- vfo_t vfo = RIG_VFO_CURR;
3456
+ int vfo = SHIM_RIG_VFO_CURR;
3473
3457
 
3474
3458
  if (info.Length() >= 1 && info[0].IsString()) {
3475
3459
  // getSplit(vfo)
3476
- vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
3460
+ vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
3477
3461
  }
3478
- // Otherwise use default RIG_VFO_CURR for getSplit()
3462
+ // Otherwise use default SHIM_RIG_VFO_CURR for getSplit()
3479
3463
 
3480
3464
  GetSplitAsyncWorker* asyncWorker = new GetSplitAsyncWorker(env, this, vfo);
3481
3465
  asyncWorker->Queue();
@@ -3498,33 +3482,33 @@ Napi::Value NodeHamLib::VfoOperation(const Napi::CallbackInfo & info) {
3498
3482
 
3499
3483
  std::string vfoOpStr = info[0].As<Napi::String>().Utf8Value();
3500
3484
 
3501
- vfo_op_t vfo_op;
3485
+ int vfo_op;
3502
3486
  if (vfoOpStr == "CPY") {
3503
- vfo_op = RIG_OP_CPY;
3487
+ vfo_op = SHIM_RIG_OP_CPY;
3504
3488
  } else if (vfoOpStr == "XCHG") {
3505
- vfo_op = RIG_OP_XCHG;
3489
+ vfo_op = SHIM_RIG_OP_XCHG;
3506
3490
  } else if (vfoOpStr == "FROM_VFO") {
3507
- vfo_op = RIG_OP_FROM_VFO;
3491
+ vfo_op = SHIM_RIG_OP_FROM_VFO;
3508
3492
  } else if (vfoOpStr == "TO_VFO") {
3509
- vfo_op = RIG_OP_TO_VFO;
3493
+ vfo_op = SHIM_RIG_OP_TO_VFO;
3510
3494
  } else if (vfoOpStr == "MCL") {
3511
- vfo_op = RIG_OP_MCL;
3495
+ vfo_op = SHIM_RIG_OP_MCL;
3512
3496
  } else if (vfoOpStr == "UP") {
3513
- vfo_op = RIG_OP_UP;
3497
+ vfo_op = SHIM_RIG_OP_UP;
3514
3498
  } else if (vfoOpStr == "DOWN") {
3515
- vfo_op = RIG_OP_DOWN;
3499
+ vfo_op = SHIM_RIG_OP_DOWN;
3516
3500
  } else if (vfoOpStr == "BAND_UP") {
3517
- vfo_op = RIG_OP_BAND_UP;
3501
+ vfo_op = SHIM_RIG_OP_BAND_UP;
3518
3502
  } else if (vfoOpStr == "BAND_DOWN") {
3519
- vfo_op = RIG_OP_BAND_DOWN;
3503
+ vfo_op = SHIM_RIG_OP_BAND_DOWN;
3520
3504
  } else if (vfoOpStr == "LEFT") {
3521
- vfo_op = RIG_OP_LEFT;
3505
+ vfo_op = SHIM_RIG_OP_LEFT;
3522
3506
  } else if (vfoOpStr == "RIGHT") {
3523
- vfo_op = RIG_OP_RIGHT;
3507
+ vfo_op = SHIM_RIG_OP_RIGHT;
3524
3508
  } else if (vfoOpStr == "TUNE") {
3525
- vfo_op = RIG_OP_TUNE;
3509
+ vfo_op = SHIM_RIG_OP_TUNE;
3526
3510
  } else if (vfoOpStr == "TOGGLE") {
3527
- vfo_op = RIG_OP_TOGGLE;
3511
+ vfo_op = SHIM_RIG_OP_TOGGLE;
3528
3512
  } else {
3529
3513
  Napi::TypeError::New(env, "Invalid VFO operation").ThrowAsJavaScriptException();
3530
3514
  return env.Null();
@@ -3549,17 +3533,17 @@ Napi::Value NodeHamLib::SetAntenna(const Napi::CallbackInfo & info) {
3549
3533
  return env.Null();
3550
3534
  }
3551
3535
 
3552
- ant_t antenna = info[0].As<Napi::Number>().Int32Value();
3536
+ int antenna = info[0].As<Napi::Number>().Int32Value();
3553
3537
 
3554
3538
  // Support optional VFO parameter: setAntenna(antenna) or setAntenna(antenna, vfo)
3555
- vfo_t vfo = RIG_VFO_CURR;
3539
+ int vfo = SHIM_RIG_VFO_CURR;
3556
3540
  if (info.Length() >= 2 && info[1].IsString()) {
3557
- vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
3541
+ vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
3558
3542
  }
3559
3543
 
3560
3544
  // Default option value (can be extended later if needed)
3561
- value_t option = {0};
3562
-
3545
+ float option = 0.0f;
3546
+
3563
3547
  SetAntennaAsyncWorker* asyncWorker = new SetAntennaAsyncWorker(env, this, antenna, vfo, option);
3564
3548
  asyncWorker->Queue();
3565
3549
  return asyncWorker->GetPromise();
@@ -3574,13 +3558,13 @@ Napi::Value NodeHamLib::GetAntenna(const Napi::CallbackInfo & info) {
3574
3558
  }
3575
3559
 
3576
3560
  // Support optional VFO parameter: getAntenna() or getAntenna(vfo)
3577
- vfo_t vfo = RIG_VFO_CURR;
3561
+ int vfo = SHIM_RIG_VFO_CURR;
3578
3562
  if (info.Length() >= 1 && info[0].IsString()) {
3579
- vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
3563
+ vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
3580
3564
  }
3581
3565
 
3582
- // Default antenna query (RIG_ANT_CURR gets all antenna info)
3583
- ant_t antenna = RIG_ANT_CURR;
3566
+ // Default antenna query (SHIM_RIG_ANT_CURR gets all antenna info)
3567
+ int antenna = SHIM_RIG_ANT_CURR;
3584
3568
 
3585
3569
  GetAntennaAsyncWorker* asyncWorker = new GetAntennaAsyncWorker(env, this, vfo, antenna);
3586
3570
  asyncWorker->Queue();
@@ -3724,6 +3708,8 @@ Napi::Function NodeHamLib::GetClass(Napi::Env env) {
3724
3708
  // Static methods
3725
3709
  NodeHamLib::StaticMethod("getSupportedRigs", & NodeHamLib::GetSupportedRigs),
3726
3710
  NodeHamLib::StaticMethod("getHamlibVersion", & NodeHamLib::GetHamlibVersion),
3711
+ NodeHamLib::StaticMethod("setDebugLevel", & NodeHamLib::SetDebugLevel),
3712
+ NodeHamLib::StaticMethod("getDebugLevel", & NodeHamLib::GetDebugLevel),
3727
3713
  });
3728
3714
  constructor = Napi::Persistent(ret);
3729
3715
  constructor.SuppressDestruct();
@@ -3749,60 +3735,31 @@ bool NodeHamLib::isNetworkAddress(const char* path) {
3749
3735
  }
3750
3736
 
3751
3737
  // Static callback function for rig_list_foreach
3752
- int NodeHamLib::rig_list_callback(const struct rig_caps *caps, void *data) {
3738
+ int NodeHamLib::rig_list_callback(const shim_rig_info_t *info, void *data) {
3753
3739
  RigListData *rig_data = static_cast<RigListData*>(data);
3754
-
3740
+
3755
3741
  // Create rig info object
3756
3742
  Napi::Object rigInfo = Napi::Object::New(rig_data->env);
3757
- rigInfo.Set(Napi::String::New(rig_data->env, "rigModel"),
3758
- Napi::Number::New(rig_data->env, caps->rig_model));
3759
- rigInfo.Set(Napi::String::New(rig_data->env, "modelName"),
3760
- Napi::String::New(rig_data->env, caps->model_name ? caps->model_name : ""));
3761
- rigInfo.Set(Napi::String::New(rig_data->env, "mfgName"),
3762
- Napi::String::New(rig_data->env, caps->mfg_name ? caps->mfg_name : ""));
3763
- rigInfo.Set(Napi::String::New(rig_data->env, "version"),
3764
- Napi::String::New(rig_data->env, caps->version ? caps->version : ""));
3765
- rigInfo.Set(Napi::String::New(rig_data->env, "status"),
3766
- Napi::String::New(rig_data->env, rig_strstatus(caps->status)));
3767
-
3768
- // Determine rig type string
3769
- const char* rigType = "Unknown";
3770
- switch (caps->rig_type & RIG_TYPE_MASK) {
3771
- case RIG_TYPE_TRANSCEIVER:
3772
- rigType = "Transceiver";
3773
- break;
3774
- case RIG_TYPE_HANDHELD:
3775
- rigType = "Handheld";
3776
- break;
3777
- case RIG_TYPE_MOBILE:
3778
- rigType = "Mobile";
3779
- break;
3780
- case RIG_TYPE_RECEIVER:
3781
- rigType = "Receiver";
3782
- break;
3783
- case RIG_TYPE_PCRECEIVER:
3784
- rigType = "PC Receiver";
3785
- break;
3786
- case RIG_TYPE_SCANNER:
3787
- rigType = "Scanner";
3788
- break;
3789
- case RIG_TYPE_TRUNKSCANNER:
3790
- rigType = "Trunk Scanner";
3791
- break;
3792
- case RIG_TYPE_COMPUTER:
3793
- rigType = "Computer";
3794
- break;
3795
- case RIG_TYPE_OTHER:
3796
- rigType = "Other";
3797
- break;
3798
- }
3799
-
3800
- rigInfo.Set(Napi::String::New(rig_data->env, "rigType"),
3743
+ rigInfo.Set(Napi::String::New(rig_data->env, "rigModel"),
3744
+ Napi::Number::New(rig_data->env, info->rig_model));
3745
+ rigInfo.Set(Napi::String::New(rig_data->env, "modelName"),
3746
+ Napi::String::New(rig_data->env, info->model_name ? info->model_name : ""));
3747
+ rigInfo.Set(Napi::String::New(rig_data->env, "mfgName"),
3748
+ Napi::String::New(rig_data->env, info->mfg_name ? info->mfg_name : ""));
3749
+ rigInfo.Set(Napi::String::New(rig_data->env, "version"),
3750
+ Napi::String::New(rig_data->env, info->version ? info->version : ""));
3751
+ rigInfo.Set(Napi::String::New(rig_data->env, "status"),
3752
+ Napi::String::New(rig_data->env, shim_rig_strstatus(info->status)));
3753
+
3754
+ // Determine rig type string using shim helper
3755
+ const char* rigType = shim_rig_type_str(info->rig_type);
3756
+
3757
+ rigInfo.Set(Napi::String::New(rig_data->env, "rigType"),
3801
3758
  Napi::String::New(rig_data->env, rigType));
3802
-
3759
+
3803
3760
  // Add to list
3804
3761
  rig_data->rigList.push_back(rigInfo);
3805
-
3762
+
3806
3763
  return 1; // Continue iteration (returning 0 would stop)
3807
3764
  }
3808
3765
 
@@ -3811,15 +3768,15 @@ Napi::Value NodeHamLib::GetSupportedRigs(const Napi::CallbackInfo& info) {
3811
3768
  Napi::Env env = info.Env();
3812
3769
 
3813
3770
  // Load all backends to ensure we get the complete list
3814
- rig_load_all_backends();
3771
+ shim_rig_load_all_backends();
3815
3772
 
3816
3773
  // Prepare data structure for callback with proper initialization
3817
3774
  RigListData rigData{std::vector<Napi::Object>(), env};
3818
3775
 
3819
3776
  // Call hamlib function to iterate through all supported rigs
3820
- int result = rig_list_foreach(rig_list_callback, &rigData);
3777
+ int result = shim_rig_list_foreach(rig_list_callback, &rigData);
3821
3778
 
3822
- if (result != RIG_OK) {
3779
+ if (result != SHIM_RIG_OK) {
3823
3780
  Napi::Error::New(env, "Failed to retrieve supported rig list").ThrowAsJavaScriptException();
3824
3781
  return env.Null();
3825
3782
  }
@@ -3837,10 +3794,48 @@ Napi::Value NodeHamLib::GetSupportedRigs(const Napi::CallbackInfo& info) {
3837
3794
  Napi::Value NodeHamLib::GetHamlibVersion(const Napi::CallbackInfo& info) {
3838
3795
  Napi::Env env = info.Env();
3839
3796
 
3840
- // Reference to external hamlib_version2 variable
3841
- extern const char* hamlib_version2;
3797
+ return Napi::String::New(env, shim_rig_get_version());
3798
+ }
3842
3799
 
3843
- return Napi::String::New(env, hamlib_version2);
3800
+ // Set Hamlib debug level
3801
+ // Debug levels: 0=NONE, 1=BUG, 2=ERR, 3=WARN, 4=VERBOSE, 5=TRACE
3802
+ Napi::Value NodeHamLib::SetDebugLevel(const Napi::CallbackInfo& info) {
3803
+ Napi::Env env = info.Env();
3804
+
3805
+ if (info.Length() < 1 || !info[0].IsNumber()) {
3806
+ Napi::TypeError::New(env, "Debug level (number) required").ThrowAsJavaScriptException();
3807
+ return env.Undefined();
3808
+ }
3809
+
3810
+ int level = info[0].As<Napi::Number>().Int32Value();
3811
+
3812
+ // Validate debug level (0-5)
3813
+ if (level < 0 || level > 5) {
3814
+ Napi::RangeError::New(env, "Debug level must be between 0 (NONE) and 5 (TRACE)").ThrowAsJavaScriptException();
3815
+ return env.Undefined();
3816
+ }
3817
+
3818
+ shim_rig_set_debug(level);
3819
+
3820
+ return env.Undefined();
3821
+ }
3822
+
3823
+ // Get current Hamlib debug level
3824
+ Napi::Value NodeHamLib::GetDebugLevel(const Napi::CallbackInfo& info) {
3825
+ Napi::Env env = info.Env();
3826
+
3827
+ // hamlib_get_debug() is not available in all versions, so we use a workaround
3828
+ // by calling rig_debug_level which is a global variable in hamlib
3829
+ // However, this is internal implementation, so we use rig_debug with RIG_DEBUG_NONE
3830
+ // to get the current level. For now, we'll just return a note that this is not
3831
+ // directly accessible. In practice, applications should track the level they set.
3832
+
3833
+ // Since there's no public API to query debug level in Hamlib,
3834
+ // we'll document that users should track it themselves
3835
+ Napi::Error::New(env,
3836
+ "Getting debug level is not supported by Hamlib API. "
3837
+ "Please track the debug level you set using setDebugLevel().").ThrowAsJavaScriptException();
3838
+ return env.Undefined();
3844
3839
  }
3845
3840
 
3846
3841
  // Serial Port Configuration Methods
@@ -3985,7 +3980,7 @@ Napi::Value NodeHamLib::GetSupportedSerialConfigs(const Napi::CallbackInfo& info
3985
3980
  pttTypeOptions[5u] = Napi::String::New(env, "GPIO");
3986
3981
  pttTypeOptions[6u] = Napi::String::New(env, "GPION");
3987
3982
  pttTypeOptions[7u] = Napi::String::New(env, "NONE");
3988
- configs.Set("ptt_type", pttTypeOptions);
3983
+ configs.Set("intype", pttTypeOptions);
3989
3984
 
3990
3985
  // DCD type options
3991
3986
  Napi::Array dcdTypeOptions = Napi::Array::New(env, 9);
@@ -3998,7 +3993,7 @@ Napi::Value NodeHamLib::GetSupportedSerialConfigs(const Napi::CallbackInfo& info
3998
3993
  dcdTypeOptions[6u] = Napi::String::New(env, "GPIO");
3999
3994
  dcdTypeOptions[7u] = Napi::String::New(env, "GPION");
4000
3995
  dcdTypeOptions[8u] = Napi::String::New(env, "NONE");
4001
- configs.Set("dcd_type", dcdTypeOptions);
3996
+ configs.Set("intype", dcdTypeOptions);
4002
3997
 
4003
3998
  return configs;
4004
3999
  }
@@ -4013,7 +4008,7 @@ Napi::Value NodeHamLib::SetPowerstat(const Napi::CallbackInfo& info) {
4013
4008
  }
4014
4009
 
4015
4010
  int powerStatus = info[0].As<Napi::Number>().Int32Value();
4016
- powerstat_t status = static_cast<powerstat_t>(powerStatus);
4011
+ int status = static_cast<int>(powerStatus);
4017
4012
 
4018
4013
  SetPowerstatAsyncWorker* asyncWorker = new SetPowerstatAsyncWorker(env, this, status);
4019
4014
  asyncWorker->Queue();
@@ -4032,7 +4027,7 @@ Napi::Value NodeHamLib::GetPowerstat(const Napi::CallbackInfo& info) {
4032
4027
  Napi::Value NodeHamLib::GetPtt(const Napi::CallbackInfo& info) {
4033
4028
  Napi::Env env = info.Env();
4034
4029
 
4035
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
4030
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
4036
4031
 
4037
4032
  GetPttAsyncWorker* asyncWorker = new GetPttAsyncWorker(env, this, vfo);
4038
4033
  asyncWorker->Queue();
@@ -4043,7 +4038,7 @@ Napi::Value NodeHamLib::GetPtt(const Napi::CallbackInfo& info) {
4043
4038
  Napi::Value NodeHamLib::GetDcd(const Napi::CallbackInfo& info) {
4044
4039
  Napi::Env env = info.Env();
4045
4040
 
4046
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
4041
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
4047
4042
 
4048
4043
  GetDcdAsyncWorker* asyncWorker = new GetDcdAsyncWorker(env, this, vfo);
4049
4044
  asyncWorker->Queue();
@@ -4059,8 +4054,8 @@ Napi::Value NodeHamLib::SetTuningStep(const Napi::CallbackInfo& info) {
4059
4054
  return env.Null();
4060
4055
  }
4061
4056
 
4062
- shortfreq_t ts = info[0].As<Napi::Number>().Int32Value();
4063
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
4057
+ int ts = info[0].As<Napi::Number>().Int32Value();
4058
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
4064
4059
 
4065
4060
  SetTuningStepAsyncWorker* asyncWorker = new SetTuningStepAsyncWorker(env, this, vfo, ts);
4066
4061
  asyncWorker->Queue();
@@ -4070,7 +4065,7 @@ Napi::Value NodeHamLib::SetTuningStep(const Napi::CallbackInfo& info) {
4070
4065
  Napi::Value NodeHamLib::GetTuningStep(const Napi::CallbackInfo& info) {
4071
4066
  Napi::Env env = info.Env();
4072
4067
 
4073
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
4068
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
4074
4069
 
4075
4070
  GetTuningStepAsyncWorker* asyncWorker = new GetTuningStepAsyncWorker(env, this, vfo);
4076
4071
  asyncWorker->Queue();
@@ -4087,20 +4082,20 @@ Napi::Value NodeHamLib::SetRepeaterShift(const Napi::CallbackInfo& info) {
4087
4082
  }
4088
4083
 
4089
4084
  std::string shiftStr = info[0].As<Napi::String>().Utf8Value();
4090
- rptr_shift_t shift = RIG_RPT_SHIFT_NONE;
4085
+ int shift = SHIM_RIG_RPT_SHIFT_NONE;
4091
4086
 
4092
4087
  if (shiftStr == "NONE" || shiftStr == "none") {
4093
- shift = RIG_RPT_SHIFT_NONE;
4088
+ shift = SHIM_RIG_RPT_SHIFT_NONE;
4094
4089
  } else if (shiftStr == "MINUS" || shiftStr == "minus" || shiftStr == "-") {
4095
- shift = RIG_RPT_SHIFT_MINUS;
4090
+ shift = SHIM_RIG_RPT_SHIFT_MINUS;
4096
4091
  } else if (shiftStr == "PLUS" || shiftStr == "plus" || shiftStr == "+") {
4097
- shift = RIG_RPT_SHIFT_PLUS;
4092
+ shift = SHIM_RIG_RPT_SHIFT_PLUS;
4098
4093
  } else {
4099
4094
  Napi::TypeError::New(env, "Invalid repeater shift (must be 'NONE', 'MINUS', or 'PLUS')").ThrowAsJavaScriptException();
4100
4095
  return env.Null();
4101
4096
  }
4102
4097
 
4103
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
4098
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
4104
4099
 
4105
4100
  SetRepeaterShiftAsyncWorker* asyncWorker = new SetRepeaterShiftAsyncWorker(env, this, vfo, shift);
4106
4101
  asyncWorker->Queue();
@@ -4110,7 +4105,7 @@ Napi::Value NodeHamLib::SetRepeaterShift(const Napi::CallbackInfo& info) {
4110
4105
  Napi::Value NodeHamLib::GetRepeaterShift(const Napi::CallbackInfo& info) {
4111
4106
  Napi::Env env = info.Env();
4112
4107
 
4113
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
4108
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
4114
4109
 
4115
4110
  GetRepeaterShiftAsyncWorker* asyncWorker = new GetRepeaterShiftAsyncWorker(env, this, vfo);
4116
4111
  asyncWorker->Queue();
@@ -4125,8 +4120,8 @@ Napi::Value NodeHamLib::SetRepeaterOffset(const Napi::CallbackInfo& info) {
4125
4120
  return env.Null();
4126
4121
  }
4127
4122
 
4128
- shortfreq_t offset = info[0].As<Napi::Number>().Int32Value();
4129
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
4123
+ int offset = info[0].As<Napi::Number>().Int32Value();
4124
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
4130
4125
 
4131
4126
  SetRepeaterOffsetAsyncWorker* asyncWorker = new SetRepeaterOffsetAsyncWorker(env, this, vfo, offset);
4132
4127
  asyncWorker->Queue();
@@ -4136,7 +4131,7 @@ Napi::Value NodeHamLib::SetRepeaterOffset(const Napi::CallbackInfo& info) {
4136
4131
  Napi::Value NodeHamLib::GetRepeaterOffset(const Napi::CallbackInfo& info) {
4137
4132
  Napi::Env env = info.Env();
4138
4133
 
4139
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
4134
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
4140
4135
 
4141
4136
  GetRepeaterOffsetAsyncWorker* asyncWorker = new GetRepeaterOffsetAsyncWorker(env, this, vfo);
4142
4137
  asyncWorker->Queue();
@@ -4146,21 +4141,21 @@ Napi::Value NodeHamLib::GetRepeaterOffset(const Napi::CallbackInfo& info) {
4146
4141
  // CTCSS/DCS Tone Control AsyncWorker classes
4147
4142
  class SetCtcssToneAsyncWorker : public HamLibAsyncWorker {
4148
4143
  public:
4149
- SetCtcssToneAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, tone_t tone)
4144
+ SetCtcssToneAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, unsigned int tone)
4150
4145
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tone_(tone) {}
4151
4146
 
4152
4147
  void Execute() override {
4153
4148
  CHECK_RIG_VALID();
4154
4149
 
4155
- result_code_ = rig_set_ctcss_tone(hamlib_instance_->my_rig, vfo_, tone_);
4156
- if (result_code_ != RIG_OK) {
4157
- error_message_ = rigerror(result_code_);
4150
+ result_code_ = shim_rig_set_ctcss_tone(hamlib_instance_->my_rig, vfo_, tone_);
4151
+ if (result_code_ != SHIM_RIG_OK) {
4152
+ error_message_ = shim_rigerror(result_code_);
4158
4153
  }
4159
4154
  }
4160
4155
 
4161
4156
  void OnOK() override {
4162
4157
  Napi::Env env = Env();
4163
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4158
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4164
4159
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4165
4160
  } else {
4166
4161
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4173,27 +4168,27 @@ public:
4173
4168
  }
4174
4169
 
4175
4170
  private:
4176
- vfo_t vfo_;
4177
- tone_t tone_;
4171
+ int vfo_;
4172
+ unsigned int tone_;
4178
4173
  };
4179
4174
 
4180
4175
  class GetCtcssToneAsyncWorker : public HamLibAsyncWorker {
4181
4176
  public:
4182
- GetCtcssToneAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
4177
+ GetCtcssToneAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
4183
4178
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tone_(0) {}
4184
4179
 
4185
4180
  void Execute() override {
4186
4181
  CHECK_RIG_VALID();
4187
4182
 
4188
- result_code_ = rig_get_ctcss_tone(hamlib_instance_->my_rig, vfo_, &tone_);
4189
- if (result_code_ != RIG_OK) {
4190
- error_message_ = rigerror(result_code_);
4183
+ result_code_ = shim_rig_get_ctcss_tone(hamlib_instance_->my_rig, vfo_, &tone_);
4184
+ if (result_code_ != SHIM_RIG_OK) {
4185
+ error_message_ = shim_rigerror(result_code_);
4191
4186
  }
4192
4187
  }
4193
4188
 
4194
4189
  void OnOK() override {
4195
4190
  Napi::Env env = Env();
4196
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4191
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4197
4192
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4198
4193
  } else {
4199
4194
  deferred_.Resolve(Napi::Number::New(env, tone_));
@@ -4206,27 +4201,27 @@ public:
4206
4201
  }
4207
4202
 
4208
4203
  private:
4209
- vfo_t vfo_;
4210
- tone_t tone_;
4204
+ int vfo_;
4205
+ unsigned int tone_;
4211
4206
  };
4212
4207
 
4213
4208
  class SetDcsCodeAsyncWorker : public HamLibAsyncWorker {
4214
4209
  public:
4215
- SetDcsCodeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, tone_t code)
4210
+ SetDcsCodeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, unsigned int code)
4216
4211
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), code_(code) {}
4217
4212
 
4218
4213
  void Execute() override {
4219
4214
  CHECK_RIG_VALID();
4220
4215
 
4221
- result_code_ = rig_set_dcs_code(hamlib_instance_->my_rig, vfo_, code_);
4222
- if (result_code_ != RIG_OK) {
4223
- error_message_ = rigerror(result_code_);
4216
+ result_code_ = shim_rig_set_dcs_code(hamlib_instance_->my_rig, vfo_, code_);
4217
+ if (result_code_ != SHIM_RIG_OK) {
4218
+ error_message_ = shim_rigerror(result_code_);
4224
4219
  }
4225
4220
  }
4226
4221
 
4227
4222
  void OnOK() override {
4228
4223
  Napi::Env env = Env();
4229
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4224
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4230
4225
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4231
4226
  } else {
4232
4227
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4239,27 +4234,27 @@ public:
4239
4234
  }
4240
4235
 
4241
4236
  private:
4242
- vfo_t vfo_;
4243
- tone_t code_;
4237
+ int vfo_;
4238
+ unsigned int code_;
4244
4239
  };
4245
4240
 
4246
4241
  class GetDcsCodeAsyncWorker : public HamLibAsyncWorker {
4247
4242
  public:
4248
- GetDcsCodeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
4243
+ GetDcsCodeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
4249
4244
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), code_(0) {}
4250
4245
 
4251
4246
  void Execute() override {
4252
4247
  CHECK_RIG_VALID();
4253
4248
 
4254
- result_code_ = rig_get_dcs_code(hamlib_instance_->my_rig, vfo_, &code_);
4255
- if (result_code_ != RIG_OK) {
4256
- error_message_ = rigerror(result_code_);
4249
+ result_code_ = shim_rig_get_dcs_code(hamlib_instance_->my_rig, vfo_, &code_);
4250
+ if (result_code_ != SHIM_RIG_OK) {
4251
+ error_message_ = shim_rigerror(result_code_);
4257
4252
  }
4258
4253
  }
4259
4254
 
4260
4255
  void OnOK() override {
4261
4256
  Napi::Env env = Env();
4262
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4257
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4263
4258
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4264
4259
  } else {
4265
4260
  deferred_.Resolve(Napi::Number::New(env, code_));
@@ -4272,27 +4267,27 @@ public:
4272
4267
  }
4273
4268
 
4274
4269
  private:
4275
- vfo_t vfo_;
4276
- tone_t code_;
4270
+ int vfo_;
4271
+ unsigned int code_;
4277
4272
  };
4278
4273
 
4279
4274
  class SetCtcssSqlAsyncWorker : public HamLibAsyncWorker {
4280
4275
  public:
4281
- SetCtcssSqlAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, tone_t tone)
4276
+ SetCtcssSqlAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, unsigned int tone)
4282
4277
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tone_(tone) {}
4283
4278
 
4284
4279
  void Execute() override {
4285
4280
  CHECK_RIG_VALID();
4286
4281
 
4287
- result_code_ = rig_set_ctcss_sql(hamlib_instance_->my_rig, vfo_, tone_);
4288
- if (result_code_ != RIG_OK) {
4289
- error_message_ = rigerror(result_code_);
4282
+ result_code_ = shim_rig_set_ctcss_sql(hamlib_instance_->my_rig, vfo_, tone_);
4283
+ if (result_code_ != SHIM_RIG_OK) {
4284
+ error_message_ = shim_rigerror(result_code_);
4290
4285
  }
4291
4286
  }
4292
4287
 
4293
4288
  void OnOK() override {
4294
4289
  Napi::Env env = Env();
4295
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4290
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4296
4291
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4297
4292
  } else {
4298
4293
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4305,27 +4300,27 @@ public:
4305
4300
  }
4306
4301
 
4307
4302
  private:
4308
- vfo_t vfo_;
4309
- tone_t tone_;
4303
+ int vfo_;
4304
+ unsigned int tone_;
4310
4305
  };
4311
4306
 
4312
4307
  class GetCtcssSqlAsyncWorker : public HamLibAsyncWorker {
4313
4308
  public:
4314
- GetCtcssSqlAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
4309
+ GetCtcssSqlAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
4315
4310
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tone_(0) {}
4316
4311
 
4317
4312
  void Execute() override {
4318
4313
  CHECK_RIG_VALID();
4319
4314
 
4320
- result_code_ = rig_get_ctcss_sql(hamlib_instance_->my_rig, vfo_, &tone_);
4321
- if (result_code_ != RIG_OK) {
4322
- error_message_ = rigerror(result_code_);
4315
+ result_code_ = shim_rig_get_ctcss_sql(hamlib_instance_->my_rig, vfo_, &tone_);
4316
+ if (result_code_ != SHIM_RIG_OK) {
4317
+ error_message_ = shim_rigerror(result_code_);
4323
4318
  }
4324
4319
  }
4325
4320
 
4326
4321
  void OnOK() override {
4327
4322
  Napi::Env env = Env();
4328
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4323
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4329
4324
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4330
4325
  } else {
4331
4326
  deferred_.Resolve(Napi::Number::New(env, tone_));
@@ -4338,27 +4333,27 @@ public:
4338
4333
  }
4339
4334
 
4340
4335
  private:
4341
- vfo_t vfo_;
4342
- tone_t tone_;
4336
+ int vfo_;
4337
+ unsigned int tone_;
4343
4338
  };
4344
4339
 
4345
4340
  class SetDcsSqlAsyncWorker : public HamLibAsyncWorker {
4346
4341
  public:
4347
- SetDcsSqlAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, tone_t code)
4342
+ SetDcsSqlAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, unsigned int code)
4348
4343
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), code_(code) {}
4349
4344
 
4350
4345
  void Execute() override {
4351
4346
  CHECK_RIG_VALID();
4352
4347
 
4353
- result_code_ = rig_set_dcs_sql(hamlib_instance_->my_rig, vfo_, code_);
4354
- if (result_code_ != RIG_OK) {
4355
- error_message_ = rigerror(result_code_);
4348
+ result_code_ = shim_rig_set_dcs_sql(hamlib_instance_->my_rig, vfo_, code_);
4349
+ if (result_code_ != SHIM_RIG_OK) {
4350
+ error_message_ = shim_rigerror(result_code_);
4356
4351
  }
4357
4352
  }
4358
4353
 
4359
4354
  void OnOK() override {
4360
4355
  Napi::Env env = Env();
4361
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4356
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4362
4357
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4363
4358
  } else {
4364
4359
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4371,27 +4366,27 @@ public:
4371
4366
  }
4372
4367
 
4373
4368
  private:
4374
- vfo_t vfo_;
4375
- tone_t code_;
4369
+ int vfo_;
4370
+ unsigned int code_;
4376
4371
  };
4377
4372
 
4378
4373
  class GetDcsSqlAsyncWorker : public HamLibAsyncWorker {
4379
4374
  public:
4380
- GetDcsSqlAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
4375
+ GetDcsSqlAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
4381
4376
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), code_(0) {}
4382
4377
 
4383
4378
  void Execute() override {
4384
4379
  CHECK_RIG_VALID();
4385
4380
 
4386
- result_code_ = rig_get_dcs_sql(hamlib_instance_->my_rig, vfo_, &code_);
4387
- if (result_code_ != RIG_OK) {
4388
- error_message_ = rigerror(result_code_);
4381
+ result_code_ = shim_rig_get_dcs_sql(hamlib_instance_->my_rig, vfo_, &code_);
4382
+ if (result_code_ != SHIM_RIG_OK) {
4383
+ error_message_ = shim_rigerror(result_code_);
4389
4384
  }
4390
4385
  }
4391
4386
 
4392
4387
  void OnOK() override {
4393
4388
  Napi::Env env = Env();
4394
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4389
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4395
4390
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4396
4391
  } else {
4397
4392
  deferred_.Resolve(Napi::Number::New(env, code_));
@@ -4404,97 +4399,95 @@ public:
4404
4399
  }
4405
4400
 
4406
4401
  private:
4407
- vfo_t vfo_;
4408
- tone_t code_;
4402
+ int vfo_;
4403
+ unsigned int code_;
4409
4404
  };
4410
4405
 
4411
4406
  // Parameter Control AsyncWorker classes
4412
4407
  class SetParmAsyncWorker : public HamLibAsyncWorker {
4413
4408
  public:
4414
- SetParmAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, setting_t parm, value_t value)
4409
+ SetParmAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, uint64_t parm, float value)
4415
4410
  : HamLibAsyncWorker(env, hamlib_instance), parm_(parm), value_(value) {}
4416
-
4411
+
4417
4412
  void Execute() override {
4418
4413
  CHECK_RIG_VALID();
4419
-
4420
- result_code_ = rig_set_parm(hamlib_instance_->my_rig, parm_, value_);
4421
- if (result_code_ != RIG_OK) {
4422
- error_message_ = rigerror(result_code_);
4414
+
4415
+ result_code_ = shim_rig_set_parm_f(hamlib_instance_->my_rig, parm_, value_);
4416
+ if (result_code_ != SHIM_RIG_OK) {
4417
+ error_message_ = shim_rigerror(result_code_);
4423
4418
  }
4424
4419
  }
4425
-
4420
+
4426
4421
  void OnOK() override {
4427
4422
  Napi::Env env = Env();
4428
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4423
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4429
4424
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4430
4425
  } else {
4431
4426
  deferred_.Resolve(Napi::Number::New(env, result_code_));
4432
4427
  }
4433
4428
  }
4434
-
4429
+
4435
4430
  void OnError(const Napi::Error& e) override {
4436
4431
  Napi::Env env = Env();
4437
4432
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4438
4433
  }
4439
-
4434
+
4440
4435
  private:
4441
- setting_t parm_;
4442
- value_t value_;
4436
+ uint64_t parm_;
4437
+ float value_;
4443
4438
  };
4444
4439
 
4445
4440
  class GetParmAsyncWorker : public HamLibAsyncWorker {
4446
4441
  public:
4447
- GetParmAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, setting_t parm)
4448
- : HamLibAsyncWorker(env, hamlib_instance), parm_(parm) {
4449
- value_.f = 0.0;
4450
- }
4451
-
4442
+ GetParmAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, uint64_t parm)
4443
+ : HamLibAsyncWorker(env, hamlib_instance), parm_(parm), value_(0.0f) {}
4444
+
4452
4445
  void Execute() override {
4453
4446
  CHECK_RIG_VALID();
4454
-
4455
- result_code_ = rig_get_parm(hamlib_instance_->my_rig, parm_, &value_);
4456
- if (result_code_ != RIG_OK) {
4457
- error_message_ = rigerror(result_code_);
4447
+
4448
+ result_code_ = shim_rig_get_parm_f(hamlib_instance_->my_rig, parm_, &value_);
4449
+ if (result_code_ != SHIM_RIG_OK) {
4450
+ error_message_ = shim_rigerror(result_code_);
4458
4451
  }
4459
4452
  }
4460
-
4453
+
4461
4454
  void OnOK() override {
4462
4455
  Napi::Env env = Env();
4463
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4456
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4464
4457
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4465
4458
  } else {
4466
- deferred_.Resolve(Napi::Number::New(env, value_.f));
4459
+ deferred_.Resolve(Napi::Number::New(env, value_));
4467
4460
  }
4468
4461
  }
4469
-
4462
+
4470
4463
  void OnError(const Napi::Error& e) override {
4471
4464
  Napi::Env env = Env();
4472
4465
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4473
4466
  }
4474
-
4467
+
4475
4468
  private:
4476
- setting_t parm_;
4477
- value_t value_;
4469
+ uint64_t parm_;
4470
+ float value_;
4478
4471
  };
4479
4472
 
4480
4473
  // DTMF Support AsyncWorker classes
4481
4474
  class SendDtmfAsyncWorker : public HamLibAsyncWorker {
4482
4475
  public:
4483
- SendDtmfAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, const std::string& digits)
4476
+ SendDtmfAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, const std::string& digits)
4484
4477
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), digits_(digits) {}
4485
4478
 
4486
4479
  void Execute() override {
4487
4480
  CHECK_RIG_VALID();
4488
4481
 
4489
- result_code_ = rig_send_dtmf(hamlib_instance_->my_rig, vfo_, digits_.c_str());
4490
- if (result_code_ != RIG_OK) {
4491
- error_message_ = rigerror(result_code_);
4482
+ result_code_ = shim_rig_send_dtmf(hamlib_instance_->my_rig, vfo_, digits_.c_str());
4483
+ if (result_code_ != SHIM_RIG_OK) {
4484
+ error_message_ = shim_rigerror(result_code_);
4492
4485
  }
4493
4486
  }
4494
4487
 
4495
4488
  void OnOK() override {
4496
4489
  Napi::Env env = Env();
4497
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4490
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4498
4491
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4499
4492
  } else {
4500
4493
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4507,13 +4500,13 @@ public:
4507
4500
  }
4508
4501
 
4509
4502
  private:
4510
- vfo_t vfo_;
4503
+ int vfo_;
4511
4504
  std::string digits_;
4512
4505
  };
4513
4506
 
4514
4507
  class RecvDtmfAsyncWorker : public HamLibAsyncWorker {
4515
4508
  public:
4516
- RecvDtmfAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, int maxLength)
4509
+ RecvDtmfAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, int maxLength)
4517
4510
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), max_length_(maxLength), length_(0) {
4518
4511
  digits_.resize(maxLength + 1, '\0');
4519
4512
  }
@@ -4523,15 +4516,15 @@ public:
4523
4516
 
4524
4517
  length_ = max_length_;
4525
4518
  // rig_recv_dtmf expects a mutable buffer (char*). Ensure non-const pointer.
4526
- result_code_ = rig_recv_dtmf(hamlib_instance_->my_rig, vfo_, &digits_[0], &length_);
4527
- if (result_code_ != RIG_OK) {
4528
- error_message_ = rigerror(result_code_);
4519
+ result_code_ = shim_rig_recv_dtmf(hamlib_instance_->my_rig, vfo_, &digits_[0], &length_);
4520
+ if (result_code_ != SHIM_RIG_OK) {
4521
+ error_message_ = shim_rigerror(result_code_);
4529
4522
  }
4530
4523
  }
4531
4524
 
4532
4525
  void OnOK() override {
4533
4526
  Napi::Env env = Env();
4534
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4527
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4535
4528
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4536
4529
  } else {
4537
4530
  Napi::Object obj = Napi::Object::New(env);
@@ -4547,7 +4540,7 @@ public:
4547
4540
  }
4548
4541
 
4549
4542
  private:
4550
- vfo_t vfo_;
4543
+ int vfo_;
4551
4544
  int max_length_;
4552
4545
  int length_;
4553
4546
  std::string digits_;
@@ -4556,21 +4549,21 @@ private:
4556
4549
  // Memory Channel Advanced Operations AsyncWorker classes
4557
4550
  class GetMemAsyncWorker : public HamLibAsyncWorker {
4558
4551
  public:
4559
- GetMemAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
4552
+ GetMemAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
4560
4553
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ch_(0) {}
4561
4554
 
4562
4555
  void Execute() override {
4563
4556
  CHECK_RIG_VALID();
4564
4557
 
4565
- result_code_ = rig_get_mem(hamlib_instance_->my_rig, vfo_, &ch_);
4566
- if (result_code_ != RIG_OK) {
4567
- error_message_ = rigerror(result_code_);
4558
+ result_code_ = shim_rig_get_mem(hamlib_instance_->my_rig, vfo_, &ch_);
4559
+ if (result_code_ != SHIM_RIG_OK) {
4560
+ error_message_ = shim_rigerror(result_code_);
4568
4561
  }
4569
4562
  }
4570
4563
 
4571
4564
  void OnOK() override {
4572
4565
  Napi::Env env = Env();
4573
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4566
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4574
4567
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4575
4568
  } else {
4576
4569
  deferred_.Resolve(Napi::Number::New(env, ch_));
@@ -4583,27 +4576,27 @@ public:
4583
4576
  }
4584
4577
 
4585
4578
  private:
4586
- vfo_t vfo_;
4579
+ int vfo_;
4587
4580
  int ch_;
4588
4581
  };
4589
4582
 
4590
4583
  class SetBankAsyncWorker : public HamLibAsyncWorker {
4591
4584
  public:
4592
- SetBankAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, int bank)
4585
+ SetBankAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, int bank)
4593
4586
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), bank_(bank) {}
4594
4587
 
4595
4588
  void Execute() override {
4596
4589
  CHECK_RIG_VALID();
4597
4590
 
4598
- result_code_ = rig_set_bank(hamlib_instance_->my_rig, vfo_, bank_);
4599
- if (result_code_ != RIG_OK) {
4600
- error_message_ = rigerror(result_code_);
4591
+ result_code_ = shim_rig_set_bank(hamlib_instance_->my_rig, vfo_, bank_);
4592
+ if (result_code_ != SHIM_RIG_OK) {
4593
+ error_message_ = shim_rigerror(result_code_);
4601
4594
  }
4602
4595
  }
4603
4596
 
4604
4597
  void OnOK() override {
4605
4598
  Napi::Env env = Env();
4606
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4599
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4607
4600
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4608
4601
  } else {
4609
4602
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4616,7 +4609,7 @@ public:
4616
4609
  }
4617
4610
 
4618
4611
  private:
4619
- vfo_t vfo_;
4612
+ int vfo_;
4620
4613
  int bank_;
4621
4614
  };
4622
4615
 
@@ -4628,18 +4621,18 @@ public:
4628
4621
  void Execute() override {
4629
4622
  CHECK_RIG_VALID();
4630
4623
 
4631
- count_ = rig_mem_count(hamlib_instance_->my_rig);
4624
+ count_ = shim_rig_mem_count(hamlib_instance_->my_rig);
4632
4625
  if (count_ < 0) {
4633
4626
  result_code_ = count_;
4634
- error_message_ = rigerror(result_code_);
4627
+ error_message_ = shim_rigerror(result_code_);
4635
4628
  } else {
4636
- result_code_ = RIG_OK;
4629
+ result_code_ = SHIM_RIG_OK;
4637
4630
  }
4638
4631
  }
4639
4632
 
4640
4633
  void OnOK() override {
4641
4634
  Napi::Env env = Env();
4642
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4635
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4643
4636
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4644
4637
  } else {
4645
4638
  deferred_.Resolve(Napi::Number::New(env, count_));
@@ -4658,21 +4651,21 @@ private:
4658
4651
  // Morse Code Support AsyncWorker classes
4659
4652
  class SendMorseAsyncWorker : public HamLibAsyncWorker {
4660
4653
  public:
4661
- SendMorseAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, const std::string& msg)
4654
+ SendMorseAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, const std::string& msg)
4662
4655
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), msg_(msg) {}
4663
4656
 
4664
4657
  void Execute() override {
4665
4658
  CHECK_RIG_VALID();
4666
4659
 
4667
- result_code_ = rig_send_morse(hamlib_instance_->my_rig, vfo_, msg_.c_str());
4668
- if (result_code_ != RIG_OK) {
4669
- error_message_ = rigerror(result_code_);
4660
+ result_code_ = shim_rig_send_morse(hamlib_instance_->my_rig, vfo_, msg_.c_str());
4661
+ if (result_code_ != SHIM_RIG_OK) {
4662
+ error_message_ = shim_rigerror(result_code_);
4670
4663
  }
4671
4664
  }
4672
4665
 
4673
4666
  void OnOK() override {
4674
4667
  Napi::Env env = Env();
4675
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4668
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4676
4669
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4677
4670
  } else {
4678
4671
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4685,27 +4678,27 @@ public:
4685
4678
  }
4686
4679
 
4687
4680
  private:
4688
- vfo_t vfo_;
4681
+ int vfo_;
4689
4682
  std::string msg_;
4690
4683
  };
4691
4684
 
4692
4685
  class StopMorseAsyncWorker : public HamLibAsyncWorker {
4693
4686
  public:
4694
- StopMorseAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
4687
+ StopMorseAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
4695
4688
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo) {}
4696
4689
 
4697
4690
  void Execute() override {
4698
4691
  CHECK_RIG_VALID();
4699
4692
 
4700
- result_code_ = rig_stop_morse(hamlib_instance_->my_rig, vfo_);
4701
- if (result_code_ != RIG_OK) {
4702
- error_message_ = rigerror(result_code_);
4693
+ result_code_ = shim_rig_stop_morse(hamlib_instance_->my_rig, vfo_);
4694
+ if (result_code_ != SHIM_RIG_OK) {
4695
+ error_message_ = shim_rigerror(result_code_);
4703
4696
  }
4704
4697
  }
4705
4698
 
4706
4699
  void OnOK() override {
4707
4700
  Napi::Env env = Env();
4708
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4701
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4709
4702
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4710
4703
  } else {
4711
4704
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4718,26 +4711,26 @@ public:
4718
4711
  }
4719
4712
 
4720
4713
  private:
4721
- vfo_t vfo_;
4714
+ int vfo_;
4722
4715
  };
4723
4716
 
4724
4717
  class WaitMorseAsyncWorker : public HamLibAsyncWorker {
4725
4718
  public:
4726
- WaitMorseAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
4719
+ WaitMorseAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
4727
4720
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo) {}
4728
4721
 
4729
4722
  void Execute() override {
4730
4723
  CHECK_RIG_VALID();
4731
4724
 
4732
- result_code_ = rig_wait_morse(hamlib_instance_->my_rig, vfo_);
4733
- if (result_code_ != RIG_OK) {
4734
- error_message_ = rigerror(result_code_);
4725
+ result_code_ = shim_rig_wait_morse(hamlib_instance_->my_rig, vfo_);
4726
+ if (result_code_ != SHIM_RIG_OK) {
4727
+ error_message_ = shim_rigerror(result_code_);
4735
4728
  }
4736
4729
  }
4737
4730
 
4738
4731
  void OnOK() override {
4739
4732
  Napi::Env env = Env();
4740
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4733
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4741
4734
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4742
4735
  } else {
4743
4736
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4750,27 +4743,27 @@ public:
4750
4743
  }
4751
4744
 
4752
4745
  private:
4753
- vfo_t vfo_;
4746
+ int vfo_;
4754
4747
  };
4755
4748
 
4756
4749
  // Voice Memory Support AsyncWorker classes
4757
4750
  class SendVoiceMemAsyncWorker : public HamLibAsyncWorker {
4758
4751
  public:
4759
- SendVoiceMemAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo, int ch)
4752
+ SendVoiceMemAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo, int ch)
4760
4753
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ch_(ch) {}
4761
4754
 
4762
4755
  void Execute() override {
4763
4756
  CHECK_RIG_VALID();
4764
4757
 
4765
- result_code_ = rig_send_voice_mem(hamlib_instance_->my_rig, vfo_, ch_);
4766
- if (result_code_ != RIG_OK) {
4767
- error_message_ = rigerror(result_code_);
4758
+ result_code_ = shim_rig_send_voice_mem(hamlib_instance_->my_rig, vfo_, ch_);
4759
+ if (result_code_ != SHIM_RIG_OK) {
4760
+ error_message_ = shim_rigerror(result_code_);
4768
4761
  }
4769
4762
  }
4770
4763
 
4771
4764
  void OnOK() override {
4772
4765
  Napi::Env env = Env();
4773
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4766
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4774
4767
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4775
4768
  } else {
4776
4769
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4783,34 +4776,27 @@ public:
4783
4776
  }
4784
4777
 
4785
4778
  private:
4786
- vfo_t vfo_;
4779
+ int vfo_;
4787
4780
  int ch_;
4788
4781
  };
4789
4782
 
4790
4783
  class StopVoiceMemAsyncWorker : public HamLibAsyncWorker {
4791
4784
  public:
4792
- StopVoiceMemAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
4785
+ StopVoiceMemAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
4793
4786
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo) {}
4794
4787
 
4795
4788
  void Execute() override {
4796
4789
  CHECK_RIG_VALID();
4797
4790
 
4798
- #if HAVE_RIG_STOP_VOICE_MEM
4799
- result_code_ = rig_stop_voice_mem(hamlib_instance_->my_rig, vfo_);
4800
- if (result_code_ != RIG_OK) {
4801
- error_message_ = rigerror(result_code_);
4791
+ result_code_ = shim_rig_stop_voice_mem(hamlib_instance_->my_rig, vfo_);
4792
+ if (result_code_ != SHIM_RIG_OK) {
4793
+ error_message_ = shim_rigerror(result_code_);
4802
4794
  }
4803
- #else
4804
- // rig_stop_voice_mem function is not available in this hamlib version
4805
- // Return not implemented for compatibility with older hamlib versions
4806
- result_code_ = -RIG_ENIMPL;
4807
- error_message_ = "rig_stop_voice_mem not available in this hamlib version";
4808
- #endif
4809
4795
  }
4810
4796
 
4811
4797
  void OnOK() override {
4812
4798
  Napi::Env env = Env();
4813
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4799
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4814
4800
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4815
4801
  } else {
4816
4802
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4823,36 +4809,29 @@ public:
4823
4809
  }
4824
4810
 
4825
4811
  private:
4826
- vfo_t vfo_;
4812
+ int vfo_;
4827
4813
  };
4828
4814
 
4829
4815
  // Complex Split Frequency/Mode Operations AsyncWorker classes
4830
4816
  class SetSplitFreqModeAsyncWorker : public HamLibAsyncWorker {
4831
4817
  public:
4832
- SetSplitFreqModeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo,
4833
- freq_t tx_freq, rmode_t tx_mode, pbwidth_t tx_width)
4818
+ SetSplitFreqModeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo,
4819
+ double tx_freq, int tx_mode, int tx_width)
4834
4820
  : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tx_freq_(tx_freq),
4835
4821
  tx_mode_(tx_mode), tx_width_(tx_width) {}
4836
4822
 
4837
4823
  void Execute() override {
4838
4824
  CHECK_RIG_VALID();
4839
4825
 
4840
- #if HAVE_RIG_SPLIT_FREQ_MODE
4841
- result_code_ = rig_set_split_freq_mode(hamlib_instance_->my_rig, vfo_, tx_freq_, tx_mode_, tx_width_);
4842
- if (result_code_ != RIG_OK) {
4843
- error_message_ = rigerror(result_code_);
4826
+ result_code_ = shim_rig_set_split_freq_mode(hamlib_instance_->my_rig, vfo_, tx_freq_, tx_mode_, tx_width_);
4827
+ if (result_code_ != SHIM_RIG_OK) {
4828
+ error_message_ = shim_rigerror(result_code_);
4844
4829
  }
4845
- #else
4846
- // rig_set_split_freq_mode function is not available in this hamlib version
4847
- // Fall back to using separate calls
4848
- result_code_ = -RIG_ENIMPL;
4849
- error_message_ = "rig_set_split_freq_mode not available - use setSplitFreq and setSplitMode separately";
4850
- #endif
4851
4830
  }
4852
4831
 
4853
4832
  void OnOK() override {
4854
4833
  Napi::Env env = Env();
4855
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4834
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4856
4835
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4857
4836
  } else {
4858
4837
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4865,41 +4844,34 @@ public:
4865
4844
  }
4866
4845
 
4867
4846
  private:
4868
- vfo_t vfo_;
4869
- freq_t tx_freq_;
4870
- rmode_t tx_mode_;
4871
- pbwidth_t tx_width_;
4847
+ int vfo_;
4848
+ double tx_freq_;
4849
+ int tx_mode_;
4850
+ int tx_width_;
4872
4851
  };
4873
4852
 
4874
4853
  class GetSplitFreqModeAsyncWorker : public HamLibAsyncWorker {
4875
4854
  public:
4876
- GetSplitFreqModeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, vfo_t vfo)
4877
- : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tx_freq_(0), tx_mode_(RIG_MODE_NONE), tx_width_(0) {}
4855
+ GetSplitFreqModeAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int vfo)
4856
+ : HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tx_freq_(0), tx_mode_(SHIM_RIG_MODE_NONE), tx_width_(0) {}
4878
4857
 
4879
4858
  void Execute() override {
4880
4859
  CHECK_RIG_VALID();
4881
4860
 
4882
- #if HAVE_RIG_SPLIT_FREQ_MODE
4883
- result_code_ = rig_get_split_freq_mode(hamlib_instance_->my_rig, vfo_, &tx_freq_, &tx_mode_, &tx_width_);
4884
- if (result_code_ != RIG_OK) {
4885
- error_message_ = rigerror(result_code_);
4861
+ result_code_ = shim_rig_get_split_freq_mode(hamlib_instance_->my_rig, vfo_, &tx_freq_, &tx_mode_, &tx_width_);
4862
+ if (result_code_ != SHIM_RIG_OK) {
4863
+ error_message_ = shim_rigerror(result_code_);
4886
4864
  }
4887
- #else
4888
- // rig_get_split_freq_mode function is not available in this hamlib version
4889
- // Fall back to using separate calls
4890
- result_code_ = -RIG_ENIMPL;
4891
- error_message_ = "rig_get_split_freq_mode not available - use getSplitFreq and getSplitMode separately";
4892
- #endif
4893
4865
  }
4894
4866
 
4895
4867
  void OnOK() override {
4896
4868
  Napi::Env env = Env();
4897
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4869
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4898
4870
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4899
4871
  } else {
4900
4872
  Napi::Object obj = Napi::Object::New(env);
4901
4873
  obj.Set(Napi::String::New(env, "txFrequency"), Napi::Number::New(env, static_cast<double>(tx_freq_)));
4902
- obj.Set(Napi::String::New(env, "txMode"), Napi::String::New(env, rig_strrmode(tx_mode_)));
4874
+ obj.Set(Napi::String::New(env, "txMode"), Napi::String::New(env, shim_rig_strrmode(tx_mode_)));
4903
4875
  obj.Set(Napi::String::New(env, "txWidth"), Napi::Number::New(env, static_cast<double>(tx_width_)));
4904
4876
  deferred_.Resolve(obj);
4905
4877
  }
@@ -4911,30 +4883,30 @@ public:
4911
4883
  }
4912
4884
 
4913
4885
  private:
4914
- vfo_t vfo_;
4915
- freq_t tx_freq_;
4916
- rmode_t tx_mode_;
4917
- pbwidth_t tx_width_;
4886
+ int vfo_;
4887
+ double tx_freq_;
4888
+ int tx_mode_;
4889
+ int tx_width_;
4918
4890
  };
4919
4891
 
4920
4892
  // Reset Function AsyncWorker class
4921
4893
  class ResetAsyncWorker : public HamLibAsyncWorker {
4922
4894
  public:
4923
- ResetAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, reset_t reset)
4895
+ ResetAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, int reset)
4924
4896
  : HamLibAsyncWorker(env, hamlib_instance), reset_(reset) {}
4925
4897
 
4926
4898
  void Execute() override {
4927
4899
  CHECK_RIG_VALID();
4928
4900
 
4929
- result_code_ = rig_reset(hamlib_instance_->my_rig, reset_);
4930
- if (result_code_ != RIG_OK) {
4931
- error_message_ = rigerror(result_code_);
4901
+ result_code_ = shim_rig_reset(hamlib_instance_->my_rig, reset_);
4902
+ if (result_code_ != SHIM_RIG_OK) {
4903
+ error_message_ = shim_rigerror(result_code_);
4932
4904
  }
4933
4905
  }
4934
4906
 
4935
4907
  void OnOK() override {
4936
4908
  Napi::Env env = Env();
4937
- if (result_code_ != RIG_OK && !error_message_.empty()) {
4909
+ if (result_code_ != SHIM_RIG_OK && !error_message_.empty()) {
4938
4910
  deferred_.Reject(Napi::Error::New(env, error_message_).Value());
4939
4911
  } else {
4940
4912
  deferred_.Resolve(Napi::Number::New(env, result_code_));
@@ -4947,7 +4919,7 @@ public:
4947
4919
  }
4948
4920
 
4949
4921
  private:
4950
- reset_t reset_;
4922
+ int reset_;
4951
4923
  };
4952
4924
 
4953
4925
  // CTCSS/DCS Tone Control Methods Implementation
@@ -4959,8 +4931,8 @@ Napi::Value NodeHamLib::SetCtcssTone(const Napi::CallbackInfo& info) {
4959
4931
  return env.Null();
4960
4932
  }
4961
4933
 
4962
- tone_t tone = static_cast<tone_t>(info[0].As<Napi::Number>().Uint32Value());
4963
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
4934
+ unsigned int tone = static_cast<unsigned int>(info[0].As<Napi::Number>().Uint32Value());
4935
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
4964
4936
 
4965
4937
  SetCtcssToneAsyncWorker* asyncWorker = new SetCtcssToneAsyncWorker(env, this, vfo, tone);
4966
4938
  asyncWorker->Queue();
@@ -4970,7 +4942,7 @@ Napi::Value NodeHamLib::SetCtcssTone(const Napi::CallbackInfo& info) {
4970
4942
  Napi::Value NodeHamLib::GetCtcssTone(const Napi::CallbackInfo& info) {
4971
4943
  Napi::Env env = info.Env();
4972
4944
 
4973
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
4945
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
4974
4946
 
4975
4947
  GetCtcssToneAsyncWorker* asyncWorker = new GetCtcssToneAsyncWorker(env, this, vfo);
4976
4948
  asyncWorker->Queue();
@@ -4985,8 +4957,8 @@ Napi::Value NodeHamLib::SetDcsCode(const Napi::CallbackInfo& info) {
4985
4957
  return env.Null();
4986
4958
  }
4987
4959
 
4988
- tone_t code = static_cast<tone_t>(info[0].As<Napi::Number>().Uint32Value());
4989
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
4960
+ unsigned int code = static_cast<unsigned int>(info[0].As<Napi::Number>().Uint32Value());
4961
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
4990
4962
 
4991
4963
  SetDcsCodeAsyncWorker* asyncWorker = new SetDcsCodeAsyncWorker(env, this, vfo, code);
4992
4964
  asyncWorker->Queue();
@@ -4996,7 +4968,7 @@ Napi::Value NodeHamLib::SetDcsCode(const Napi::CallbackInfo& info) {
4996
4968
  Napi::Value NodeHamLib::GetDcsCode(const Napi::CallbackInfo& info) {
4997
4969
  Napi::Env env = info.Env();
4998
4970
 
4999
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
4971
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
5000
4972
 
5001
4973
  GetDcsCodeAsyncWorker* asyncWorker = new GetDcsCodeAsyncWorker(env, this, vfo);
5002
4974
  asyncWorker->Queue();
@@ -5011,8 +4983,8 @@ Napi::Value NodeHamLib::SetCtcssSql(const Napi::CallbackInfo& info) {
5011
4983
  return env.Null();
5012
4984
  }
5013
4985
 
5014
- tone_t tone = static_cast<tone_t>(info[0].As<Napi::Number>().Uint32Value());
5015
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
4986
+ unsigned int tone = static_cast<unsigned int>(info[0].As<Napi::Number>().Uint32Value());
4987
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
5016
4988
 
5017
4989
  SetCtcssSqlAsyncWorker* asyncWorker = new SetCtcssSqlAsyncWorker(env, this, vfo, tone);
5018
4990
  asyncWorker->Queue();
@@ -5022,7 +4994,7 @@ Napi::Value NodeHamLib::SetCtcssSql(const Napi::CallbackInfo& info) {
5022
4994
  Napi::Value NodeHamLib::GetCtcssSql(const Napi::CallbackInfo& info) {
5023
4995
  Napi::Env env = info.Env();
5024
4996
 
5025
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
4997
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
5026
4998
 
5027
4999
  GetCtcssSqlAsyncWorker* asyncWorker = new GetCtcssSqlAsyncWorker(env, this, vfo);
5028
5000
  asyncWorker->Queue();
@@ -5037,8 +5009,8 @@ Napi::Value NodeHamLib::SetDcsSql(const Napi::CallbackInfo& info) {
5037
5009
  return env.Null();
5038
5010
  }
5039
5011
 
5040
- tone_t code = static_cast<tone_t>(info[0].As<Napi::Number>().Uint32Value());
5041
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
5012
+ unsigned int code = static_cast<unsigned int>(info[0].As<Napi::Number>().Uint32Value());
5013
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
5042
5014
 
5043
5015
  SetDcsSqlAsyncWorker* asyncWorker = new SetDcsSqlAsyncWorker(env, this, vfo, code);
5044
5016
  asyncWorker->Queue();
@@ -5048,7 +5020,7 @@ Napi::Value NodeHamLib::SetDcsSql(const Napi::CallbackInfo& info) {
5048
5020
  Napi::Value NodeHamLib::GetDcsSql(const Napi::CallbackInfo& info) {
5049
5021
  Napi::Env env = info.Env();
5050
5022
 
5051
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
5023
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
5052
5024
 
5053
5025
  GetDcsSqlAsyncWorker* asyncWorker = new GetDcsSqlAsyncWorker(env, this, vfo);
5054
5026
  asyncWorker->Queue();
@@ -5065,16 +5037,15 @@ Napi::Value NodeHamLib::SetParm(const Napi::CallbackInfo& info) {
5065
5037
  }
5066
5038
 
5067
5039
  std::string parm_str = info[0].As<Napi::String>().Utf8Value();
5068
- setting_t parm = rig_parse_parm(parm_str.c_str());
5040
+ uint64_t parm = shim_rig_parse_parm(parm_str.c_str());
5069
5041
 
5070
5042
  if (parm == 0) {
5071
5043
  Napi::Error::New(env, "Invalid parameter name: " + parm_str).ThrowAsJavaScriptException();
5072
5044
  return env.Null();
5073
5045
  }
5074
5046
 
5075
- value_t value;
5076
- value.f = info[1].As<Napi::Number>().FloatValue();
5077
-
5047
+ float value = info[1].As<Napi::Number>().FloatValue();
5048
+
5078
5049
  SetParmAsyncWorker* asyncWorker = new SetParmAsyncWorker(env, this, parm, value);
5079
5050
  asyncWorker->Queue();
5080
5051
  return asyncWorker->GetPromise();
@@ -5089,7 +5060,7 @@ Napi::Value NodeHamLib::GetParm(const Napi::CallbackInfo& info) {
5089
5060
  }
5090
5061
 
5091
5062
  std::string parm_str = info[0].As<Napi::String>().Utf8Value();
5092
- setting_t parm = rig_parse_parm(parm_str.c_str());
5063
+ uint64_t parm = shim_rig_parse_parm(parm_str.c_str());
5093
5064
 
5094
5065
  if (parm == 0) {
5095
5066
  Napi::Error::New(env, "Invalid parameter name: " + parm_str).ThrowAsJavaScriptException();
@@ -5111,7 +5082,7 @@ Napi::Value NodeHamLib::SendDtmf(const Napi::CallbackInfo& info) {
5111
5082
  }
5112
5083
 
5113
5084
  std::string digits = info[0].As<Napi::String>().Utf8Value();
5114
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
5085
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
5115
5086
 
5116
5087
  SendDtmfAsyncWorker* asyncWorker = new SendDtmfAsyncWorker(env, this, vfo, digits);
5117
5088
  asyncWorker->Queue();
@@ -5126,7 +5097,7 @@ Napi::Value NodeHamLib::RecvDtmf(const Napi::CallbackInfo& info) {
5126
5097
  maxLength = info[0].As<Napi::Number>().Int32Value();
5127
5098
  }
5128
5099
 
5129
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
5100
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
5130
5101
 
5131
5102
  RecvDtmfAsyncWorker* asyncWorker = new RecvDtmfAsyncWorker(env, this, vfo, maxLength);
5132
5103
  asyncWorker->Queue();
@@ -5137,7 +5108,7 @@ Napi::Value NodeHamLib::RecvDtmf(const Napi::CallbackInfo& info) {
5137
5108
  Napi::Value NodeHamLib::GetMem(const Napi::CallbackInfo& info) {
5138
5109
  Napi::Env env = info.Env();
5139
5110
 
5140
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
5111
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
5141
5112
 
5142
5113
  GetMemAsyncWorker* asyncWorker = new GetMemAsyncWorker(env, this, vfo);
5143
5114
  asyncWorker->Queue();
@@ -5153,7 +5124,7 @@ Napi::Value NodeHamLib::SetBank(const Napi::CallbackInfo& info) {
5153
5124
  }
5154
5125
 
5155
5126
  int bank = info[0].As<Napi::Number>().Int32Value();
5156
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
5127
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
5157
5128
 
5158
5129
  SetBankAsyncWorker* asyncWorker = new SetBankAsyncWorker(env, this, vfo, bank);
5159
5130
  asyncWorker->Queue();
@@ -5178,7 +5149,7 @@ Napi::Value NodeHamLib::SendMorse(const Napi::CallbackInfo& info) {
5178
5149
  }
5179
5150
 
5180
5151
  std::string msg = info[0].As<Napi::String>().Utf8Value();
5181
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
5152
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
5182
5153
 
5183
5154
  SendMorseAsyncWorker* asyncWorker = new SendMorseAsyncWorker(env, this, vfo, msg);
5184
5155
  asyncWorker->Queue();
@@ -5188,7 +5159,7 @@ Napi::Value NodeHamLib::SendMorse(const Napi::CallbackInfo& info) {
5188
5159
  Napi::Value NodeHamLib::StopMorse(const Napi::CallbackInfo& info) {
5189
5160
  Napi::Env env = info.Env();
5190
5161
 
5191
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
5162
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
5192
5163
 
5193
5164
  StopMorseAsyncWorker* asyncWorker = new StopMorseAsyncWorker(env, this, vfo);
5194
5165
  asyncWorker->Queue();
@@ -5198,7 +5169,7 @@ Napi::Value NodeHamLib::StopMorse(const Napi::CallbackInfo& info) {
5198
5169
  Napi::Value NodeHamLib::WaitMorse(const Napi::CallbackInfo& info) {
5199
5170
  Napi::Env env = info.Env();
5200
5171
 
5201
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
5172
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
5202
5173
 
5203
5174
  WaitMorseAsyncWorker* asyncWorker = new WaitMorseAsyncWorker(env, this, vfo);
5204
5175
  asyncWorker->Queue();
@@ -5215,7 +5186,7 @@ Napi::Value NodeHamLib::SendVoiceMem(const Napi::CallbackInfo& info) {
5215
5186
  }
5216
5187
 
5217
5188
  int ch = info[0].As<Napi::Number>().Int32Value();
5218
- vfo_t vfo = parseVfoParameter(info, 1, RIG_VFO_CURR);
5189
+ int vfo = parseVfoParameter(info, 1, SHIM_RIG_VFO_CURR);
5219
5190
 
5220
5191
  SendVoiceMemAsyncWorker* asyncWorker = new SendVoiceMemAsyncWorker(env, this, vfo, ch);
5221
5192
  asyncWorker->Queue();
@@ -5225,7 +5196,7 @@ Napi::Value NodeHamLib::SendVoiceMem(const Napi::CallbackInfo& info) {
5225
5196
  Napi::Value NodeHamLib::StopVoiceMem(const Napi::CallbackInfo& info) {
5226
5197
  Napi::Env env = info.Env();
5227
5198
 
5228
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
5199
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
5229
5200
 
5230
5201
  StopVoiceMemAsyncWorker* asyncWorker = new StopVoiceMemAsyncWorker(env, this, vfo);
5231
5202
  asyncWorker->Queue();
@@ -5241,7 +5212,7 @@ Napi::Value NodeHamLib::SetSplitFreqMode(const Napi::CallbackInfo& info) {
5241
5212
  return env.Null();
5242
5213
  }
5243
5214
 
5244
- freq_t tx_freq = static_cast<freq_t>(info[0].As<Napi::Number>().DoubleValue());
5215
+ double tx_freq = static_cast<double>(info[0].As<Napi::Number>().DoubleValue());
5245
5216
 
5246
5217
  // Basic frequency range validation
5247
5218
  if (tx_freq < 1000 || tx_freq > 10000000000) { // 1 kHz to 10 GHz reasonable range
@@ -5250,11 +5221,11 @@ Napi::Value NodeHamLib::SetSplitFreqMode(const Napi::CallbackInfo& info) {
5250
5221
  }
5251
5222
 
5252
5223
  std::string mode_str = info[1].As<Napi::String>().Utf8Value();
5253
- pbwidth_t tx_width = static_cast<pbwidth_t>(info[2].As<Napi::Number>().DoubleValue());
5254
- vfo_t vfo = parseVfoParameter(info, 3, RIG_VFO_CURR);
5224
+ int tx_width = static_cast<int>(info[2].As<Napi::Number>().DoubleValue());
5225
+ int vfo = parseVfoParameter(info, 3, SHIM_RIG_VFO_CURR);
5255
5226
 
5256
- rmode_t tx_mode = rig_parse_mode(mode_str.c_str());
5257
- if (tx_mode == RIG_MODE_NONE) {
5227
+ int tx_mode = shim_rig_parse_mode(mode_str.c_str());
5228
+ if (tx_mode == SHIM_RIG_MODE_NONE) {
5258
5229
  Napi::Error::New(env, "Invalid mode: " + mode_str).ThrowAsJavaScriptException();
5259
5230
  return env.Null();
5260
5231
  }
@@ -5267,7 +5238,7 @@ Napi::Value NodeHamLib::SetSplitFreqMode(const Napi::CallbackInfo& info) {
5267
5238
  Napi::Value NodeHamLib::GetSplitFreqMode(const Napi::CallbackInfo& info) {
5268
5239
  Napi::Env env = info.Env();
5269
5240
 
5270
- vfo_t vfo = parseVfoParameter(info, 0, RIG_VFO_CURR);
5241
+ int vfo = parseVfoParameter(info, 0, SHIM_RIG_VFO_CURR);
5271
5242
 
5272
5243
  GetSplitFreqModeAsyncWorker* asyncWorker = new GetSplitFreqModeAsyncWorker(env, this, vfo);
5273
5244
  asyncWorker->Queue();
@@ -5289,7 +5260,7 @@ Napi::Value NodeHamLib::Power2mW(const Napi::CallbackInfo& info) {
5289
5260
  }
5290
5261
 
5291
5262
  float power = info[0].As<Napi::Number>().FloatValue();
5292
- freq_t freq = info[1].As<Napi::Number>().DoubleValue();
5263
+ double freq = info[1].As<Napi::Number>().DoubleValue();
5293
5264
  std::string mode_str = info[2].As<Napi::String>().Utf8Value();
5294
5265
 
5295
5266
  // Validate power (0.0 to 1.0)
@@ -5305,8 +5276,8 @@ Napi::Value NodeHamLib::Power2mW(const Napi::CallbackInfo& info) {
5305
5276
  }
5306
5277
 
5307
5278
  // Parse mode string
5308
- rmode_t mode = rig_parse_mode(mode_str.c_str());
5309
- if (mode == RIG_MODE_NONE) {
5279
+ int mode = shim_rig_parse_mode(mode_str.c_str());
5280
+ if (mode == SHIM_RIG_MODE_NONE) {
5310
5281
  Napi::Error::New(env, "Invalid mode: " + mode_str).ThrowAsJavaScriptException();
5311
5282
  return env.Null();
5312
5283
  }
@@ -5331,7 +5302,7 @@ Napi::Value NodeHamLib::MW2Power(const Napi::CallbackInfo& info) {
5331
5302
  }
5332
5303
 
5333
5304
  unsigned int mwpower = info[0].As<Napi::Number>().Uint32Value();
5334
- freq_t freq = info[1].As<Napi::Number>().DoubleValue();
5305
+ double freq = info[1].As<Napi::Number>().DoubleValue();
5335
5306
  std::string mode_str = info[2].As<Napi::String>().Utf8Value();
5336
5307
 
5337
5308
  // Validate milliwatts (reasonable range)
@@ -5347,8 +5318,8 @@ Napi::Value NodeHamLib::MW2Power(const Napi::CallbackInfo& info) {
5347
5318
  }
5348
5319
 
5349
5320
  // Parse mode string
5350
- rmode_t mode = rig_parse_mode(mode_str.c_str());
5351
- if (mode == RIG_MODE_NONE) {
5321
+ int mode = shim_rig_parse_mode(mode_str.c_str());
5322
+ if (mode == SHIM_RIG_MODE_NONE) {
5352
5323
  Napi::Error::New(env, "Invalid mode: " + mode_str).ThrowAsJavaScriptException();
5353
5324
  return env.Null();
5354
5325
  }
@@ -5362,20 +5333,20 @@ Napi::Value NodeHamLib::MW2Power(const Napi::CallbackInfo& info) {
5362
5333
  Napi::Value NodeHamLib::Reset(const Napi::CallbackInfo& info) {
5363
5334
  Napi::Env env = info.Env();
5364
5335
 
5365
- reset_t reset = RIG_RESET_SOFT; // Default to soft reset
5336
+ int reset = SHIM_RIG_RESET_SOFT; // Default to soft reset
5366
5337
 
5367
5338
  if (info.Length() > 0 && info[0].IsString()) {
5368
5339
  std::string reset_str = info[0].As<Napi::String>().Utf8Value();
5369
5340
  if (reset_str == "NONE") {
5370
- reset = RIG_RESET_NONE;
5341
+ reset = SHIM_RIG_RESET_NONE;
5371
5342
  } else if (reset_str == "SOFT") {
5372
- reset = RIG_RESET_SOFT;
5343
+ reset = SHIM_RIG_RESET_SOFT;
5373
5344
  } else if (reset_str == "MCALL") {
5374
- reset = RIG_RESET_MCALL;
5345
+ reset = SHIM_RIG_RESET_MCALL;
5375
5346
  } else if (reset_str == "MASTER") {
5376
- reset = RIG_RESET_MASTER;
5347
+ reset = SHIM_RIG_RESET_MASTER;
5377
5348
  } else if (reset_str == "VFO") {
5378
- reset = RIG_RESET_VFO;
5349
+ reset = SHIM_RIG_RESET_VFO;
5379
5350
  } else {
5380
5351
  Napi::Error::New(env, "Invalid reset type: " + reset_str +
5381
5352
  " (valid: NONE, SOFT, VFO, MCALL, MASTER)").ThrowAsJavaScriptException();