hamlib 0.3.3 → 0.4.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
@@ -89,7 +89,7 @@ await rig.setMode('USB');
89
89
  const mode = await rig.getMode();
90
90
 
91
91
  // VFO
92
- await rig.setVfo('VFO-A');
92
+ await rig.setVfo('VFOA');
93
93
  const vfo = await rig.getVfo();
94
94
 
95
95
  // PTT
@@ -111,7 +111,7 @@ await rig.setMemoryChannel(1, {
111
111
  });
112
112
 
113
113
  // Recall channel
114
- const channel = await rig.getMemoryChannel(1);
114
+ const channel = await rig.getMemoryChannel(1, true);
115
115
  await rig.selectMemoryChannel(1);
116
116
  ```
117
117
 
@@ -124,7 +124,7 @@ await rig.setXit(-50); // -50 Hz XIT
124
124
  await rig.clearRitXit(); // Clear both
125
125
 
126
126
  // Scanning
127
- await rig.startScan('VFO'); // Start VFO scan
127
+ await rig.startScan('VFO', 0); // Start VFO scan
128
128
  await rig.stopScan(); // Stop scan
129
129
 
130
130
  // Levels (0.0-1.0)
@@ -158,15 +158,17 @@ const reply = await rig.sendRaw(
158
158
  Notes:
159
159
  - `sendRaw()` is request/response oriented.
160
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`.
161
+ - The main `HamLib` class stays a bridge. High-level spectrum helpers live under the `hamlib/spectrum` subpath.
162
162
 
163
163
  ### Official Spectrum Streaming
164
164
 
165
165
  ```javascript
166
166
  const { HamLib } = require('hamlib');
167
+ const { SpectrumController } = require('hamlib/spectrum');
167
168
 
168
169
  async function monitorSpectrum() {
169
170
  const rig = new HamLib(3085, '/dev/tty.usbmodem11201');
171
+ const spectrum = new SpectrumController(rig);
170
172
 
171
173
  await rig.setSerialConfig('rate', '9600');
172
174
  await rig.setSerialConfig('data_bits', '8');
@@ -174,12 +176,12 @@ async function monitorSpectrum() {
174
176
  await rig.setSerialConfig('serial_parity', 'None');
175
177
  await rig.open();
176
178
 
177
- const support = await rig.getSpectrumSupportSummary();
179
+ const support = await spectrum.getSpectrumSupportSummary();
178
180
  if (!support.supported) {
179
181
  throw new Error('Official Hamlib spectrum streaming is not supported by this rig/backend');
180
182
  }
181
183
 
182
- rig.on('spectrumLine', (line) => {
184
+ spectrum.on('spectrumLine', (line) => {
183
185
  console.log({
184
186
  centerFreq: line.centerFreq,
185
187
  spanHz: line.spanHz,
@@ -187,51 +189,54 @@ async function monitorSpectrum() {
187
189
  });
188
190
  });
189
191
 
190
- await rig.startManagedSpectrum({
192
+ await spectrum.startManagedSpectrum({
191
193
  hold: false,
192
194
  spanHz: 10000,
195
+ pumpIntervalMs: 200,
193
196
  });
194
197
 
195
198
  await new Promise((resolve) => setTimeout(resolve, 15000));
196
199
 
197
- await rig.stopManagedSpectrum();
200
+ await spectrum.stopManagedSpectrum();
198
201
  await rig.close();
199
202
  }
200
203
  ```
201
204
 
202
205
  Spectrum API summary:
203
206
 
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
- - `getSpectrumDisplayState()` returns a normalized display state with `mode/span/fixed edges/edge slot`.
208
- - `configureSpectrumDisplay()` applies a normalized display config and reads back the resulting state.
209
- - `getSpectrumEdgeSlot()` / `setSpectrumEdgeSlot()` expose backend edge-slot control when available.
210
- - `getSpectrumFixedEdges()` / `setSpectrumFixedEdges()` expose direct fixed-range control using `SPECTRUM_EDGE_LOW/HIGH`.
211
- - `startSpectrumStream(callback?)` registers the official Hamlib spectrum callback only.
212
- - `stopSpectrumStream()` unregisters the official spectrum callback.
213
- - `startManagedSpectrum(config?)` runs the validated startup sequence for Icom/Hamlib async spectrum.
214
- - `stopManagedSpectrum()` runs the symmetric shutdown sequence and unregisters the callback.
207
+ - `HamLib.getSpectrumCapabilities()` returns conservative backend metadata exposed by the native addon.
208
+ - `HamLib.startSpectrumStream(callback?)` registers the official Hamlib spectrum callback only.
209
+ - `HamLib.stopSpectrumStream()` unregisters the official spectrum callback.
210
+ - `SpectrumController.getSpectrumSupportSummary()` returns a product-oriented summary of whether official spectrum streaming is usable on the current rig/backend.
211
+ - `SpectrumController.configureSpectrum()` applies supported `SPECTRUM_*` levels and optional `SPECTRUM_HOLD`.
212
+ - `SpectrumController.getSpectrumDisplayState()` returns a normalized display state with `mode/span/fixed edges/edge slot`.
213
+ - `SpectrumController.configureSpectrumDisplay()` applies a normalized display config and reads back the resulting state.
214
+ - `SpectrumController.getSpectrumEdgeSlot()` / `SpectrumController.setSpectrumEdgeSlot()` expose backend edge-slot control when available.
215
+ - `SpectrumController.getSpectrumFixedEdges()` / `SpectrumController.setSpectrumFixedEdges()` expose direct fixed-range control using `SPECTRUM_EDGE_LOW/HIGH`.
216
+ - `SpectrumController.startManagedSpectrum(config?)` runs the validated startup sequence for Icom/Hamlib async spectrum.
217
+ - `pumpIntervalMs` controls a lightweight helper-side CAT pump. Default `200`; set `0` or `false` to disable.
218
+ - `SpectrumController.stopManagedSpectrum()` runs the symmetric shutdown sequence and unregisters the callback.
215
219
 
216
220
  Fixed-range example:
217
221
 
218
222
  ```javascript
219
- await rig.configureSpectrumDisplay({
223
+ await spectrum.configureSpectrumDisplay({
220
224
  mode: 'fixed',
221
225
  edgeSlot: 1,
222
226
  edgeLowHz: 14074000,
223
227
  edgeHighHz: 14077000,
224
228
  });
225
229
 
226
- const displayState = await rig.getSpectrumDisplayState();
230
+ const displayState = await spectrum.getSpectrumDisplayState();
227
231
  console.log(displayState);
228
232
  ```
229
233
 
230
234
  Emitted events:
231
235
 
232
- - `spectrumLine` carries a single `SpectrumLine` object with frequency edges, mode, and raw bin payload.
233
- - `spectrumStateChanged` emits `{ active: boolean }` when managed spectrum starts or stops.
234
- - `spectrumError` is reserved for asynchronous streaming failures.
236
+ - `HamLib` emits `spectrumLine` when `startSpectrumStream()` is used without an explicit callback.
237
+ - `SpectrumController` emits `spectrumLine` for managed spectrum data.
238
+ - `SpectrumController` emits `spectrumStateChanged` when managed spectrum starts or stops.
239
+ - `SpectrumController` emits `spectrumError` when managed startup fails asynchronously.
235
240
 
236
241
  ### Power and Status
237
242