hamlib 0.2.7 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # node-hamlib
1
+ # hamlib
2
2
 
3
3
  Control amateur radio transceivers from Node.js using the [Hamlib](https://hamlib.github.io/) library.
4
4
 
@@ -8,6 +8,7 @@ Control amateur radio transceivers from Node.js using the [Hamlib](https://hamli
8
8
  - **Full Async/Promise API** - Non-blocking operations with async/await support
9
9
  - **Comprehensive Serial Control** - 13 parameters for complete serial port configuration
10
10
  - **Multiple Connections** - Serial ports, network (rigctld), direct control
11
+ - **Official Spectrum Streaming** - Wraps Hamlib's official spectrum callback API with Promise helpers and typed events
11
12
  - **TypeScript Ready** - Complete type definitions included
12
13
  - **Cross-platform** - Windows, Linux, macOS
13
14
 
@@ -15,7 +16,7 @@ Control amateur radio transceivers from Node.js using the [Hamlib](https://hamli
15
16
 
16
17
  ### Option 1: NPM Installation (Recommended)
17
18
  ```bash
18
- npm install node-hamlib
19
+ npm install hamlib
19
20
  ```
20
21
 
21
22
  The package will automatically use precompiled binaries if available for your platform, otherwise it will build from source.
@@ -24,9 +25,9 @@ The package will automatically use precompiled binaries if available for your pl
24
25
 
25
26
  For faster installation or offline environments, you can manually install precompiled binaries:
26
27
 
27
- 1. **Download Prebuilds**: Go to [Releases](../../releases) and download `node-hamlib-prebuilds.zip`
28
+ 1. **Download Prebuilds**: Go to [Releases](../../releases) and download `hamlib-prebuilds.zip`
28
29
  2. **Extract**: Unzip to your project's `node_modules/hamlib/prebuilds/` directory
29
- 3. **Install**: Run `npm install node-hamlib --ignore-scripts`
30
+ 3. **Install**: Run `npm install hamlib --ignore-scripts`
30
31
 
31
32
  **Supported Prebuilt Platforms:**
32
33
  - ✅ Linux x64
@@ -37,7 +38,7 @@ For faster installation or offline environments, you can manually install precom
37
38
  ## Quick Start
38
39
 
39
40
  ```javascript
40
- const { HamLib } = require('node-hamlib');
41
+ const { HamLib } = require('hamlib');
41
42
 
42
43
  async function main() {
43
44
  // Create rig instance (model 1035 = FT-991A)
@@ -144,6 +145,76 @@ await rig.vfoOperation('CPY'); // Copy VFO A to B
144
145
  await rig.vfoOperation('TOGGLE'); // Toggle VFO A/B
145
146
  ```
146
147
 
148
+ ### Raw CI-V Request/Reply
149
+
150
+ ```javascript
151
+ const reply = await rig.sendRaw(
152
+ Buffer.from([0xfe, 0xfe, 0xa4, 0xe0, 0x03, 0xfd]),
153
+ 64,
154
+ Buffer.from([0xfd])
155
+ );
156
+ ```
157
+
158
+ Notes:
159
+ - `sendRaw()` is request/response oriented.
160
+ - Continuous spectrum streaming now uses Hamlib's official spectrum callback APIs instead of a raw serial byte subscription.
161
+ - For Icom rigs, start managed spectrum only after `open()`. The built-in helper now follows the validated sequence: register callback, best-effort enable async, configure spectrum, enable `SPECTRUM`, then enable `TRANSCEIVE`.
162
+
163
+ ### Official Spectrum Streaming
164
+
165
+ ```javascript
166
+ const { HamLib } = require('hamlib');
167
+
168
+ async function monitorSpectrum() {
169
+ const rig = new HamLib(3085, '/dev/tty.usbmodem11201');
170
+
171
+ await rig.setSerialConfig('rate', '9600');
172
+ await rig.setSerialConfig('data_bits', '8');
173
+ await rig.setSerialConfig('stop_bits', '1');
174
+ await rig.setSerialConfig('serial_parity', 'None');
175
+ await rig.open();
176
+
177
+ const support = await rig.getSpectrumSupportSummary();
178
+ if (!support.supported) {
179
+ throw new Error('Official Hamlib spectrum streaming is not supported by this rig/backend');
180
+ }
181
+
182
+ rig.on('spectrumLine', (line) => {
183
+ console.log({
184
+ centerFreq: line.centerFreq,
185
+ spanHz: line.spanHz,
186
+ bins: line.dataLength,
187
+ });
188
+ });
189
+
190
+ await rig.startManagedSpectrum({
191
+ hold: false,
192
+ spanHz: 10000,
193
+ });
194
+
195
+ await new Promise((resolve) => setTimeout(resolve, 15000));
196
+
197
+ await rig.stopManagedSpectrum();
198
+ await rig.close();
199
+ }
200
+ ```
201
+
202
+ Spectrum API summary:
203
+
204
+ - `getSpectrumCapabilities()` returns conservative backend metadata exposed by the native addon.
205
+ - `getSpectrumSupportSummary()` returns a product-oriented summary of whether official spectrum streaming is usable on the current rig/backend.
206
+ - `configureSpectrum()` applies supported `SPECTRUM_*` levels and optional `SPECTRUM_HOLD`.
207
+ - `startSpectrumStream(callback?)` registers the official Hamlib spectrum callback only.
208
+ - `stopSpectrumStream()` unregisters the official spectrum callback.
209
+ - `startManagedSpectrum(config?)` runs the validated startup sequence for Icom/Hamlib async spectrum.
210
+ - `stopManagedSpectrum()` runs the symmetric shutdown sequence and unregisters the callback.
211
+
212
+ Emitted events:
213
+
214
+ - `spectrumLine` carries a single `SpectrumLine` object with frequency edges, mode, and raw bin payload.
215
+ - `spectrumStateChanged` emits `{ active: boolean }` when managed spectrum starts or stops.
216
+ - `spectrumError` is reserved for asynchronous streaming failures.
217
+
147
218
  ### Power and Status
148
219
 
149
220
  ```javascript
@@ -220,7 +291,7 @@ const parity = await rig.getSerialConfig('serial_parity');
220
291
  ## Complete Example
221
292
 
222
293
  ```javascript
223
- const { HamLib } = require('node-hamlib');
294
+ const { HamLib } = require('hamlib');
224
295
 
225
296
  async function repeaterOperation() {
226
297
  const rig = new HamLib(1035, '/dev/ttyUSB0');
package/binding.gyp CHANGED
@@ -24,24 +24,28 @@
24
24
  # Linux configuration
25
25
  ["OS==\"linux\"", {
26
26
  "include_dirs": [
27
+ "<(module_root_dir)/hamlib-build/include",
27
28
  "<!@(node -e \"if(process.env.HAMLIB_PREFIX) console.log(process.env.HAMLIB_PREFIX + '/include')\")",
28
29
  "/usr/include",
29
30
  "/usr/local/include"
30
31
  ],
31
32
  "libraries": [
32
33
  "<(module_root_dir)/shim-build/libhamlib_shim.a",
34
+ "-L<(module_root_dir)/hamlib-build/lib",
33
35
  "<!@(node -e \"if(process.env.HAMLIB_PREFIX) console.log('-L' + process.env.HAMLIB_PREFIX + '/lib')\")",
34
36
  "-L/usr/lib",
35
37
  "-L/usr/local/lib",
36
38
  "-lhamlib"
37
39
  ],
38
40
  "ldflags": [
39
- "-Wl,-rpath,\\$ORIGIN"
41
+ "-Wl,-rpath,\\$ORIGIN",
42
+ "-Wl,-rpath,<(module_root_dir)/hamlib-build/lib"
40
43
  ]
41
44
  }],
42
45
  # macOS configuration
43
46
  ["OS==\"mac\"", {
44
47
  "include_dirs": [
48
+ "<(module_root_dir)/hamlib-build/include",
45
49
  "<!@(node -e \"if(process.env.HAMLIB_PREFIX) console.log(process.env.HAMLIB_PREFIX + '/include')\")",
46
50
  "/usr/local/include",
47
51
  "/usr/local/opt/hamlib/include",
@@ -52,6 +56,7 @@
52
56
  ],
53
57
  "libraries": [
54
58
  "<(module_root_dir)/shim-build/libhamlib_shim.a",
59
+ "-L<(module_root_dir)/hamlib-build/lib",
55
60
  "<!@(node -e \"if(process.env.HAMLIB_PREFIX) console.log('-L' + process.env.HAMLIB_PREFIX + '/lib')\")",
56
61
  "-L/usr/local/lib",
57
62
  "-L/usr/local/opt/hamlib/lib",
@@ -67,7 +72,8 @@
67
72
  "MACOSX_DEPLOYMENT_TARGET": "10.15"
68
73
  },
69
74
  "ldflags": [
70
- "-Wl,-rpath,@loader_path"
75
+ "-Wl,-rpath,@loader_path",
76
+ "-Wl,-rpath,<(module_root_dir)/hamlib-build/lib"
71
77
  ]
72
78
  }],
73
79
  # Windows configuration