Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Remove duplicate firmware-update related status keys in twin (#209)
Browse files Browse the repository at this point in the history
* Updating the key name of the reported device firmware update property, so that we won't have two reported properties: 'FirmwareUpdateStatus' and 'DeviceMethodStatus', one of which is always null.

* PR feedback.

* PR feedback.
  • Loading branch information
peterfelts authored and ppathan committed May 4, 2018
1 parent 2d2a92d commit ca0c8bb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Services/data/devicemodels/scripts/FirmwareUpdate-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var state = {
// Default device properties
var properties = {
Firmware: "1.0.0",
DeviceMethodStatus: "Updating Firmware"
FirmwareUpdateStatus: "Updating Firmware"
};

/**
Expand Down Expand Up @@ -58,33 +58,33 @@ function main(context, previousState, previousProperties) {
// Reboot - devices goes offline and comes online after 20 seconds
log("Executing 'FirmwareUpdate' JavaScript method; Firmware version passed:" + context.Firmware);

var DeviceMethodStatusKey = "DeviceMethodStatus";
var DevicePropertyKey = "FirmwareUpdateStatus";
var FirmwareKey = "Firmware";

// update the status to offline & firmware updating
state.online = false;
state.CalculateRandomizedTelemetry = false;
var status = "Command received, updating firmware version to ";
status = status.concat(context.Firmware);
updateProperty(DeviceMethodStatusKey, status);
updateProperty(DevicePropertyKey, status);
sleep(5000);

log("Image Downloading...");
status = "Image Downloading...";
updateProperty(DeviceMethodStatusKey, status);
updateProperty(DevicePropertyKey, status);
sleep(7500);

log("Executing firmware update simulation function, firmware version passed:" + context.Firmware);
status = "Downloaded, applying firmware...";
updateProperty(DeviceMethodStatusKey, status);
updateProperty(DevicePropertyKey, status);
sleep(5000);

status = "Rebooting...";
updateProperty(DeviceMethodStatusKey, status);
updateProperty(DevicePropertyKey, status);
sleep(5000);

status = "Firmware Updated.";
updateProperty(DeviceMethodStatusKey, status);
updateProperty(DevicePropertyKey, status);
properties.Firmware = context.Firmware;
updateProperty(FirmwareKey, context.Firmware);
sleep(7500);
Expand Down

0 comments on commit ca0c8bb

Please sign in to comment.