The Rate Limit Policy API allows you to limit the rate of the OTA upgrades by defining the upgrade interval and upgrade delay. The rate limit policy can be created in two ways, either by defining the upgrade delay and upgrade speed like below:
RateLimitPolicyBuilder builder = new RateLimitPolicyBuilder(); builder.setOtaUpgradeDelay(Duration.ofSeconds(0)); //upgrade speed should be between 0 % (min speed) to 100 % (max speed) builder.setOtaUpgradeSpeed(100); RateLimitPolicy policy = builder.create();
Or by defining the upgrade delay and upgrade interval like below:
RateLimitPolicyBuilder builder = new RateLimitPolicyBuilder(); builder.setOtaUpgradeDelay(Duration.ofSeconds(0)); //upgrade interval should be between 0 millisecond (max speed) to 65534 millisecond (min speed) builder.setOtaUpgradeInterval(Duration.ofMillis(1)); RateLimitPolicy policy = builder.create();
In order to create a rate limit policy, both upgrade delay and upgrade speed or upgrade delay and upgrade interval must be defined.
Under the hood, upgrade speed gets converted to its corresponding upgrade interval.
Once the rate limit policy object is created, it can be applied using the setRateLimitPolicy method, in the InternalOtaHandler class, before or after an upgrade is started. So either doing the following:
Gateway gw = ... Device device = ... gw.getInternalOtaHandler().setRateLimitPolicy(device, policy); device.startOtaUpgrade();
or:
Gateway gw = ... Device device = ... device.startOtaUpgrade(); gw.getInternalOtaHandler().setRateLimitPolicy(device, policy);
Rate limit policy can be reset to default by applying the resetRateRateLimitPolicy method like below. This will apply a upgradeDelay of 0 seconds and upgradeInterval of 1 millisecond.
gw.getInternalOtaHandler().resetRateLimitPolicy(device);
The OTA upgrade can also be paused mid upgrade using the pauseOtaUpgrade method like below:
gw.getInternalOtaHandler().pauseOtaUpgrade(d);
The OTA upgrade that was paused can be unpaused using the unpauseOtaUpgrade method like below:
gw.getInternalOtaHandler().unpauseOtaUpgrade(d);
Triggering unpause on a paused upgrade does not take place immediately; it can take up to 15 seconds for it to unpause. This is because the device is set to poll the gateway every 15 seconds when paused.
Related Articles
Filter by label
There are no items with the selected labels at this time.