Skip to content

Commit

Permalink
Made OTA more robust by increasing retries and transfer timeouts (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Hofmann authored and cdjackson committed Apr 21, 2019
1 parent 476873d commit a2699cd
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,23 @@ public class ZclOtaUpgradeServer implements ZigBeeApplication {
/**
* Default transfer timeout period in milliseconds
*/
private final long TRANSFER_TIMEOUT_PERIOD = 30000;
private static final long TRANSFER_TIMEOUT_PERIOD = 300000;

/**
* Transfer timeout period in milliseconds
*/
private long transferTimeoutPeriod = TRANSFER_TIMEOUT_PERIOD;

/**
* The amount of retries to get the current firmware version
*/
private static final int AMOUNT_OF_RETRIES_TO_REQUEST_CURRENT_FW_VERSION = 10;

/**
* The sleep time before trying to request the current firmware version
*/
private static final long SLEEP_TIME_BEFORE_REQUESTING_CURRENT_FW_VERSION = 10000;

/**
* Field control value of 0x01 (bit 0 set) means that the client’s IEEE address is included in the payload. This
* indicates that the client is requesting a device specific file such as security credential, log or configuration;
Expand Down Expand Up @@ -436,8 +446,8 @@ public void run() {

// Attempt to get the current firmware version. As the device will be restarting, which could take
// some time to complete, we retry this a few times.
for (int cnt = 0; cnt < 10; cnt++) {
Thread.sleep(3000);
for (int cnt = 0; cnt < AMOUNT_OF_RETRIES_TO_REQUEST_CURRENT_FW_VERSION; cnt++) {
Thread.sleep(SLEEP_TIME_BEFORE_REQUESTING_CURRENT_FW_VERSION);
Integer fileVersion = cluster.getCurrentFileVersion(0);
if (fileVersion == null) {
continue;
Expand Down

0 comments on commit a2699cd

Please sign in to comment.