use of com.zsmartsystems.zigbee.ZigBeeEndpoint in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleAttributeSupportedCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
if (args.length != 3) {
throw new IllegalArgumentException("Invalid number of arguments");
}
final ZigBeeEndpoint endpoint = getEndpoint(networkManager, args[1]);
final Integer clusterId = parseCluster(args[2]);
ZclCluster cluster = endpoint.getInputCluster(clusterId);
if (cluster != null) {
out.println("Using input cluster");
} else {
cluster = endpoint.getOutputCluster(clusterId);
if (cluster != null) {
out.println("Using output cluster");
} else {
out.println("Cluster not found");
return;
}
}
final Future<Boolean> future = cluster.discoverAttributes(false);
Boolean result = future.get();
if (result) {
out.println("Supported attributes for " + cluster.getClusterName() + " Cluster " + printClusterId(cluster.getClusterId()));
out.println("AttrId Data Type Name");
for (Integer attributeId : cluster.getSupportedAttributes()) {
out.print(" ");
ZclAttribute attribute = cluster.getAttribute(attributeId);
out.print(printAttributeId(attributeId));
if (attribute != null) {
out.print(" " + printZclDataType(attribute.getDataType()) + " " + attribute.getName());
}
out.println();
}
} else {
out.println("Failed to retrieve supported attributes");
}
}
use of com.zsmartsystems.zigbee.ZigBeeEndpoint in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleBindCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
if (args.length < 3) {
throw new IllegalArgumentException("Invalid number of arguments");
}
final int clusterId = parseCluster(args[1]);
final ZigBeeEndpoint source = getEndpoint(networkManager, args[2]);
ZclCluster cluster = source.getInputCluster(clusterId);
if (cluster == null) {
throw new IllegalArgumentException("Cluster '" + clusterId + "' not found.");
}
IeeeAddress destAddress;
int destEndpoint;
if (args.length >= 4) {
ZigBeeEndpoint destination = getEndpoint(networkManager, args[3]);
destAddress = destination.getIeeeAddress();
destEndpoint = destination.getEndpointId();
} else {
destAddress = networkManager.getNode(0).getIeeeAddress();
destEndpoint = 1;
}
final CommandResult response = cluster.bind(destAddress, destEndpoint).get();
processDefaultResponse(response, out);
}
use of com.zsmartsystems.zigbee.ZigBeeEndpoint in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleDescribeEndpointCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
if (args.length != 2) {
throw new IllegalArgumentException("Invalid number of arguments");
}
final ZigBeeEndpoint endpoint = getEndpoint(networkManager, args[1]);
out.println("IEEE Address : " + endpoint.getIeeeAddress());
out.println("Network Address : " + endpoint.getParentNode().getNetworkAddress());
out.println("Endpoint : " + endpoint.getEndpointId());
out.println("Device Profile : " + ZigBeeProfileType.getProfileType(endpoint.getProfileId()) + String.format(" (0x%04X)", endpoint.getProfileId()));
out.println("Device Version : " + endpoint.getDeviceVersion());
out.println("Input Clusters : ");
printClusters(endpoint, true, out);
out.println("Output Clusters : ");
printClusters(endpoint, false, out);
}
use of com.zsmartsystems.zigbee.ZigBeeEndpoint in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleDeviceInformationCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException {
if (args.length < 2) {
throw new IllegalArgumentException("Invalid number of arguments");
}
Map<String, String> commands = new TreeMap<>();
long refresh = Long.MAX_VALUE;
for (int cnt = 2; cnt < args.length; cnt++) {
String arg = args[cnt];
String upperArg = arg.toUpperCase();
if ("REFRESH".equals(upperArg)) {
refresh = 0;
continue;
}
commands.put(upperArg, "");
}
if (commands.isEmpty()) {
commands.put("MANUFACTURER", "");
commands.put("MODEL", "");
commands.put("APPVERSION", "");
commands.put("STKVERSION", "");
commands.put("ZCLVERSION", "");
commands.put("HWVERSION", "");
commands.put("DATE", "");
}
final ZigBeeEndpoint endpoint = getEndpoint(networkManager, args[1]);
if (endpoint == null) {
throw new IllegalArgumentException("Endpoint '" + args[1] + "' not found.");
}
ZclBasicCluster basicCluster = (ZclBasicCluster) endpoint.getInputCluster(0);
if (basicCluster == null) {
throw new IllegalArgumentException("Can't find basic cluster for " + endpoint.getEndpointAddress());
}
for (String command : commands.keySet()) {
out.println("Requesting " + command);
Object response = null;
switch(command) {
case "MANUFACTURER":
response = basicCluster.getManufacturerName(refresh);
break;
case "MODEL":
response = basicCluster.getModelIdentifier(refresh);
break;
case "APPVERSION":
response = basicCluster.getApplicationVersion(refresh);
break;
case "STKVERSION":
response = basicCluster.getStackVersion(refresh);
break;
case "ZCLVERSION":
response = basicCluster.getZclVersion(refresh);
break;
case "HWVERSION":
response = basicCluster.getHwVersion(refresh);
break;
case "DATE":
response = basicCluster.getDateCode(refresh);
break;
default:
out.println("Unknown info type: " + command);
break;
}
if (response != null) {
commands.put(command, response.toString());
}
}
out.println("Node Info Value");
for (Entry<String, String> command : commands.entrySet()) {
out.println(String.format("%-12s ", command.getKey()) + command.getValue());
}
}
use of com.zsmartsystems.zigbee.ZigBeeEndpoint in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeNodeServiceDiscoverer method requestActiveEndpoints.
/**
* Get the active endpoints for a node
*
* @return true if the message was processed ok
* @throws ExecutionException
* @throws InterruptedException
*/
private boolean requestActiveEndpoints() throws InterruptedException, ExecutionException {
final ActiveEndpointsRequest activeEndpointsRequest = new ActiveEndpointsRequest();
activeEndpointsRequest.setDestinationAddress(new ZigBeeEndpointAddress(node.getNetworkAddress()));
activeEndpointsRequest.setNwkAddrOfInterest(node.getNetworkAddress());
CommandResult response = networkManager.unicast(activeEndpointsRequest, activeEndpointsRequest).get();
final ActiveEndpointsResponse activeEndpointsResponse = (ActiveEndpointsResponse) response.getResponse();
logger.debug("{}: Node SVC Discovery ActiveEndpointsResponse returned {}", node.getIeeeAddress(), response);
if (activeEndpointsResponse == null) {
return false;
}
// Get the simple descriptors for all endpoints
List<ZigBeeEndpoint> endpoints = new ArrayList<ZigBeeEndpoint>();
for (final int endpointId : activeEndpointsResponse.getActiveEpList()) {
ZigBeeEndpoint endpoint = getSimpleDescriptor(endpointId);
if (endpoint == null) {
return false;
}
endpoints.add(endpoint);
}
// All endpoints have been received, so add them to the node
for (ZigBeeEndpoint endpoint : endpoints) {
node.addEndpoint(endpoint);
}
return true;
}
Aggregations