use of com.zsmartsystems.zigbee.zcl.clusters.general.WriteAttributesResponse 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);
}
}
use of com.zsmartsystems.zigbee.zcl.clusters.general.WriteAttributesResponse in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclGeneralCluster method writeAttributesResponse.
/**
* The Write Attributes Response
* <p>
* The write attributes response command is generated in response to a write
* attributes command.
*
* @param records {@link List<WriteAttributeStatusRecord>} Records
* @return the {@link Future<CommandResult>} command result future
*/
public Future<CommandResult> writeAttributesResponse(List<WriteAttributeStatusRecord> records) {
WriteAttributesResponse command = new WriteAttributesResponse();
// Set the fields
command.setRecords(records);
return send(command);
}
Aggregations