use of com.zsmartsystems.zigbee.zcl.clusters.general.DiscoverCommandsGeneratedResponse in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclGeneralCluster method discoverCommandsGeneratedResponse.
/**
* The Discover Commands Generated Response
* <p>
* The Discover Commands Generated Response is generated in response to a Discover Commands Generated
* command.
*
* @param discoveryComplete {@link Boolean} Discovery complete
* @param commandIdentifiers {@link List<Integer>} Command identifiers
* @return the {@link Future<CommandResult>} command result future
*/
public Future<CommandResult> discoverCommandsGeneratedResponse(Boolean discoveryComplete, List<Integer> commandIdentifiers) {
DiscoverCommandsGeneratedResponse command = new DiscoverCommandsGeneratedResponse();
// Set the fields
command.setDiscoveryComplete(discoveryComplete);
command.setCommandIdentifiers(commandIdentifiers);
return send(command);
}
use of com.zsmartsystems.zigbee.zcl.clusters.general.DiscoverCommandsGeneratedResponse in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclCluster method discoverCommandsGenerated.
/**
* Discovers the list of commands generated by the cluster on the remote device If the discovery is successful,
* users should call {@link ZclCluster#getSupportedCommandsGenerated()} to get the list of supported commands.
* <p>
* If the discovery has already been completed, and rediscover is false, then the future will complete immediately
* and the user can use existing results. Normally there should not be a need to set rediscover to true.
*
* @param rediscover true to perform a discovery even if it was previously completed
* @return Command future {@link Boolean} with the success of the discovery
*/
public Future<Boolean> discoverCommandsGenerated(final boolean rediscover) {
RunnableFuture<Boolean> future = new FutureTask<Boolean>(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
// cluster which would cause errors consolidating the responses
synchronized (supportedCommandsGenerated) {
// If we don't want to rediscover, and we already have the list of attributes, then return
if (!rediscover && !supportedCommandsGenerated.isEmpty()) {
return true;
}
int index = 0;
boolean complete = false;
Set<Integer> commands = new HashSet<Integer>();
do {
final DiscoverCommandsGenerated command = new DiscoverCommandsGenerated();
command.setClusterId(clusterId);
command.setDestinationAddress(zigbeeEndpoint.getEndpointAddress());
command.setStartCommandIdentifier(index);
command.setMaximumCommandIdentifiers(20);
CommandResult result = send(command).get();
if (result.isError()) {
return false;
}
DiscoverCommandsGeneratedResponse response = (DiscoverCommandsGeneratedResponse) result.getResponse();
complete = response.getDiscoveryComplete();
if (response.getCommandIdentifiers() != null) {
commands.addAll(response.getCommandIdentifiers());
index = Collections.max(commands) + 1;
}
} while (!complete);
supportedCommandsGenerated.clear();
supportedCommandsGenerated.addAll(commands);
}
return true;
}
});
// start the thread to execute it
new Thread(future).start();
return future;
}
Aggregations