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

Improve command line interpretation of endpoint ID #1448

Merged
merged 2 commits into from
Nov 20, 2024
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 @@ -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
Loading