zwave-js / node-red-contrib-zwave-js

The most powerful, high performing and highly polished Z-Wave node for Node-RED based on Z-Wave JS. If you want a fully featured Z-Wave framework in your Node-RED instance, you have found it.
MIT License
47 stars 6 forks source link

Implement Firmware Updates #69

Closed marcus-j-davies closed 3 years ago

marcus-j-davies commented 3 years ago

And so it begins

// Extract the firmware from a given firmware file
let actualFirmware: Firmware;
try {
    const format = guessFirmwareFileFormat(filename, rawData);
    actualFirmware = extractFirmware(rawData, format);
} catch (e) {
    // handle the error, then abort the update
}

// try the update
try {
    await this.driver.controller.nodes
        .get(nodeId)!
        .beginFirmwareUpdate(
            actualFirmware.data,
            actualFirmware.firmwareTarget,
        );
    console.log(`Node ${nodeId}: Firmware update started`);
} catch (e) {
    // handle error
}