Skip to content

Commit cdb98ec

Browse files
committed
fix: align getMode typings with runtime bandwidth field
1 parent 984742b commit cdb98ec

6 files changed

Lines changed: 14 additions & 7 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function main() {
5454

5555
const freq = await rig.getFrequency();
5656
const mode = await rig.getMode();
57-
console.log(`${freq/1000000} MHz ${mode.mode}`);
57+
console.log(`${freq/1000000} MHz ${mode.mode} ${mode.bandwidth}Hz`);
5858

5959
await rig.close();
6060

@@ -120,6 +120,7 @@ await rig.setMode('USB', 'nochange');
120120
await rig.setMode('USB', PASSBAND.NOCHANGE);
121121
await rig.setMode('USB', rig.getPassbandNormal('USB'));
122122
const mode = await rig.getMode();
123+
console.log(mode.bandwidth); // Current passband width in Hz
123124

124125
// VFO
125126
await rig.setVfo('VFOA');

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ interface ConnectionInfo {
2626
interface ModeInfo {
2727
/** Radio mode character */
2828
mode: string;
29-
/** Bandwidth width */
30-
width: number;
29+
/** Bandwidth in Hz */
30+
bandwidth: number;
3131
}
3232

3333
/**

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hamlib",
3-
"version": "0.4.4",
3+
"version": "0.4.5",
44
"description": "Node.js bindings for Hamlib rig control with official spectrum streaming support",
55
"main": "index.js",
66
"module": "lib/index.mjs",

test/test_ci_functional.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,12 @@ async function run() {
449449
await rig.setMode('USB', rig.getPassbandNormal('USB'));
450450
});
451451

452+
await test('getMode returns mode and numeric bandwidth', async () => {
453+
const mode = await rig.getMode();
454+
assert(typeof mode.mode === 'string', `expected mode string, got ${typeof mode.mode}`);
455+
assert(typeof mode.bandwidth === 'number', `expected numeric bandwidth, got ${typeof mode.bandwidth}`);
456+
});
457+
452458
await test('getResolution returns number for USB', () => {
453459
const res = rig.getResolution('USB');
454460
assert(typeof res === 'number', `expected number, got ${typeof res}`);

test/test_dummy_complete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async function runCompleteTest() {
126126

127127
await testWithErrorHandling('获取当前模式', async () => {
128128
const mode = await rig.getMode();
129-
return `模式: ${mode.mode}, 带宽: ${mode.width}`;
129+
return `模式: ${mode.mode}, 带宽: ${mode.bandwidth}`;
130130
});
131131

132132
await testWithErrorHandling('设置USB模式', async () => {

0 commit comments

Comments
 (0)