Search in sources :

Example 1 with ConfigureReportingResponse

use of com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeConsoleReportingUnsubscribeCommand method process.

@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
    if (args.length != 6) {
        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.setReporting(attribute, 0, 0xFFFF, null).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 2 with ConfigureReportingResponse

use of com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingResponse 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 3 with ConfigureReportingResponse

use of com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclGeneralCluster method configureReportingResponse.

/**
 * The Configure Reporting Response
 * <p>
 * The Configure Reporting Response command is generated in response to a
 * Configure Reporting command.
 *
 * @param status {@link ZclStatus} Status
 * @param records {@link List<AttributeStatusRecord>} Records
 * @return the {@link Future<CommandResult>} command result future
 */
public Future<CommandResult> configureReportingResponse(ZclStatus status, List<AttributeStatusRecord> records) {
    ConfigureReportingResponse command = new ConfigureReportingResponse();
    // Set the fields
    command.setStatus(status);
    command.setRecords(records);
    return send(command);
}
Also used : ConfigureReportingResponse(com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingResponse)

Aggregations

ConfigureReportingResponse (com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingResponse)3 CommandResult (com.zsmartsystems.zigbee.CommandResult)2 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)2 ZclAttribute (com.zsmartsystems.zigbee.zcl.ZclAttribute)2 ZclCluster (com.zsmartsystems.zigbee.zcl.ZclCluster)2 ZclStatus (com.zsmartsystems.zigbee.zcl.ZclStatus)2