Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/speechmike_hid_device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ export class SpeechMikeHidDevice extends DictationDeviceBase {
} else if (this.commandResolvers.get(command) !== undefined) {
await this.handleCommandResponse(command, data);
} else {
throw new Error(`Unhandled input report from command ${command}`);
// Ignore extra status messages and slow replies from the device
// (common on wireless devices like the SpeechMike Ambient PSM5000,
// e.g. on device power off/on or machine lock/unlock).
console.debug(`Ignoring unhandled input report from command ${command}`);
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/speechmike_hid_device_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,22 @@ describe('SpeechMikeHidDevice', () => {
state.dictationDevice, MotionEvent.LAYED_DOWN);
});

it('ignores unrecognized input reports without throwing', async () => {
await createDictationDeviceForType(DeviceType.SPEECHMIKE_SMP_3700);

// Wireless SpeechMikes (e.g. Ambient PSM5000) emit unsolicited
// status/handshake reports, and may deliver command replies after their
// resolver has timed out. Command 134 (0x86) matches neither a button,
// motion nor wireless-status event, and has no pending resolver, so it must
// be ignored rather than throwing.
await expectAsync(
state.fakeHidDevice.handleInputReport([134, 0, 0, 0, 0, 0, 0, 0, 0]))
.toBeResolved();

expect(state.buttonEventListener).not.toHaveBeenCalled();
expect(state.motionEventListener).not.toHaveBeenCalled();
});

describe('handles input reports', () => {
it('SpeechMikes_Pro', async () => {
await createDictationDeviceForType(DeviceType.SPEECHMIKE_SMP_3700);
Expand Down