Skip to content

Commit b878ea5

Browse files
raman325claude
andcommitted
feat: add schema 47 driver commands (2/4)
Add new driver commands: softResetAndRestart, enterBootloader, leaveBootloader, getSupportedCCVersion, getSafeCCVersion, updateUserAgent, enableFrequentRSSIMonitoring, and disableFrequentRSSIMonitoring. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 485f10c commit b878ea5

6 files changed

Lines changed: 231 additions & 12 deletions

File tree

API_SCHEMA.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,5 @@ Base schema.
122122
- Added controller state properties: `isSIS`, `maxPayloadSize`, `maxPayloadSizeLR`, `zwaveApiVersion`, `zwaveChipType`
123123
- Added driver events: `all nodes ready`, `error`, `bootloader ready`
124124
- Added controller events: `network found`, `network joined`, `network left`, `joining network failed`, `leaving network failed`
125+
- Added driver commands: `soft_reset_and_restart`, `enter_bootloader`, `leave_bootloader`, `get_supported_cc_version`, `get_safe_cc_version`, `update_user_agent`, `enable_frequent_rssi_monitoring`, `disable_frequent_rssi_monitoring`
126+
- Automatic ZIP extraction for firmware update commands

README.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ interface {
443443
}
444444
```
445445

446-
If `fileFormat` is not provided in Option 1, the format will be guessed based on the filename and file payload.
446+
If `fileFormat` is not provided in Option 1, the format will be guessed based on the filename and file payload. If guessing fails, the server will automatically attempt to extract firmware from a ZIP archive.
447447

448448
Returns:
449449

@@ -472,6 +472,102 @@ interface {
472472
}
473473
```
474474

475+
#### [Soft Reset and Restart](https://zwave-js.github.io/node-zwave-js/#/api/driver?id=softresetandrestart)
476+
477+
[compatible with schema version: 47+]
478+
479+
```ts
480+
interface {
481+
messageId: string;
482+
command: "driver.soft_reset_and_restart";
483+
}
484+
```
485+
486+
#### [Enter Bootloader](https://zwave-js.github.io/node-zwave-js/#/api/driver?id=enterbootloader)
487+
488+
[compatible with schema version: 47+]
489+
490+
```ts
491+
interface {
492+
messageId: string;
493+
command: "driver.enter_bootloader";
494+
}
495+
```
496+
497+
#### [Leave Bootloader](https://zwave-js.github.io/node-zwave-js/#/api/driver?id=leavebootloader)
498+
499+
[compatible with schema version: 47+]
500+
501+
```ts
502+
interface {
503+
messageId: string;
504+
command: "driver.leave_bootloader";
505+
}
506+
```
507+
508+
#### [Get Supported CC Version](https://zwave-js.github.io/node-zwave-js/#/api/driver?id=getsupportedccversion)
509+
510+
[compatible with schema version: 47+]
511+
512+
```ts
513+
interface {
514+
messageId: string;
515+
command: "driver.get_supported_cc_version";
516+
cc: CommandClasses;
517+
nodeId: number;
518+
endpointIndex?: number;
519+
}
520+
```
521+
522+
#### [Get Safe CC Version](https://zwave-js.github.io/node-zwave-js/#/api/driver?id=getsafeccversion)
523+
524+
[compatible with schema version: 47+]
525+
526+
```ts
527+
interface {
528+
messageId: string;
529+
command: "driver.get_safe_cc_version";
530+
cc: CommandClasses;
531+
nodeId: number;
532+
endpointIndex?: number;
533+
}
534+
```
535+
536+
#### [Update User Agent](https://zwave-js.github.io/node-zwave-js/#/api/driver?id=updateuseragent)
537+
538+
[compatible with schema version: 47+]
539+
540+
```ts
541+
interface {
542+
messageId: string;
543+
command: "driver.update_user_agent";
544+
components: Record<string, string | null | undefined>;
545+
}
546+
```
547+
548+
#### [Enable Frequent RSSI Monitoring](https://zwave-js.github.io/node-zwave-js/#/api/driver?id=enablefrequentrssimonitoring)
549+
550+
[compatible with schema version: 47+]
551+
552+
```ts
553+
interface {
554+
messageId: string;
555+
command: "driver.enable_frequent_rssi_monitoring";
556+
durationMs: number;
557+
}
558+
```
559+
560+
#### [Disable Frequent RSSI Monitoring](https://zwave-js.github.io/node-zwave-js/#/api/driver?id=disablefrequentrssimonitoring)
561+
562+
[compatible with schema version: 47+]
563+
564+
```ts
565+
interface {
566+
messageId: string;
567+
command: "driver.disable_frequent_rssi_monitoring";
568+
}
569+
```
570+
475571
### Controller level commands
476572

477573
`zwave-js-server` supports all of the controller methods listed in the [Z-Wave JS documentation](https://zwave-js.github.io/node-zwave-js/#/api/controller?id=controller-methods). `zwave-js-server` uses [snake casing](https://en.wikipedia.org/wiki/Snake_case) for commands and prefixes every controller command with `controller.`, so `beginInclusion` is called using the `controller.begin_inclusion` command.

src/lib/driver/command.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,18 @@ export enum DriverCommand {
2121
firmwareUpdateOTW = "driver.firmware_update_otw",
2222
// Schema version >= 41:
2323
isOTWFirmwareUpdateInProgress = "driver.is_otw_firmware_update_in_progress",
24+
// Undocumented
25+
softResetAndRestart = "driver.soft_reset_and_restart",
26+
// Undocumented
27+
enterBootloader = "driver.enter_bootloader",
28+
// Undocumented
29+
leaveBootloader = "driver.leave_bootloader",
30+
// CC version queries
31+
getSupportedCCVersion = "driver.get_supported_cc_version",
32+
getSafeCCVersion = "driver.get_safe_cc_version",
33+
// User agent
34+
updateUserAgent = "driver.update_user_agent",
35+
// RSSI monitoring
36+
enableFrequentRSSIMonitoring = "driver.enable_frequent_rssi_monitoring",
37+
disableFrequentRSSIMonitoring = "driver.disable_frequent_rssi_monitoring",
2438
}

src/lib/driver/incoming_message.ts

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FirmwareFileFormat, LogConfig } from "@zwave-js/core";
1+
import { CommandClasses, FirmwareFileFormat, LogConfig } from "@zwave-js/core";
22
import { DriverCommand } from "./command.js";
33
import { IncomingCommandBase } from "../incoming_message_base.js";
44
import {
@@ -110,6 +110,52 @@ export interface IncomingCommandIsOTWFirmwareUpdateInProgress
110110
command: DriverCommand.isOTWFirmwareUpdateInProgress;
111111
}
112112

113+
// Bootloader operations
114+
interface IncomingCommandSoftResetAndRestart extends IncomingCommandBase {
115+
command: DriverCommand.softResetAndRestart;
116+
}
117+
118+
interface IncomingCommandEnterBootloader extends IncomingCommandBase {
119+
command: DriverCommand.enterBootloader;
120+
}
121+
122+
interface IncomingCommandLeaveBootloader extends IncomingCommandBase {
123+
command: DriverCommand.leaveBootloader;
124+
}
125+
126+
// CC version queries
127+
interface IncomingCommandGetSupportedCCVersion extends IncomingCommandBase {
128+
command: DriverCommand.getSupportedCCVersion;
129+
cc: CommandClasses;
130+
nodeId: number;
131+
endpointIndex?: number;
132+
}
133+
134+
interface IncomingCommandGetSafeCCVersion extends IncomingCommandBase {
135+
command: DriverCommand.getSafeCCVersion;
136+
cc: CommandClasses;
137+
nodeId: number;
138+
endpointIndex?: number;
139+
}
140+
141+
// User agent
142+
interface IncomingCommandUpdateUserAgent extends IncomingCommandBase {
143+
command: DriverCommand.updateUserAgent;
144+
components: Record<string, string | null | undefined>;
145+
}
146+
147+
// RSSI monitoring
148+
interface IncomingCommandEnableFrequentRSSIMonitoring
149+
extends IncomingCommandBase {
150+
command: DriverCommand.enableFrequentRSSIMonitoring;
151+
durationMs: number;
152+
}
153+
154+
interface IncomingCommandDisableFrequentRSSIMonitoring
155+
extends IncomingCommandBase {
156+
command: DriverCommand.disableFrequentRSSIMonitoring;
157+
}
158+
113159
export type IncomingMessageDriver =
114160
| IncomingCommandGetConfig
115161
| IncomingCommandUpdateLogConfig
@@ -130,4 +176,12 @@ export type IncomingMessageDriver =
130176
| IncomingCommandUpdateOptions
131177
| IncomingCommandSendTestFrame
132178
| IncomingCommandFirmwareUpdateOTW
133-
| IncomingCommandIsOTWFirmwareUpdateInProgress;
179+
| IncomingCommandIsOTWFirmwareUpdateInProgress
180+
| IncomingCommandSoftResetAndRestart
181+
| IncomingCommandEnterBootloader
182+
| IncomingCommandLeaveBootloader
183+
| IncomingCommandGetSupportedCCVersion
184+
| IncomingCommandGetSafeCCVersion
185+
| IncomingCommandUpdateUserAgent
186+
| IncomingCommandEnableFrequentRSSIMonitoring
187+
| IncomingCommandDisableFrequentRSSIMonitoring;

src/lib/driver/message_handler.ts

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import {
2-
Driver,
3-
extractFirmware,
4-
guessFirmwareFileFormat,
5-
OTWFirmwareUpdateResult,
6-
} from "zwave-js";
1+
import { Driver, extractFirmware, OTWFirmwareUpdateResult } from "zwave-js";
72
import { UnknownCommandError } from "../error.js";
3+
import { parseFirmwareFile } from "../common.js";
84
import {
95
Client,
106
ClientsController,
@@ -136,11 +132,12 @@ export class DriverMessageHandler implements MessageHandler {
136132
result = await this.driver.firmwareUpdateOTW(message.updateInfo);
137133
} else {
138134
const file = Buffer.from(message.file, "base64");
139-
const { data } = await extractFirmware(
135+
const parsed = parseFirmwareFile(
136+
message.filename,
140137
file,
141-
message.fileFormat ??
142-
guessFirmwareFileFormat(message.filename, file),
138+
message.fileFormat,
143139
);
140+
const { data } = await extractFirmware(parsed.rawData, parsed.format);
144141
result = await this.driver.firmwareUpdateOTW(data);
145142
}
146143
return { result };
@@ -149,6 +146,50 @@ export class DriverMessageHandler implements MessageHandler {
149146
const progress = this.driver.isOTWFirmwareUpdateInProgress();
150147
return { progress };
151148
}
149+
// Bootloader operations
150+
case DriverCommand.softResetAndRestart: {
151+
await this.driver.softResetAndRestart();
152+
return {};
153+
}
154+
case DriverCommand.enterBootloader: {
155+
await this.driver.enterBootloader();
156+
return {};
157+
}
158+
case DriverCommand.leaveBootloader: {
159+
await this.driver.leaveBootloader();
160+
return {};
161+
}
162+
// CC version queries
163+
case DriverCommand.getSupportedCCVersion: {
164+
const version = this.driver.getSupportedCCVersion(
165+
message.cc,
166+
message.nodeId,
167+
message.endpointIndex,
168+
);
169+
return { version };
170+
}
171+
case DriverCommand.getSafeCCVersion: {
172+
const version = this.driver.getSafeCCVersion(
173+
message.cc,
174+
message.nodeId,
175+
message.endpointIndex,
176+
);
177+
return { version };
178+
}
179+
// User agent
180+
case DriverCommand.updateUserAgent: {
181+
this.driver.updateUserAgent(message.components);
182+
return {};
183+
}
184+
// RSSI monitoring
185+
case DriverCommand.enableFrequentRSSIMonitoring: {
186+
this.driver.enableFrequentRSSIMonitoring(message.durationMs);
187+
return {};
188+
}
189+
case DriverCommand.disableFrequentRSSIMonitoring: {
190+
this.driver.disableFrequentRSSIMonitoring();
191+
return {};
192+
}
152193
default: {
153194
throw new UnknownCommandError(command);
154195
}

src/lib/driver/outgoing_message.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,16 @@ export interface DriverResultTypes {
2828
[DriverCommand.sendTestFrame]: { status?: TransmitStatus };
2929
[DriverCommand.firmwareUpdateOTW]: OTWFirmwareUpdateResultType;
3030
[DriverCommand.isOTWFirmwareUpdateInProgress]: { progress: boolean };
31+
// Bootloader operations
32+
[DriverCommand.softResetAndRestart]: Record<string, never>;
33+
[DriverCommand.enterBootloader]: Record<string, never>;
34+
[DriverCommand.leaveBootloader]: Record<string, never>;
35+
// CC version queries
36+
[DriverCommand.getSupportedCCVersion]: { version: number };
37+
[DriverCommand.getSafeCCVersion]: { version: number | undefined };
38+
// User agent
39+
[DriverCommand.updateUserAgent]: Record<string, never>;
40+
// RSSI monitoring
41+
[DriverCommand.enableFrequentRSSIMonitoring]: Record<string, never>;
42+
[DriverCommand.disableFrequentRSSIMonitoring]: Record<string, never>;
3143
}

0 commit comments

Comments
 (0)