Skip to content

Commit

Permalink
Fix minor bugs in on/off converter (#272)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <chris@cd-jackson.com>
  • Loading branch information
cdjackson authored and hsudbrock committed Oct 8, 2018
1 parent 721afae commit ba25912
Showing 1 changed file with 7 additions and 14 deletions.
Expand Up @@ -66,6 +66,8 @@ public boolean initializeConverter() {
pollingPeriod = POLLING_PERIOD_HIGH;
}
} else {
logger.error("{}: Error 0x{} setting server binding", endpoint.getIeeeAddress(),
Integer.toHexString(bindResponse.getStatusCode()));
pollingPeriod = POLLING_PERIOD_HIGH;
}
} catch (InterruptedException | ExecutionException e) {
Expand All @@ -79,18 +81,12 @@ public boolean initializeConverter() {
if (clusterOnOffClient != null) {
try {
CommandResult bindResponse = clusterOnOffClient.bind().get();
if (bindResponse.isSuccess()) {
// Configure reporting - no faster than once per second - no slower than 10 minutes.
CommandResult reportingResponse = clusterOnOffClient
.setOnOffReporting(1, REPORTING_PERIOD_DEFAULT_MAX).get();
if (reportingResponse.isError()) {
pollingPeriod = POLLING_PERIOD_HIGH;
}
} else {
pollingPeriod = POLLING_PERIOD_HIGH;
if (!bindResponse.isSuccess()) {
logger.error("{}: Error 0x{} setting client binding", endpoint.getIeeeAddress(),
Integer.toHexString(bindResponse.getStatusCode()));
}
} catch (InterruptedException | ExecutionException e) {
logger.error("{}: Exception setting reporting ", endpoint.getIeeeAddress(), e);
logger.error("{}: Exception setting binding ", endpoint.getIeeeAddress(), e);
}

// Add the command listener
Expand All @@ -105,7 +101,7 @@ public void disposeConverter() {
logger.debug("{}: Closing device on/off cluster", endpoint.getIeeeAddress());

if (clusterOnOffClient != null) {
clusterOnOffClient.removeAttributeListener(this);
clusterOnOffClient.removeCommandListener(this);
}
if (clusterOnOffServer != null) {
clusterOnOffServer.removeAttributeListener(this);
Expand All @@ -114,9 +110,6 @@ public void disposeConverter() {

@Override
public void handleRefresh() {
if (clusterOnOffClient != null) {
clusterOnOffClient.getOnOff(0);
}
if (clusterOnOffServer != null) {
clusterOnOffServer.getOnOff(0);
}
Expand Down

0 comments on commit ba25912

Please sign in to comment.