Search in sources :

Example 11 with ZclAttribute

use of com.zsmartsystems.zigbee.zcl.ZclAttribute in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclAlarmsCluster method initializeAttributes.

// Attribute initialisation
protected Map<Integer, ZclAttribute> initializeAttributes() {
    Map<Integer, ZclAttribute> attributeMap = new ConcurrentHashMap<Integer, ZclAttribute>(1);
    attributeMap.put(ATTR_ALARMCOUNT, new ZclAttribute(ZclClusterType.ALARMS, ATTR_ALARMCOUNT, "AlarmCount", ZclDataType.UNSIGNED_16_BIT_INTEGER, false, true, false, false));
    return attributeMap;
}
Also used : ZclAttribute(com.zsmartsystems.zigbee.zcl.ZclAttribute) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 12 with ZclAttribute

use of com.zsmartsystems.zigbee.zcl.ZclAttribute in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclBasicCluster method initializeAttributes.

// Attribute initialisation
protected Map<Integer, ZclAttribute> initializeAttributes() {
    Map<Integer, ZclAttribute> attributeMap = new ConcurrentHashMap<Integer, ZclAttribute>(14);
    attributeMap.put(ATTR_ZCLVERSION, new ZclAttribute(ZclClusterType.BASIC, ATTR_ZCLVERSION, "ZCLVersion", ZclDataType.UNSIGNED_8_BIT_INTEGER, true, true, false, false));
    attributeMap.put(ATTR_APPLICATIONVERSION, new ZclAttribute(ZclClusterType.BASIC, ATTR_APPLICATIONVERSION, "ApplicationVersion", ZclDataType.UNSIGNED_8_BIT_INTEGER, true, true, false, false));
    attributeMap.put(ATTR_STACKVERSION, new ZclAttribute(ZclClusterType.BASIC, ATTR_STACKVERSION, "StackVersion", ZclDataType.UNSIGNED_8_BIT_INTEGER, true, true, false, false));
    attributeMap.put(ATTR_HWVERSION, new ZclAttribute(ZclClusterType.BASIC, ATTR_HWVERSION, "HWVersion", ZclDataType.UNSIGNED_8_BIT_INTEGER, true, true, false, false));
    attributeMap.put(ATTR_MANUFACTURERNAME, new ZclAttribute(ZclClusterType.BASIC, ATTR_MANUFACTURERNAME, "ManufacturerName", ZclDataType.CHARACTER_STRING, true, true, false, false));
    attributeMap.put(ATTR_MODELIDENTIFIER, new ZclAttribute(ZclClusterType.BASIC, ATTR_MODELIDENTIFIER, "ModelIdentifier", ZclDataType.CHARACTER_STRING, true, true, false, false));
    attributeMap.put(ATTR_DATECODE, new ZclAttribute(ZclClusterType.BASIC, ATTR_DATECODE, "DateCode", ZclDataType.CHARACTER_STRING, true, true, false, false));
    attributeMap.put(ATTR_POWERSOURCE, new ZclAttribute(ZclClusterType.BASIC, ATTR_POWERSOURCE, "PowerSource", ZclDataType.ENUMERATION_8_BIT, true, true, false, false));
    attributeMap.put(ATTR_LOCATIONDESCRIPTION, new ZclAttribute(ZclClusterType.BASIC, ATTR_LOCATIONDESCRIPTION, "LocationDescription", ZclDataType.CHARACTER_STRING, true, true, true, false));
    attributeMap.put(ATTR_PHYSICALENVIRONMENT, new ZclAttribute(ZclClusterType.BASIC, ATTR_PHYSICALENVIRONMENT, "PhysicalEnvironment", ZclDataType.ENUMERATION_8_BIT, true, true, true, false));
    attributeMap.put(ATTR_DEVICEENABLED, new ZclAttribute(ZclClusterType.BASIC, ATTR_DEVICEENABLED, "DeviceEnabled", ZclDataType.BOOLEAN, true, true, true, false));
    attributeMap.put(ATTR_ALARMMASK, new ZclAttribute(ZclClusterType.BASIC, ATTR_ALARMMASK, "AlarmMask", ZclDataType.BITMAP_8_BIT, true, true, true, false));
    attributeMap.put(ATTR_DISABLELOCALCONFIG, new ZclAttribute(ZclClusterType.BASIC, ATTR_DISABLELOCALCONFIG, "DisableLocalConfig", ZclDataType.BITMAP_8_BIT, true, true, true, false));
    attributeMap.put(ATTR_SWBUILDID, new ZclAttribute(ZclClusterType.BASIC, ATTR_SWBUILDID, "SWBuildID", ZclDataType.CHARACTER_STRING, false, true, false, false));
    return attributeMap;
}
Also used : ZclAttribute(com.zsmartsystems.zigbee.zcl.ZclAttribute) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 13 with ZclAttribute

use of com.zsmartsystems.zigbee.zcl.ZclAttribute in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeConsoleReportingConfigCommand method process.

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
    if (args.length != 4) {
        throw new IllegalArgumentException("Invalid number of arguments");
    }
    final ZigBeeEndpoint endpoint = getEndpoint(networkManager, args[1]);
    final int clusterId = parseCluster(args[3]);
    final ZclCluster cluster;
    final String direction = args[2].toUpperCase();
    if ("IN".equals(direction)) {
        cluster = endpoint.getInputCluster(clusterId);
    } else if ("OUT".equals(direction)) {
        cluster = endpoint.getOutputCluster(clusterId);
    } else {
        throw new IllegalArgumentException("Cluster direction must be IN or OUT");
    }
    final int attributeId = parseAttribute(args[4]);
    final ZclAttribute attribute = cluster.getAttribute(attributeId);
    final CommandResult result = cluster.getReporting(attribute).get();
    if (result.isSuccess()) {
        final ReadAttributesResponse response = result.getResponse();
        final ZclStatus statusCode = response.getRecords().get(0).getStatus();
        if (statusCode == ZclStatus.SUCCESS) {
            out.println("Cluster " + response.getClusterId() + ", Attribute " + response.getRecords().get(0).getAttributeIdentifier() + ", type " + response.getRecords().get(0).getAttributeDataType() + ", value: " + response.getRecords().get(0).getAttributeValue());
        } else {
            out.println("Attribute value read error: " + statusCode);
        }
    } else {
        out.println("Error executing command: " + result);
    }
}
Also used : ZclStatus(com.zsmartsystems.zigbee.zcl.ZclStatus) ZclAttribute(com.zsmartsystems.zigbee.zcl.ZclAttribute) ReadAttributesResponse(com.zsmartsystems.zigbee.zcl.clusters.general.ReadAttributesResponse) ZclCluster(com.zsmartsystems.zigbee.zcl.ZclCluster) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) CommandResult(com.zsmartsystems.zigbee.CommandResult)

Example 14 with ZclAttribute

use of com.zsmartsystems.zigbee.zcl.ZclAttribute in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeConsoleReportingSubscribeCommand method process.

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
    if (args.length < 7) {
        throw new IllegalArgumentException("Invalid number of arguments");
    }
    final ZigBeeEndpoint endpoint = getEndpoint(networkManager, args[1]);
    final int clusterId = parseCluster(args[3]);
    final ZclCluster cluster;
    final String direction = args[2].toUpperCase();
    if ("IN".equals(direction)) {
        cluster = endpoint.getInputCluster(clusterId);
    } else if ("OUT".equals(direction)) {
        cluster = endpoint.getOutputCluster(clusterId);
    } else {
        throw new IllegalArgumentException("Cluster direction must be IN or OUT");
    }
    final int minInterval;
    try {
        minInterval = Integer.parseInt(args[5]);
    } catch (final NumberFormatException e) {
        throw new IllegalArgumentException("Min Interval has invalid format");
    }
    final int maxInterval;
    try {
        maxInterval = Integer.parseInt(args[6]);
    } catch (final NumberFormatException e) {
        throw new IllegalArgumentException("Max Interval has invalid format");
    }
    final int attributeId = parseAttribute(args[4]);
    final ZclAttribute attribute = cluster.getAttribute(attributeId);
    final Object reportableChange;
    if (args.length > 6) {
        reportableChange = parseValue(args[7], attribute.getDataType());
    } else {
        reportableChange = null;
    }
    final CommandResult result = cluster.setReporting(attribute, minInterval, maxInterval, reportableChange).get();
    if (result.isSuccess()) {
        final ConfigureReportingResponse response = result.getResponse();
        final ZclStatus statusCode = response.getRecords().get(0).getStatus();
        if (statusCode == ZclStatus.SUCCESS) {
            out.println("Attribute value configure reporting success.");
        } else {
            out.println("Attribute value configure reporting error: " + statusCode);
        }
    } else {
        out.println("Error executing command: " + result);
    }
}
Also used : ZclStatus(com.zsmartsystems.zigbee.zcl.ZclStatus) ZclAttribute(com.zsmartsystems.zigbee.zcl.ZclAttribute) ZclCluster(com.zsmartsystems.zigbee.zcl.ZclCluster) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) CommandResult(com.zsmartsystems.zigbee.CommandResult) ConfigureReportingResponse(com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingResponse)

Example 15 with ZclAttribute

use of com.zsmartsystems.zigbee.zcl.ZclAttribute in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeConsoleAttributeWriteCommand method process.

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
    if (args.length != 5) {
        throw new IllegalArgumentException("Invalid number of arguments");
    }
    final ZigBeeEndpoint endpoint = getEndpoint(networkManager, args[1]);
    final int clusterId = parseCluster(args[3]);
    final int attributeId = parseAttribute(args[4]);
    final ZclCluster cluster;
    final String direction = args[2].toUpperCase();
    if ("IN".equals(direction)) {
        cluster = endpoint.getInputCluster(clusterId);
    } else if ("OUT".equals(direction)) {
        cluster = endpoint.getOutputCluster(clusterId);
    } else {
        throw new IllegalArgumentException("Cluster direction must be IN or OUT");
    }
    final ZclAttribute attribute = cluster.getAttribute(attributeId);
    final Object value = parseValue(args[4], attribute.getDataType());
    final CommandResult result = cluster.write(attribute, value).get();
    if (result.isSuccess()) {
        final WriteAttributesResponse response = result.getResponse();
        final int statusCode = response.getRecords().get(0).getStatus();
        if (statusCode == 0) {
            out.println("Attribute value write success.");
        } else {
            final ZclStatus status = ZclStatus.getStatus((byte) statusCode);
            out.println("Attribute value write error: " + status);
        }
    } else {
        out.println("Error executing command: " + result);
    }
}
Also used : ZclStatus(com.zsmartsystems.zigbee.zcl.ZclStatus) ZclAttribute(com.zsmartsystems.zigbee.zcl.ZclAttribute) WriteAttributesResponse(com.zsmartsystems.zigbee.zcl.clusters.general.WriteAttributesResponse) ZclCluster(com.zsmartsystems.zigbee.zcl.ZclCluster) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) CommandResult(com.zsmartsystems.zigbee.CommandResult)

Aggregations

ZclAttribute (com.zsmartsystems.zigbee.zcl.ZclAttribute)34 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)28 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)6 ZclCluster (com.zsmartsystems.zigbee.zcl.ZclCluster)6 CommandResult (com.zsmartsystems.zigbee.CommandResult)5 ZclStatus (com.zsmartsystems.zigbee.zcl.ZclStatus)5 ConfigureReportingResponse (com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingResponse)2 ReadAttributesResponse (com.zsmartsystems.zigbee.zcl.clusters.general.ReadAttributesResponse)2 WriteAttributesResponse (com.zsmartsystems.zigbee.zcl.clusters.general.WriteAttributesResponse)1