Search in sources :

Example 1 with ZclClusterType

use of com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeEndpoint method getClusterClass.

private ZclCluster getClusterClass(int clusterId) {
    ZclClusterType clusterType = ZclClusterType.getValueById(clusterId);
    if (clusterType == null) {
        // Unsupported cluster
        logger.debug("{}: Unsupported cluster {}", getEndpointAddress(), clusterId);
        return null;
    }
    // Create a cluster class
    ZclCluster cluster = null;
    Constructor<? extends ZclCluster> constructor;
    // try {
    try {
        constructor = clusterType.getClusterClass().getConstructor(ZigBeeNetworkManager.class, ZigBeeEndpoint.class);
        cluster = constructor.newInstance(networkManager, this);
    } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        logger.debug("{}: Error instantiating cluster {}", getEndpointAddress(), clusterType);
        return null;
    }
    return cluster;
}
Also used : ZclClusterType(com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType) ZclCluster(com.zsmartsystems.zigbee.zcl.ZclCluster) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ZclCluster (com.zsmartsystems.zigbee.zcl.ZclCluster)1 ZclClusterType (com.zsmartsystems.zigbee.zcl.protocol.ZclClusterType)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1