Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper method to get firmware version from OTA cluster #443

Merged
merged 1 commit into from
Dec 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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