Skip to content

Commit

Permalink
Improve command line interpretation of endpoint ID (#1448)
Browse files Browse the repository at this point in the history
* Improve command line interpretation of endpoint ID

Signed-off-by: Chris Jackson <[email protected]>
  • Loading branch information
cdjackson authored Nov 20, 2024
1 parent fec6047 commit 5528094
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,22 @@ protected ZigBeeNode getNode(ZigBeeNetworkManager networkManager, final String n
*/
protected ZigBeeEndpoint getEndpoint(final ZigBeeNetworkManager networkManager, final String endpointId)
throws IllegalArgumentException {
for (final ZigBeeNode node : networkManager.getNodes()) {
for (final ZigBeeEndpoint endpoint : node.getEndpoints()) {
if (endpointId.equals(node.getNetworkAddress() + "/" + endpoint.getEndpointId())) {
return endpoint;
}
}
String[] endpointParts = endpointId.split("/");
if (endpointParts.length != 2) {
throw new IllegalArgumentException("Invalid endpoint format '" + endpointId + "'");
}
ZigBeeNode node = getNode(networkManager, endpointParts[0]);
int endpointNumber;
try {
endpointNumber = Integer.parseInt(endpointParts[1]);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid endpoint number '" + endpointParts[1] + "'");
}
ZigBeeEndpoint endpoint = node.getEndpoint(endpointNumber);
if (endpoint == null) {
throw new IllegalArgumentException("Endpoint '" + endpointId + "' is not found");
}
throw new IllegalArgumentException("Endpoint '" + endpointId + "' is not found");
return endpoint;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,17 @@ public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStr
if (result.isSuccess()) {
final ReadReportingConfigurationResponse response = result.getResponse();
final AttributeReportingStatusRecord attributeReportingStatusRecord = response.getRecords().get(0);

final ZclStatus statusCode = attributeReportingStatusRecord.getStatus();
if (statusCode == ZclStatus.SUCCESS) {
out.println("Cluster " + response.getClusterId() + ", Attribute "
+ attributeReportingStatusRecord.getAttributeIdentifier() + ", type "
+ attributeReportingStatusRecord.getAttributeDataType() + ", minimum reporting interval: "
+ attributeReportingStatusRecord.getMinimumReportingInterval() + ", maximum reporting interval: "
+ attributeReportingStatusRecord.getMaximumReportingInterval() + ", timeout: "
+ attributeReportingStatusRecord.getTimeoutPeriod());
+ attributeReportingStatusRecord.getMinimumReportingInterval()
+ ", maximum reporting interval: "
+ attributeReportingStatusRecord.getMaximumReportingInterval() + ", timeout: "
+ (attributeReportingStatusRecord.getTimeoutPeriod() == 0 ? "N/A"
: attributeReportingStatusRecord.getTimeoutPeriod()));
} else {
out.println("Attribute value read error: " + statusCode);
}
Expand Down

0 comments on commit 5528094

Please sign in to comment.