hamlib 0.1.4 → 0.1.6

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,6 +1,17 @@
1
1
  #include "hamlib.h"
2
2
  #include <string>
3
3
  #include <vector>
4
+ #include <memory>
5
+
6
+ // Cross-platform compatibility for hamlib token types
7
+ // Linux versions use token_t, some others use hamlib_token_t
8
+ #ifndef HAMLIB_TOKEN_T
9
+ #ifdef __linux__
10
+ #define HAMLIB_TOKEN_T token_t
11
+ #else
12
+ #define HAMLIB_TOKEN_T hamlib_token_t
13
+ #endif
14
+ #endif
4
15
 
5
16
  // Structure to hold rig information for the callback
6
17
  struct RigListData {
@@ -13,6 +24,311 @@ using namespace Napi;
13
24
  Napi::FunctionReference NodeHamLib::constructor;
14
25
  Napi::ThreadSafeFunction tsfn;
15
26
 
27
+ // Base AsyncWorker implementation
28
+ HamLibAsyncWorker::HamLibAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance)
29
+ : AsyncWorker(callback), hamlib_instance_(hamlib_instance), result_code_(0), error_message_("") {}
30
+
31
+ // Specific AsyncWorker classes for each operation
32
+ class OpenAsyncWorker : public HamLibAsyncWorker {
33
+ public:
34
+ OpenAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance)
35
+ : HamLibAsyncWorker(callback, hamlib_instance) {}
36
+
37
+ void Execute() override {
38
+ result_code_ = rig_open(hamlib_instance_->my_rig);
39
+ if (result_code_ != RIG_OK) {
40
+ error_message_ = rigerror(result_code_);
41
+ } else {
42
+ rig_set_freq_callback(hamlib_instance_->my_rig, NodeHamLib::freq_change_cb, hamlib_instance_);
43
+ auto ppt_cb = +[](RIG *rig, vfo_t vfo, ptt_t ptt, rig_ptr_t arg) {
44
+ printf("PPT pushed!");
45
+ return 0;
46
+ };
47
+ int cb_result = rig_set_ptt_callback(hamlib_instance_->my_rig, ppt_cb, NULL);
48
+ rig_set_trn(hamlib_instance_->my_rig, RIG_TRN_POLL);
49
+ hamlib_instance_->rig_is_open = true;
50
+ }
51
+ }
52
+
53
+ void OnOK() override {
54
+ Napi::Env env = Env();
55
+ Callback().Call({env.Undefined(), Napi::Number::New(env, result_code_)});
56
+ }
57
+
58
+ void OnError(const Napi::Error& e) override {
59
+ Napi::Env env = Env();
60
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
61
+ }
62
+ };
63
+
64
+ class SetFrequencyAsyncWorker : public HamLibAsyncWorker {
65
+ public:
66
+ SetFrequencyAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance, freq_t freq, vfo_t vfo)
67
+ : HamLibAsyncWorker(callback, hamlib_instance), freq_(freq), vfo_(vfo) {}
68
+
69
+ void Execute() override {
70
+ result_code_ = rig_set_freq(hamlib_instance_->my_rig, vfo_, freq_);
71
+ if (result_code_ != RIG_OK) {
72
+ error_message_ = rigerror(result_code_);
73
+ }
74
+ }
75
+
76
+ void OnOK() override {
77
+ Napi::Env env = Env();
78
+ Callback().Call({env.Undefined(), Napi::Number::New(env, result_code_)});
79
+ }
80
+
81
+ void OnError(const Napi::Error& e) override {
82
+ Napi::Env env = Env();
83
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
84
+ }
85
+
86
+ private:
87
+ freq_t freq_;
88
+ vfo_t vfo_;
89
+ };
90
+
91
+ class GetFrequencyAsyncWorker : public HamLibAsyncWorker {
92
+ public:
93
+ GetFrequencyAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance, vfo_t vfo)
94
+ : HamLibAsyncWorker(callback, hamlib_instance), vfo_(vfo), freq_(0) {}
95
+
96
+ void Execute() override {
97
+ result_code_ = rig_get_freq(hamlib_instance_->my_rig, vfo_, &freq_);
98
+ if (result_code_ != RIG_OK) {
99
+ error_message_ = rigerror(result_code_);
100
+ }
101
+ }
102
+
103
+ void OnOK() override {
104
+ Napi::Env env = Env();
105
+ Callback().Call({env.Undefined(), Napi::Number::New(env, freq_)});
106
+ }
107
+
108
+ void OnError(const Napi::Error& e) override {
109
+ Napi::Env env = Env();
110
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
111
+ }
112
+
113
+ private:
114
+ vfo_t vfo_;
115
+ freq_t freq_;
116
+ };
117
+
118
+ class SetModeAsyncWorker : public HamLibAsyncWorker {
119
+ public:
120
+ SetModeAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance, rmode_t mode, pbwidth_t width)
121
+ : HamLibAsyncWorker(callback, hamlib_instance), mode_(mode), width_(width) {}
122
+
123
+ void Execute() override {
124
+ result_code_ = rig_set_mode(hamlib_instance_->my_rig, RIG_VFO_CURR, mode_, width_);
125
+ if (result_code_ != RIG_OK) {
126
+ error_message_ = rigerror(result_code_);
127
+ }
128
+ }
129
+
130
+ void OnOK() override {
131
+ Napi::Env env = Env();
132
+ Callback().Call({env.Undefined(), Napi::Number::New(env, result_code_)});
133
+ }
134
+
135
+ void OnError(const Napi::Error& e) override {
136
+ Napi::Env env = Env();
137
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
138
+ }
139
+
140
+ private:
141
+ rmode_t mode_;
142
+ pbwidth_t width_;
143
+ };
144
+
145
+ class GetModeAsyncWorker : public HamLibAsyncWorker {
146
+ public:
147
+ GetModeAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance)
148
+ : HamLibAsyncWorker(callback, hamlib_instance), mode_(0), width_(0) {}
149
+
150
+ void Execute() override {
151
+ result_code_ = rig_get_mode(hamlib_instance_->my_rig, RIG_VFO_CURR, &mode_, &width_);
152
+ if (result_code_ != RIG_OK) {
153
+ error_message_ = rigerror(result_code_);
154
+ }
155
+ }
156
+
157
+ void OnOK() override {
158
+ Napi::Env env = Env();
159
+ Napi::Object obj = Napi::Object::New(env);
160
+ obj.Set(Napi::String::New(env, "mode"), (char)mode_);
161
+ obj.Set(Napi::String::New(env, "width"), width_);
162
+ Callback().Call({env.Undefined(), obj});
163
+ }
164
+
165
+ void OnError(const Napi::Error& e) override {
166
+ Napi::Env env = Env();
167
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
168
+ }
169
+
170
+ private:
171
+ rmode_t mode_;
172
+ pbwidth_t width_;
173
+ };
174
+
175
+ class SetPttAsyncWorker : public HamLibAsyncWorker {
176
+ public:
177
+ SetPttAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance, ptt_t ptt)
178
+ : HamLibAsyncWorker(callback, hamlib_instance), ptt_(ptt) {}
179
+
180
+ void Execute() override {
181
+ result_code_ = rig_set_ptt(hamlib_instance_->my_rig, RIG_VFO_CURR, ptt_);
182
+ if (result_code_ != RIG_OK) {
183
+ error_message_ = rigerror(result_code_);
184
+ }
185
+ }
186
+
187
+ void OnOK() override {
188
+ Napi::Env env = Env();
189
+ Callback().Call({env.Undefined(), Napi::Number::New(env, result_code_)});
190
+ }
191
+
192
+ void OnError(const Napi::Error& e) override {
193
+ Napi::Env env = Env();
194
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
195
+ }
196
+
197
+ private:
198
+ ptt_t ptt_;
199
+ };
200
+
201
+ class GetStrengthAsyncWorker : public HamLibAsyncWorker {
202
+ public:
203
+ GetStrengthAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance)
204
+ : HamLibAsyncWorker(callback, hamlib_instance), strength_(0) {}
205
+
206
+ void Execute() override {
207
+ result_code_ = rig_get_strength(hamlib_instance_->my_rig, RIG_VFO_CURR, &strength_);
208
+ if (result_code_ != RIG_OK) {
209
+ error_message_ = rigerror(result_code_);
210
+ }
211
+ }
212
+
213
+ void OnOK() override {
214
+ Napi::Env env = Env();
215
+ Callback().Call({env.Undefined(), Napi::Number::New(env, strength_)});
216
+ }
217
+
218
+ void OnError(const Napi::Error& e) override {
219
+ Napi::Env env = Env();
220
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
221
+ }
222
+
223
+ private:
224
+ int strength_;
225
+ };
226
+
227
+ class SetVfoAsyncWorker : public HamLibAsyncWorker {
228
+ public:
229
+ SetVfoAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance, vfo_t vfo)
230
+ : HamLibAsyncWorker(callback, hamlib_instance), vfo_(vfo) {}
231
+
232
+ void Execute() override {
233
+ result_code_ = rig_set_vfo(hamlib_instance_->my_rig, vfo_);
234
+ if (result_code_ != RIG_OK) {
235
+ error_message_ = rigerror(result_code_);
236
+ }
237
+ }
238
+
239
+ void OnOK() override {
240
+ Napi::Env env = Env();
241
+ Callback().Call({env.Undefined(), Napi::Number::New(env, result_code_)});
242
+ }
243
+
244
+ void OnError(const Napi::Error& e) override {
245
+ Napi::Env env = Env();
246
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
247
+ }
248
+
249
+ private:
250
+ vfo_t vfo_;
251
+ };
252
+
253
+ class GetVfoAsyncWorker : public HamLibAsyncWorker {
254
+ public:
255
+ GetVfoAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance)
256
+ : HamLibAsyncWorker(callback, hamlib_instance), vfo_(0) {}
257
+
258
+ void Execute() override {
259
+ result_code_ = rig_get_vfo(hamlib_instance_->my_rig, &vfo_);
260
+ if (result_code_ != RIG_OK) {
261
+ error_message_ = rigerror(result_code_);
262
+ }
263
+ }
264
+
265
+ void OnOK() override {
266
+ Napi::Env env = Env();
267
+ Callback().Call({env.Undefined(), Napi::Number::New(env, vfo_)});
268
+ }
269
+
270
+ void OnError(const Napi::Error& e) override {
271
+ Napi::Env env = Env();
272
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
273
+ }
274
+
275
+ private:
276
+ vfo_t vfo_;
277
+ };
278
+
279
+ class CloseAsyncWorker : public HamLibAsyncWorker {
280
+ public:
281
+ CloseAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance)
282
+ : HamLibAsyncWorker(callback, hamlib_instance) {}
283
+
284
+ void Execute() override {
285
+ result_code_ = rig_close(hamlib_instance_->my_rig);
286
+ if (result_code_ != RIG_OK) {
287
+ error_message_ = rigerror(result_code_);
288
+ } else {
289
+ hamlib_instance_->rig_is_open = false;
290
+ }
291
+ }
292
+
293
+ void OnOK() override {
294
+ Napi::Env env = Env();
295
+ Callback().Call({env.Undefined(), Napi::Number::New(env, result_code_)});
296
+ }
297
+
298
+ void OnError(const Napi::Error& e) override {
299
+ Napi::Env env = Env();
300
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
301
+ }
302
+ };
303
+
304
+ class DestroyAsyncWorker : public HamLibAsyncWorker {
305
+ public:
306
+ DestroyAsyncWorker(Napi::Function& callback, NodeHamLib* hamlib_instance)
307
+ : HamLibAsyncWorker(callback, hamlib_instance) {}
308
+
309
+ void Execute() override {
310
+ if (hamlib_instance_->rig_is_open) {
311
+ rig_close(hamlib_instance_->my_rig);
312
+ }
313
+ result_code_ = rig_cleanup(hamlib_instance_->my_rig);
314
+ if (result_code_ != RIG_OK) {
315
+ error_message_ = rigerror(result_code_);
316
+ } else {
317
+ hamlib_instance_->rig_is_open = false;
318
+ }
319
+ }
320
+
321
+ void OnOK() override {
322
+ Napi::Env env = Env();
323
+ Callback().Call({env.Undefined(), Napi::Number::New(env, result_code_)});
324
+ }
325
+
326
+ void OnError(const Napi::Error& e) override {
327
+ Napi::Env env = Env();
328
+ Callback().Call({Napi::Error::New(env, error_message_).Value(), env.Undefined()});
329
+ }
330
+ };
331
+
16
332
  NodeHamLib::NodeHamLib(const Napi::CallbackInfo & info): ObjectWrap(info) {
17
333
  Napi::Env env = info.Env();
18
334
  this->m_currentInfo = (Napi::CallbackInfo *)&info;
@@ -116,73 +432,76 @@ int NodeHamLib::freq_change_cb(RIG *rig, vfo_t vfo, freq_t freq, void* arg) {
116
432
  Napi::Value NodeHamLib::Open(const Napi::CallbackInfo & info) {
117
433
  Napi::Env env = info.Env();
118
434
 
119
- int retcode = rig_open(my_rig);
120
- if (retcode != RIG_OK) {
121
- printf("rig_open: error = %s\n", rigerror(retcode));
122
- // Napi::TypeError::New(env, "Unable to open rig")
123
- // .ThrowAsJavaScriptException();
435
+ if (info.Length() < 1 || !info[0].IsFunction()) {
436
+ Napi::TypeError::New(env, "Callback function is required").ThrowAsJavaScriptException();
437
+ return env.Undefined();
124
438
  }
125
-
126
-
127
-
128
- rig_set_freq_callback(my_rig, NodeHamLib::freq_change_cb, this);
129
-
130
- auto ppt_cb =+[](RIG *rig, vfo_t vfo, ptt_t ptt, rig_ptr_t arg) {
131
- printf("PPT pushed!");
132
- return 0;
133
- };
134
- retcode = rig_set_ptt_callback (my_rig, ppt_cb, NULL);
135
- rig_set_trn(my_rig, RIG_TRN_POLL);
136
- if (retcode != RIG_OK ) {
137
- printf("rig_set_trn: error = %s \n", rigerror(retcode));
138
- }
139
-
140
- printf ("callback: %s", rigerror(retcode));
141
-
142
- rig_is_open = true;
143
- return Napi::Number::New(env, retcode);
439
+
440
+ Napi::Function callback = info[0].As<Napi::Function>();
441
+ OpenAsyncWorker* worker = new OpenAsyncWorker(callback, this);
442
+ worker->Queue();
443
+
444
+ return env.Undefined();
144
445
  }
145
446
 
146
447
  Napi::Value NodeHamLib::SetVFO(const Napi::CallbackInfo & info) {
147
448
  Napi::Env env = info.Env();
148
- int retcode;
149
449
 
150
450
  if (!rig_is_open) {
151
451
  Napi::TypeError::New(env, "Rig is not open!")
152
452
  .ThrowAsJavaScriptException();
153
453
  return env.Null();
154
454
  }
155
- if (info.Length() < 1) {
156
- Napi::TypeError::New(env, "Must Specify VFO-A or VFO-B")
455
+
456
+ if (info.Length() < 2) {
457
+ Napi::TypeError::New(env, "Must specify VFO and callback")
157
458
  .ThrowAsJavaScriptException();
158
459
  return env.Null();
159
460
  }
461
+
160
462
  if (!info[0].IsString()) {
161
- Napi::TypeError::New(env, "Must Specify VFO-A or VFO-B as a string")
463
+ Napi::TypeError::New(env, "Must specify VFO-A or VFO-B as a string")
464
+ .ThrowAsJavaScriptException();
465
+ return env.Null();
466
+ }
467
+
468
+ if (!info[1].IsFunction()) {
469
+ Napi::TypeError::New(env, "Second parameter must be callback function")
162
470
  .ThrowAsJavaScriptException();
163
471
  return env.Null();
164
472
  }
473
+
165
474
  auto name = info[0].As < Napi::String > ().Utf8Value().c_str();
475
+ vfo_t vfo;
476
+
166
477
  if (strcmp(name, "VFO-A") == 0) {
167
- retcode = rig_set_vfo(my_rig, RIG_VFO_A);
478
+ vfo = RIG_VFO_A;
168
479
  } else if (strcmp(name, "VFO-B") == 0) {
169
- retcode = rig_set_vfo(my_rig, RIG_VFO_B);
480
+ vfo = RIG_VFO_B;
170
481
  } else {
171
- retcode = 1;
482
+ Napi::TypeError::New(env, "Invalid VFO name")
483
+ .ThrowAsJavaScriptException();
484
+ return env.Null();
172
485
  }
173
- return Napi::Number::New(env, retcode);
486
+
487
+ Napi::Function callback = info[1].As<Napi::Function>();
488
+ SetVfoAsyncWorker* worker = new SetVfoAsyncWorker(callback, this, vfo);
489
+ worker->Queue();
490
+
491
+ return env.Undefined();
174
492
  }
175
493
 
176
494
  Napi::Value NodeHamLib::SetFrequency(const Napi::CallbackInfo & info) {
177
495
  Napi::Env env = info.Env();
178
- int retcode;
496
+
179
497
  if (!rig_is_open) {
180
498
  Napi::TypeError::New(env, "Rig is not open!")
181
499
  .ThrowAsJavaScriptException();
182
500
  return env.Null();
183
501
  }
184
- if (info.Length() < 1) {
185
- Napi::TypeError::New(env, "Must specify frequency")
502
+
503
+ if (info.Length() < 2) {
504
+ Napi::TypeError::New(env, "Must specify frequency and callback")
186
505
  .ThrowAsJavaScriptException();
187
506
  return env.Null();
188
507
  }
@@ -192,134 +511,161 @@ Napi::Value NodeHamLib::SetFrequency(const Napi::CallbackInfo & info) {
192
511
  .ThrowAsJavaScriptException();
193
512
  return env.Null();
194
513
  }
514
+
195
515
  auto freq = info[0].As < Napi::Number > ().Int32Value();
196
516
 
197
517
  // Support optional VFO parameter
198
518
  vfo_t vfo = RIG_VFO_CURR;
199
- if (info.Length() >= 2 && info[1].IsString()) {
200
- auto vfostr = info[1].As < Napi::String > ().Utf8Value().c_str();
201
- if (strcmp(vfostr, "VFO-A") == 0) {
202
- vfo = RIG_VFO_A;
203
- } else if (strcmp(vfostr, "VFO-B") == 0) {
204
- vfo = RIG_VFO_B;
519
+ Napi::Function callback;
520
+
521
+ if (info.Length() == 2) {
522
+ if (!info[1].IsFunction()) {
523
+ Napi::TypeError::New(env, "Second parameter must be callback function")
524
+ .ThrowAsJavaScriptException();
525
+ return env.Null();
526
+ }
527
+ callback = info[1].As<Napi::Function>();
528
+ } else if (info.Length() == 3) {
529
+ if (info[1].IsString()) {
530
+ auto vfostr = info[1].As < Napi::String > ().Utf8Value().c_str();
531
+ if (strcmp(vfostr, "VFO-A") == 0) {
532
+ vfo = RIG_VFO_A;
533
+ } else if (strcmp(vfostr, "VFO-B") == 0) {
534
+ vfo = RIG_VFO_B;
535
+ }
205
536
  }
537
+ if (!info[2].IsFunction()) {
538
+ Napi::TypeError::New(env, "Third parameter must be callback function")
539
+ .ThrowAsJavaScriptException();
540
+ return env.Null();
541
+ }
542
+ callback = info[2].As<Napi::Function>();
206
543
  }
207
544
 
208
- retcode = rig_set_freq(my_rig, vfo, freq);
209
- return Napi::Number::New(env, retcode);
545
+ SetFrequencyAsyncWorker* worker = new SetFrequencyAsyncWorker(callback, this, freq, vfo);
546
+ worker->Queue();
547
+
548
+ return env.Undefined();
210
549
  }
211
550
 
212
551
  Napi::Value NodeHamLib::SetMode(const Napi::CallbackInfo & info) {
213
552
  Napi::Env env = info.Env();
214
- int retcode;
215
- pbwidth_t bandwidth;
553
+
216
554
  if (!rig_is_open) {
217
555
  Napi::TypeError::New(env, "Rig is not open!")
218
556
  .ThrowAsJavaScriptException();
219
557
  return env.Null();
220
558
  }
221
- if (info.Length() < 1) {
222
- Napi::TypeError::New(env, "Must Specify Mode")
559
+
560
+ if (info.Length() < 2) {
561
+ Napi::TypeError::New(env, "Must specify mode and callback")
223
562
  .ThrowAsJavaScriptException();
224
563
  return env.Null();
225
564
  }
226
565
 
227
566
  if (!info[0].IsString()) {
228
- Napi::TypeError::New(env, "Must Specify Mode as string")
567
+ Napi::TypeError::New(env, "Must specify mode as string")
229
568
  .ThrowAsJavaScriptException();
230
569
  return env.Null();
231
570
  }
232
571
 
233
572
  auto modestr = info[0].As < Napi::String > ().Utf8Value().c_str();
234
573
  auto mode = rig_parse_mode(modestr);
574
+ pbwidth_t bandwidth = RIG_PASSBAND_NORMAL;
575
+ Napi::Function callback;
235
576
 
236
- if (info.Length() > 1) {
237
- if (!info[1].IsString()) {
238
- Napi::TypeError::New(env, "Must Specify Mode as string")
577
+ if (info.Length() == 2) {
578
+ if (!info[1].IsFunction()) {
579
+ Napi::TypeError::New(env, "Second parameter must be callback function")
239
580
  .ThrowAsJavaScriptException();
240
581
  return env.Null();
241
582
  }
242
- auto bandstr = info[1].As < Napi::String > ().Utf8Value().c_str();
243
- if (strcmp(bandstr, "narrow") == 0) {
244
- bandwidth = rig_passband_narrow(my_rig, mode);
245
- } else if (strcmp(bandstr, "wide") == 0) {
246
- bandwidth = rig_passband_wide(my_rig, mode);
247
- } else {
248
- bandwidth = RIG_PASSBAND_NORMAL;
583
+ callback = info[1].As<Napi::Function>();
584
+ } else if (info.Length() == 3) {
585
+ if (info[1].IsString()) {
586
+ auto bandstr = info[1].As < Napi::String > ().Utf8Value().c_str();
587
+ if (strcmp(bandstr, "narrow") == 0) {
588
+ bandwidth = rig_passband_narrow(my_rig, mode);
589
+ } else if (strcmp(bandstr, "wide") == 0) {
590
+ bandwidth = rig_passband_wide(my_rig, mode);
591
+ }
249
592
  }
250
- } else {
251
- bandwidth = RIG_PASSBAND_NORMAL;
593
+ if (!info[2].IsFunction()) {
594
+ Napi::TypeError::New(env, "Third parameter must be callback function")
595
+ .ThrowAsJavaScriptException();
596
+ return env.Null();
597
+ }
598
+ callback = info[2].As<Napi::Function>();
252
599
  }
253
600
 
254
- retcode = rig_set_mode(my_rig, RIG_VFO_CURR, mode, bandwidth);
255
- if (retcode != RIG_OK) {
256
-
257
- Napi::TypeError::New(env, rigerror(retcode))
258
- .ThrowAsJavaScriptException();
259
- return env.Null();
260
- }
261
- return Napi::Number::New(env, retcode);
601
+ SetModeAsyncWorker* worker = new SetModeAsyncWorker(callback, this, mode, bandwidth);
602
+ worker->Queue();
603
+
604
+ return env.Undefined();
262
605
  }
263
606
 
264
607
  Napi::Value NodeHamLib::SetPtt(const Napi::CallbackInfo & info) {
265
608
  Napi::Env env = info.Env();
266
- int retcode;
267
- bool ptt_state;
609
+
268
610
  if (!rig_is_open) {
269
611
  Napi::TypeError::New(env, "Rig is not open!")
270
612
  .ThrowAsJavaScriptException();
271
613
  return env.Null();
272
614
  }
273
- if (info.Length() < 1) {
274
- Napi::TypeError::New(env, "Specify true or false for ppt state")
615
+
616
+ if (info.Length() < 2) {
617
+ Napi::TypeError::New(env, "Must specify PTT state and callback")
275
618
  .ThrowAsJavaScriptException();
276
619
  return env.Null();
277
620
  }
278
621
 
279
622
  if (!info[0].IsBoolean()) {
280
- Napi::TypeError::New(env, "PTT state is not boolean")
623
+ Napi::TypeError::New(env, "PTT state must be boolean")
281
624
  .ThrowAsJavaScriptException();
282
625
  return env.Null();
283
626
  }
284
- ptt_state = info[0].As < Napi::Boolean > ();
285
- if (ptt_state) {
286
- retcode = rig_set_ptt(my_rig, RIG_VFO_CURR, RIG_PTT_ON);
287
- } else {
288
- retcode = rig_set_ptt(my_rig, RIG_VFO_CURR, RIG_PTT_OFF);
289
- }
290
- if (retcode != RIG_OK) {
291
-
292
- Napi::TypeError::New(env, rigerror(retcode))
627
+
628
+ if (!info[1].IsFunction()) {
629
+ Napi::TypeError::New(env, "Second parameter must be callback function")
293
630
  .ThrowAsJavaScriptException();
294
631
  return env.Null();
295
632
  }
296
- return Napi::Number::New(env, retcode);
633
+
634
+ bool ptt_state = info[0].As < Napi::Boolean > ();
635
+ Napi::Function callback = info[1].As<Napi::Function>();
636
+
637
+ ptt_t ptt = ptt_state ? RIG_PTT_ON : RIG_PTT_OFF;
638
+ SetPttAsyncWorker* worker = new SetPttAsyncWorker(callback, this, ptt);
639
+ worker->Queue();
640
+
641
+ return env.Undefined();
297
642
  }
298
643
 
299
644
  Napi::Value NodeHamLib::GetVFO(const Napi::CallbackInfo & info) {
300
645
  Napi::Env env = info.Env();
301
- int retcode;
302
- vfo_t vfo;
646
+
303
647
  if (!rig_is_open) {
304
648
  Napi::TypeError::New(env, "Rig is not open!")
305
649
  .ThrowAsJavaScriptException();
306
650
  return env.Null();
307
651
  }
308
- retcode = rig_get_vfo(my_rig, & vfo);
309
- if (retcode == RIG_OK) {
310
- return Napi::Number::New(env, vfo);
311
- } else {
312
- //dont throw an exception here, not every radio reports vfo
313
- Napi::Error::New(env, rigerror(retcode));
652
+
653
+ if (info.Length() < 1 || !info[0].IsFunction()) {
654
+ Napi::TypeError::New(env, "Callback function is required")
655
+ .ThrowAsJavaScriptException();
314
656
  return env.Null();
315
657
  }
316
-
658
+
659
+ Napi::Function callback = info[0].As<Napi::Function>();
660
+ GetVfoAsyncWorker* worker = new GetVfoAsyncWorker(callback, this);
661
+ worker->Queue();
662
+
663
+ return env.Undefined();
317
664
  }
318
665
 
319
666
  Napi::Value NodeHamLib::GetFrequency(const Napi::CallbackInfo & info) {
320
667
  Napi::Env env = info.Env();
321
- int retcode;
322
- freq_t freq;
668
+
323
669
  if (!rig_is_open) {
324
670
  Napi::TypeError::New(env, "Rig is not open!")
325
671
  .ThrowAsJavaScriptException();
@@ -328,93 +674,122 @@ Napi::Value NodeHamLib::GetFrequency(const Napi::CallbackInfo & info) {
328
674
 
329
675
  // Support optional VFO parameter
330
676
  vfo_t vfo = RIG_VFO_CURR;
331
- if (info.Length() >= 1 && info[0].IsString()) {
332
- auto vfostr = info[0].As < Napi::String > ().Utf8Value().c_str();
333
- if (strcmp(vfostr, "VFO-A") == 0) {
334
- vfo = RIG_VFO_A;
335
- } else if (strcmp(vfostr, "VFO-B") == 0) {
336
- vfo = RIG_VFO_B;
337
- }
338
- }
677
+ Napi::Function callback;
339
678
 
340
- retcode = rig_get_freq(my_rig, vfo, & freq);
341
- if (retcode == RIG_OK) {
342
- return Napi::Number::New(env, freq);
679
+ if (info.Length() == 1) {
680
+ if (!info[0].IsFunction()) {
681
+ Napi::TypeError::New(env, "Parameter must be callback function")
682
+ .ThrowAsJavaScriptException();
683
+ return env.Null();
684
+ }
685
+ callback = info[0].As<Napi::Function>();
686
+ } else if (info.Length() == 2) {
687
+ if (info[0].IsString()) {
688
+ auto vfostr = info[0].As < Napi::String > ().Utf8Value().c_str();
689
+ if (strcmp(vfostr, "VFO-A") == 0) {
690
+ vfo = RIG_VFO_A;
691
+ } else if (strcmp(vfostr, "VFO-B") == 0) {
692
+ vfo = RIG_VFO_B;
693
+ }
694
+ }
695
+ if (!info[1].IsFunction()) {
696
+ Napi::TypeError::New(env, "Second parameter must be callback function")
697
+ .ThrowAsJavaScriptException();
698
+ return env.Null();
699
+ }
700
+ callback = info[1].As<Napi::Function>();
343
701
  } else {
344
- Napi::Error::New(env, rigerror(retcode));
702
+ Napi::TypeError::New(env, "Must provide callback function")
703
+ .ThrowAsJavaScriptException();
345
704
  return env.Null();
346
705
  }
706
+
707
+ GetFrequencyAsyncWorker* worker = new GetFrequencyAsyncWorker(callback, this, vfo);
708
+ worker->Queue();
709
+
710
+ return env.Undefined();
347
711
  }
348
712
 
349
713
  Napi::Value NodeHamLib::GetMode(const Napi::CallbackInfo & info) {
350
714
  Napi::Env env = info.Env();
351
- int retcode;
352
- rmode_t rmode;
353
- pbwidth_t width;
715
+
354
716
  if (!rig_is_open) {
355
717
  Napi::TypeError::New(env, "Rig is not open!")
356
718
  .ThrowAsJavaScriptException();
357
719
  return env.Null();
358
720
  }
359
- retcode = rig_get_mode(my_rig, RIG_VFO_CURR, & rmode, & width);
360
- if (retcode == RIG_OK) {
361
- Napi::Object obj = Napi::Object::New(env);
362
- obj.Set(Napi::String::New(env, "mode"), (char)rmode);
363
- obj.Set(Napi::String::New(env, "width"), width);
364
- return obj;
365
- } else {
366
- Napi::Error::New(env, rigerror(retcode));
721
+
722
+ if (info.Length() < 1 || !info[0].IsFunction()) {
723
+ Napi::TypeError::New(env, "Callback function is required")
724
+ .ThrowAsJavaScriptException();
367
725
  return env.Null();
368
726
  }
727
+
728
+ Napi::Function callback = info[0].As<Napi::Function>();
729
+ GetModeAsyncWorker* worker = new GetModeAsyncWorker(callback, this);
730
+ worker->Queue();
731
+
732
+ return env.Undefined();
369
733
  }
370
734
 
371
735
  Napi::Value NodeHamLib::GetStrength(const Napi::CallbackInfo & info) {
372
736
  Napi::Env env = info.Env();
373
- int retcode;
374
- int strength;
737
+
375
738
  if (!rig_is_open) {
376
739
  Napi::TypeError::New(env, "Rig is not open!")
377
740
  .ThrowAsJavaScriptException();
378
741
  return env.Null();
379
742
  }
380
- retcode = rig_get_strength(my_rig, RIG_VFO_CURR, & strength);
381
- if (retcode == RIG_OK) {
382
- return Napi::Number::New(env, strength);
383
- } else {
384
- Napi::Error::New(env, rigerror(retcode));
743
+
744
+ if (info.Length() < 1 || !info[0].IsFunction()) {
745
+ Napi::TypeError::New(env, "Callback function is required")
746
+ .ThrowAsJavaScriptException();
385
747
  return env.Null();
386
748
  }
749
+
750
+ Napi::Function callback = info[0].As<Napi::Function>();
751
+ GetStrengthAsyncWorker* worker = new GetStrengthAsyncWorker(callback, this);
752
+ worker->Queue();
753
+
754
+ return env.Undefined();
387
755
  }
388
756
 
389
757
  Napi::Value NodeHamLib::Close(const Napi::CallbackInfo & info) {
390
758
  Napi::Env env = info.Env();
759
+
391
760
  if (!rig_is_open) {
392
761
  Napi::TypeError::New(env, "Rig is not open!")
393
762
  .ThrowAsJavaScriptException();
394
763
  return env.Null();
395
764
  }
396
- int retcode = rig_close(my_rig);
397
- if (retcode != RIG_OK) {
398
- Napi::TypeError::New(env, "Unable to open rig")
765
+
766
+ if (info.Length() < 1 || !info[0].IsFunction()) {
767
+ Napi::TypeError::New(env, "Callback function is required")
399
768
  .ThrowAsJavaScriptException();
769
+ return env.Null();
400
770
  }
401
- rig_is_open = false;
402
- return Napi::Number::New(env, retcode);
771
+
772
+ Napi::Function callback = info[0].As<Napi::Function>();
773
+ CloseAsyncWorker* worker = new CloseAsyncWorker(callback, this);
774
+ worker->Queue();
775
+
776
+ return env.Undefined();
403
777
  }
404
778
 
405
779
  Napi::Value NodeHamLib::Destroy(const Napi::CallbackInfo & info) {
406
780
  Napi::Env env = info.Env();
407
- if (rig_is_open) {
408
- rig_close(my_rig);
409
- }
410
- int retcode = rig_cleanup(my_rig);
411
- if (retcode != RIG_OK) {
412
-
413
- Napi::TypeError::New(env, rigerror(retcode))
781
+
782
+ if (info.Length() < 1 || !info[0].IsFunction()) {
783
+ Napi::TypeError::New(env, "Callback function is required")
414
784
  .ThrowAsJavaScriptException();
785
+ return env.Null();
415
786
  }
416
- rig_is_open = false;
417
- return Napi::Number::New(env, retcode);
787
+
788
+ Napi::Function callback = info[0].As<Napi::Function>();
789
+ DestroyAsyncWorker* worker = new DestroyAsyncWorker(callback, this);
790
+ worker->Queue();
791
+
792
+ return env.Undefined();
418
793
  }
419
794
 
420
795
  Napi::Value NodeHamLib::GetConnectionInfo(const Napi::CallbackInfo & info) {
@@ -1485,6 +1860,15 @@ Napi::Function NodeHamLib::GetClass(Napi::Env env) {
1485
1860
  // Antenna Selection
1486
1861
  NodeHamLib::InstanceMethod("setAntenna", & NodeHamLib::SetAntenna),
1487
1862
  NodeHamLib::InstanceMethod("getAntenna", & NodeHamLib::GetAntenna),
1863
+
1864
+ // Serial Port Configuration
1865
+ NodeHamLib::InstanceMethod("setSerialConfig", & NodeHamLib::SetSerialConfig),
1866
+ NodeHamLib::InstanceMethod("getSerialConfig", & NodeHamLib::GetSerialConfig),
1867
+ NodeHamLib::InstanceMethod("setPttType", & NodeHamLib::SetPttType),
1868
+ NodeHamLib::InstanceMethod("getPttType", & NodeHamLib::GetPttType),
1869
+ NodeHamLib::InstanceMethod("setDcdType", & NodeHamLib::SetDcdType),
1870
+ NodeHamLib::InstanceMethod("getDcdType", & NodeHamLib::GetDcdType),
1871
+ NodeHamLib::InstanceMethod("getSupportedSerialConfigs", & NodeHamLib::GetSupportedSerialConfigs),
1488
1872
 
1489
1873
  NodeHamLib::InstanceMethod("close", & NodeHamLib::Close),
1490
1874
  NodeHamLib::InstanceMethod("destroy", & NodeHamLib::Destroy),
@@ -1601,3 +1985,250 @@ Napi::Value NodeHamLib::GetSupportedRigs(const Napi::CallbackInfo& info) {
1601
1985
  return rigArray;
1602
1986
  }
1603
1987
 
1988
+ // Serial Port Configuration Methods
1989
+
1990
+ // Set serial configuration parameter (data_bits, stop_bits, parity, handshake, etc.)
1991
+ Napi::Value NodeHamLib::SetSerialConfig(const Napi::CallbackInfo& info) {
1992
+ Napi::Env env = info.Env();
1993
+
1994
+ if (!rig_is_open) {
1995
+ Napi::TypeError::New(env, "Rig is not open!").ThrowAsJavaScriptException();
1996
+ return env.Null();
1997
+ }
1998
+
1999
+ if (info.Length() < 2 || !info[0].IsString() || !info[1].IsString()) {
2000
+ Napi::TypeError::New(env, "Expected parameter name and value as strings").ThrowAsJavaScriptException();
2001
+ return env.Null();
2002
+ }
2003
+
2004
+ std::string paramName = info[0].As<Napi::String>().Utf8Value();
2005
+ std::string paramValue = info[1].As<Napi::String>().Utf8Value();
2006
+
2007
+ // Get configuration token from parameter name
2008
+ HAMLIB_TOKEN_T token = rig_token_lookup(my_rig, paramName.c_str());
2009
+ if (token == RIG_CONF_END) {
2010
+ Napi::Error::New(env, "Unknown configuration parameter").ThrowAsJavaScriptException();
2011
+ return env.Null();
2012
+ }
2013
+
2014
+ // Use rig_set_conf to set configuration parameter
2015
+ int retcode = rig_set_conf(my_rig, token, paramValue.c_str());
2016
+ if (retcode != RIG_OK) {
2017
+ Napi::Error::New(env, rigerror(retcode)).ThrowAsJavaScriptException();
2018
+ return env.Null();
2019
+ }
2020
+
2021
+ return Napi::Number::New(env, retcode);
2022
+ }
2023
+
2024
+ // Get serial configuration parameter
2025
+ Napi::Value NodeHamLib::GetSerialConfig(const Napi::CallbackInfo& info) {
2026
+ Napi::Env env = info.Env();
2027
+
2028
+ if (!rig_is_open) {
2029
+ Napi::TypeError::New(env, "Rig is not open!").ThrowAsJavaScriptException();
2030
+ return env.Null();
2031
+ }
2032
+
2033
+ if (info.Length() < 1 || !info[0].IsString()) {
2034
+ Napi::TypeError::New(env, "Expected parameter name as string").ThrowAsJavaScriptException();
2035
+ return env.Null();
2036
+ }
2037
+
2038
+ std::string paramName = info[0].As<Napi::String>().Utf8Value();
2039
+ char value[256];
2040
+
2041
+ // Get configuration token from parameter name
2042
+ HAMLIB_TOKEN_T token = rig_token_lookup(my_rig, paramName.c_str());
2043
+ if (token == RIG_CONF_END) {
2044
+ Napi::Error::New(env, "Unknown configuration parameter").ThrowAsJavaScriptException();
2045
+ return env.Null();
2046
+ }
2047
+
2048
+ // Use rig_get_conf to get configuration parameter
2049
+ int retcode = rig_get_conf(my_rig, token, value);
2050
+ if (retcode != RIG_OK) {
2051
+ Napi::Error::New(env, rigerror(retcode)).ThrowAsJavaScriptException();
2052
+ return env.Null();
2053
+ }
2054
+
2055
+ return Napi::String::New(env, value);
2056
+ }
2057
+
2058
+ // Set PTT type
2059
+ Napi::Value NodeHamLib::SetPttType(const Napi::CallbackInfo& info) {
2060
+ Napi::Env env = info.Env();
2061
+
2062
+ if (info.Length() < 1 || !info[0].IsString()) {
2063
+ Napi::TypeError::New(env, "Expected PTT type as string").ThrowAsJavaScriptException();
2064
+ return env.Null();
2065
+ }
2066
+
2067
+ std::string pttTypeStr = info[0].As<Napi::String>().Utf8Value();
2068
+
2069
+ // Get configuration token for ptt_type
2070
+ HAMLIB_TOKEN_T token = rig_token_lookup(my_rig, "ptt_type");
2071
+ if (token == RIG_CONF_END) {
2072
+ Napi::Error::New(env, "PTT type configuration not supported").ThrowAsJavaScriptException();
2073
+ return env.Null();
2074
+ }
2075
+
2076
+ // Set PTT type through configuration
2077
+ int retcode = rig_set_conf(my_rig, token, pttTypeStr.c_str());
2078
+ if (retcode != RIG_OK) {
2079
+ Napi::Error::New(env, rigerror(retcode)).ThrowAsJavaScriptException();
2080
+ return env.Null();
2081
+ }
2082
+
2083
+ return Napi::Number::New(env, retcode);
2084
+ }
2085
+
2086
+ // Get PTT type
2087
+ Napi::Value NodeHamLib::GetPttType(const Napi::CallbackInfo& info) {
2088
+ Napi::Env env = info.Env();
2089
+
2090
+ char value[256];
2091
+
2092
+ // Get configuration token for ptt_type
2093
+ HAMLIB_TOKEN_T token = rig_token_lookup(my_rig, "ptt_type");
2094
+ if (token == RIG_CONF_END) {
2095
+ Napi::Error::New(env, "PTT type configuration not supported").ThrowAsJavaScriptException();
2096
+ return env.Null();
2097
+ }
2098
+
2099
+ // Get PTT type through configuration
2100
+ int retcode = rig_get_conf(my_rig, token, value);
2101
+ if (retcode != RIG_OK) {
2102
+ Napi::Error::New(env, rigerror(retcode)).ThrowAsJavaScriptException();
2103
+ return env.Null();
2104
+ }
2105
+
2106
+ return Napi::String::New(env, value);
2107
+ }
2108
+
2109
+ // Set DCD type
2110
+ Napi::Value NodeHamLib::SetDcdType(const Napi::CallbackInfo& info) {
2111
+ Napi::Env env = info.Env();
2112
+
2113
+ if (info.Length() < 1 || !info[0].IsString()) {
2114
+ Napi::TypeError::New(env, "Expected DCD type as string").ThrowAsJavaScriptException();
2115
+ return env.Null();
2116
+ }
2117
+
2118
+ std::string dcdTypeStr = info[0].As<Napi::String>().Utf8Value();
2119
+
2120
+ // Get configuration token for dcd_type
2121
+ HAMLIB_TOKEN_T token = rig_token_lookup(my_rig, "dcd_type");
2122
+ if (token == RIG_CONF_END) {
2123
+ Napi::Error::New(env, "DCD type configuration not supported").ThrowAsJavaScriptException();
2124
+ return env.Null();
2125
+ }
2126
+
2127
+ // Set DCD type through configuration
2128
+ int retcode = rig_set_conf(my_rig, token, dcdTypeStr.c_str());
2129
+ if (retcode != RIG_OK) {
2130
+ Napi::Error::New(env, rigerror(retcode)).ThrowAsJavaScriptException();
2131
+ return env.Null();
2132
+ }
2133
+
2134
+ return Napi::Number::New(env, retcode);
2135
+ }
2136
+
2137
+ // Get DCD type
2138
+ Napi::Value NodeHamLib::GetDcdType(const Napi::CallbackInfo& info) {
2139
+ Napi::Env env = info.Env();
2140
+
2141
+ char value[256];
2142
+
2143
+ // Get configuration token for dcd_type
2144
+ HAMLIB_TOKEN_T token = rig_token_lookup(my_rig, "dcd_type");
2145
+ if (token == RIG_CONF_END) {
2146
+ Napi::Error::New(env, "DCD type configuration not supported").ThrowAsJavaScriptException();
2147
+ return env.Null();
2148
+ }
2149
+
2150
+ // Get DCD type through configuration
2151
+ int retcode = rig_get_conf(my_rig, token, value);
2152
+ if (retcode != RIG_OK) {
2153
+ Napi::Error::New(env, rigerror(retcode)).ThrowAsJavaScriptException();
2154
+ return env.Null();
2155
+ }
2156
+
2157
+ return Napi::String::New(env, value);
2158
+ }
2159
+
2160
+ // Get supported serial configuration options
2161
+ Napi::Value NodeHamLib::GetSupportedSerialConfigs(const Napi::CallbackInfo& info) {
2162
+ Napi::Env env = info.Env();
2163
+
2164
+ // Return object with supported configuration parameters and their possible values
2165
+ Napi::Object configs = Napi::Object::New(env);
2166
+
2167
+ // Serial basic parameters
2168
+ Napi::Object serialParams = Napi::Object::New(env);
2169
+
2170
+ // Data bits options
2171
+ Napi::Array dataBitsOptions = Napi::Array::New(env, 4);
2172
+ dataBitsOptions[0u] = Napi::String::New(env, "5");
2173
+ dataBitsOptions[1u] = Napi::String::New(env, "6");
2174
+ dataBitsOptions[2u] = Napi::String::New(env, "7");
2175
+ dataBitsOptions[3u] = Napi::String::New(env, "8");
2176
+ serialParams.Set("data_bits", dataBitsOptions);
2177
+
2178
+ // Stop bits options
2179
+ Napi::Array stopBitsOptions = Napi::Array::New(env, 2);
2180
+ stopBitsOptions[0u] = Napi::String::New(env, "1");
2181
+ stopBitsOptions[1u] = Napi::String::New(env, "2");
2182
+ serialParams.Set("stop_bits", stopBitsOptions);
2183
+
2184
+ // Parity options
2185
+ Napi::Array parityOptions = Napi::Array::New(env, 3);
2186
+ parityOptions[0u] = Napi::String::New(env, "None");
2187
+ parityOptions[1u] = Napi::String::New(env, "Even");
2188
+ parityOptions[2u] = Napi::String::New(env, "Odd");
2189
+ serialParams.Set("serial_parity", parityOptions);
2190
+
2191
+ // Handshake options
2192
+ Napi::Array handshakeOptions = Napi::Array::New(env, 3);
2193
+ handshakeOptions[0u] = Napi::String::New(env, "None");
2194
+ handshakeOptions[1u] = Napi::String::New(env, "Hardware");
2195
+ handshakeOptions[2u] = Napi::String::New(env, "Software");
2196
+ serialParams.Set("serial_handshake", handshakeOptions);
2197
+
2198
+ // Control line state options
2199
+ Napi::Array stateOptions = Napi::Array::New(env, 2);
2200
+ stateOptions[0u] = Napi::String::New(env, "ON");
2201
+ stateOptions[1u] = Napi::String::New(env, "OFF");
2202
+ serialParams.Set("rts_state", stateOptions);
2203
+ serialParams.Set("dtr_state", stateOptions);
2204
+
2205
+ configs.Set("serial", serialParams);
2206
+
2207
+ // PTT type options
2208
+ Napi::Array pttTypeOptions = Napi::Array::New(env, 8);
2209
+ pttTypeOptions[0u] = Napi::String::New(env, "RIG");
2210
+ pttTypeOptions[1u] = Napi::String::New(env, "DTR");
2211
+ pttTypeOptions[2u] = Napi::String::New(env, "RTS");
2212
+ pttTypeOptions[3u] = Napi::String::New(env, "PARALLEL");
2213
+ pttTypeOptions[4u] = Napi::String::New(env, "CM108");
2214
+ pttTypeOptions[5u] = Napi::String::New(env, "GPIO");
2215
+ pttTypeOptions[6u] = Napi::String::New(env, "GPION");
2216
+ pttTypeOptions[7u] = Napi::String::New(env, "NONE");
2217
+ configs.Set("ptt_type", pttTypeOptions);
2218
+
2219
+ // DCD type options
2220
+ Napi::Array dcdTypeOptions = Napi::Array::New(env, 9);
2221
+ dcdTypeOptions[0u] = Napi::String::New(env, "RIG");
2222
+ dcdTypeOptions[1u] = Napi::String::New(env, "DSR");
2223
+ dcdTypeOptions[2u] = Napi::String::New(env, "CTS");
2224
+ dcdTypeOptions[3u] = Napi::String::New(env, "CD");
2225
+ dcdTypeOptions[4u] = Napi::String::New(env, "PARALLEL");
2226
+ dcdTypeOptions[5u] = Napi::String::New(env, "CM108");
2227
+ dcdTypeOptions[6u] = Napi::String::New(env, "GPIO");
2228
+ dcdTypeOptions[7u] = Napi::String::New(env, "GPION");
2229
+ dcdTypeOptions[8u] = Napi::String::New(env, "NONE");
2230
+ configs.Set("dcd_type", dcdTypeOptions);
2231
+
2232
+ return configs;
2233
+ }
2234
+