Skip to content

Commit

Permalink
Add helper method to get firmware version from OTA cluster
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <[email protected]>
  • Loading branch information
cdjackson committed Dec 1, 2018
1 parent 05e100a commit 83598cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,19 @@ public void run() {
return false;
}

/**
* The file version of the running firmware image on the device. The information is available for the server to
* query via ZCL read attribute command. The attribute is optional on the client.
* <p>
* This calls the synchronous method in the cluster, and always performs an update (ie will not use cached data) to
* ensure it is updated following any OTA upgrade operation.
*
* @return the current firmware version on the remote device
*/
public Integer getCurrentFileVersion() {
return cluster.getCurrentFileVersion(Long.MAX_VALUE);
}

/**
* Send an updated status on OTA progress to the listeners
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ public Future<CommandResult> answer(InvocationOnMock invocation) {
assertTrue(notifyCommand.getQueryJitter() >= 1 && notifyCommand.getQueryJitter() <= 100);
}

@Test
public void getCurrentFileVersion() {
ZclOtaUpgradeCluster cluster = Mockito.mock(ZclOtaUpgradeCluster.class);
Mockito.when(cluster.getCurrentFileVersion(ArgumentMatchers.anyLong())).thenReturn(1234);

ZclOtaUpgradeServer server = new ZclOtaUpgradeServer();
server.appStartup(cluster);
assertEquals(Integer.valueOf(1234), server.getCurrentFileVersion());
}

@Override
public void otaStatusUpdate(ZigBeeOtaServerStatus status, int percent) {
otaStatusCapture.add(status);
Expand Down

0 comments on commit 83598cc

Please sign in to comment.