Skip to content

Commit

Permalink
refactor: migrate OTA firmware updates to tasks (#7256)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Oct 9, 2024
1 parent 37629fa commit 387a14c
Show file tree
Hide file tree
Showing 5 changed files with 557 additions and 459 deletions.
8 changes: 6 additions & 2 deletions packages/zwave-js/src/lib/driver/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2630,6 +2630,10 @@ export class Driver extends TypedEventEmitter<DriverEventCallbacks>
} catch {
// ignore
}

// No need to keep the node awake longer than necessary
node.keepAwake = false;
this.debounceSendNodeToSleep(node);
}
}

Expand Down Expand Up @@ -4144,7 +4148,7 @@ export class Driver extends TypedEventEmitter<DriverEventCallbacks>
"Attempting to recover controller again...",
"warn",
);
void this.softReset().catch(() => {
void this.softResetInternal(true).catch(() => {
this.driverLog.print(
"Automatic controller recovery failed. Returning to normal operation and hoping for the best.",
"warn",
Expand Down Expand Up @@ -4173,7 +4177,7 @@ export class Driver extends TypedEventEmitter<DriverEventCallbacks>
);

// Execute the soft-reset asynchronously
void this.softReset().then(() => {
void this.softResetInternal(true).then(() => {
// The controller responded. It is no longer unresponsive.

// Re-queue the transaction, so it can get handled next.
Expand Down
5 changes: 5 additions & 0 deletions packages/zwave-js/src/lib/driver/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ export type TaskTag =
// Rebuild routes for a single node
id: "rebuild-node-routes";
nodeId: number;
}
| {
// Perform an OTA firmware update for a node
id: "firmware-update-ota";
nodeId: number;
};

export class TaskScheduler {
Expand Down
Loading

0 comments on commit 387a14c

Please sign in to comment.