Search in sources :

Example 6 with ZigBeeEndpoint

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");
    }
}
Also used : ZclAttribute(com.zsmartsystems.zigbee.zcl.ZclAttribute) ZclCluster(com.zsmartsystems.zigbee.zcl.ZclCluster) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint)

Example 7 with ZigBeeEndpoint

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);
}
Also used : ZclCluster(com.zsmartsystems.zigbee.zcl.ZclCluster) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) CommandResult(com.zsmartsystems.zigbee.CommandResult)

Example 8 with ZigBeeEndpoint

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);
}
Also used : ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint)

Example 9 with ZigBeeEndpoint

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());
    }
}
Also used : ZclBasicCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclBasicCluster) TreeMap(java.util.TreeMap) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint)

Example 10 with ZigBeeEndpoint

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;
}
Also used : ActiveEndpointsRequest(com.zsmartsystems.zigbee.zdo.command.ActiveEndpointsRequest) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ArrayList(java.util.ArrayList) ActiveEndpointsResponse(com.zsmartsystems.zigbee.zdo.command.ActiveEndpointsResponse) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) CommandResult(com.zsmartsystems.zigbee.CommandResult)

Aggregations

ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)25 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)12 ZigBeeNode (com.zsmartsystems.zigbee.ZigBeeNode)12 Test (org.junit.Test)10 CommandResult (com.zsmartsystems.zigbee.CommandResult)9 ZclCluster (com.zsmartsystems.zigbee.zcl.ZclCluster)8 ZclOnOffCluster (com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster)8 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)6 ZclAttribute (com.zsmartsystems.zigbee.zcl.ZclAttribute)6 ZigBeeCommand (com.zsmartsystems.zigbee.ZigBeeCommand)5 ZclStatus (com.zsmartsystems.zigbee.zcl.ZclStatus)5 ArrayList (java.util.ArrayList)4 ZigBeeNetworkManager (com.zsmartsystems.zigbee.ZigBeeNetworkManager)2 ConfigureReportingResponse (com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingResponse)2 ReadAttributesResponse (com.zsmartsystems.zigbee.zcl.clusters.general.ReadAttributesResponse)2 HashSet (java.util.HashSet)2 ZigBeeOtaFile (com.zsmartsystems.zigbee.app.otaserver.ZigBeeOtaFile)1 ZigBeeOtaServer (com.zsmartsystems.zigbee.app.otaserver.ZigBeeOtaServer)1 ZigBeeOtaServerStatus (com.zsmartsystems.zigbee.app.otaserver.ZigBeeOtaServerStatus)1 ZigBeeOtaStatusCallback (com.zsmartsystems.zigbee.app.otaserver.ZigBeeOtaStatusCallback)1