Skip to content

Commit

Permalink
fix: prevent fw updates when update in progress (#2984)
Browse files Browse the repository at this point in the history
Fixes #2983
  • Loading branch information
robertsLando committed Feb 27, 2023
1 parent fd5fe1a commit dad95b4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/ZwaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,12 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {

async firmwareUpdateOTA(nodeId: number, updates: FirmwareUpdateFileInfo[]) {
if (this.driverReady) {
const node = this._nodes.get(nodeId)

if (node.firmwareUpdate) {
throw Error(`Firmware update already in progress`)
}

const result = await this._driver.controller.firmwareUpdateOTA(
nodeId,
updates
Expand Down Expand Up @@ -2480,6 +2486,12 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
throw Error(`Node ${nodeId} not found`)
}

const node = this._nodes.get(nodeId)

if (node.firmwareUpdate) {
throw Error(`Firmware update already in progress`)
}

const firmwares: Firmware[] = []

for (const f of files) {
Expand Down Expand Up @@ -2525,6 +2537,12 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
throw Error(`Node ${nodeId} not found`)
}

const node = this._nodes.get(nodeId)

if (node.firmwareUpdate) {
throw Error(`Firmware update already in progress`)
}

if (!(data instanceof Buffer)) {
throw Error('Data must be a buffer')
}
Expand Down

0 comments on commit dad95b4

Please sign in to comment.