/// <summary> /// The Discover Commands Generated Response /// /// The Discover Commands Generated Response is generated in response to a Discover Commands Generated /// command. /// /// @param discoveryComplete {@link bool} Discovery complete /// @param commandIdentifiers {@link List<byte>} Command identifiers /// @return the Task<CommandResult> command result Task /// </summary> public Task <CommandResult> DiscoverCommandsGeneratedResponse(bool discoveryComplete, List <byte> commandIdentifiers) { DiscoverCommandsGeneratedResponse command = new DiscoverCommandsGeneratedResponse(); // Set the fields command.DiscoveryComplete = discoveryComplete; command.CommandIdentifiers = commandIdentifiers; return(Send(command)); }
/** * 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 Task <bool> DiscoverCommandsGenerated(bool rediscover) { return(Task.Run(() => { // Synchronise the request to avoid multiple simultaneous requests to this update the list on this // cluster which would cause errors consolidating the responses lock (_supportedCommandsGenerated) { // If we don't want to rediscover, and we already have the list of attributes, then return if (!rediscover && !(_supportedCommandsGenerated == null | _supportedCommandsGenerated.Count == 0)) { return true; } byte index = 0; bool complete = false; List <byte> commands = new List <byte>(); do { DiscoverCommandsGenerated command = new DiscoverCommandsGenerated(); command.ClusterId = _clusterId; command.DestinationAddress = _zigbeeEndpoint.GetEndpointAddress(); command.StartCommandIdentifier = index; command.MaximumCommandIdentifiers = 20; CommandResult result = Send(command).Result; if (result.IsError()) { return false; } DiscoverCommandsGeneratedResponse response = (DiscoverCommandsGeneratedResponse)result.GetResponse(); complete = response.DiscoveryComplete; if (response.CommandIdentifiers != null) { commands.AddRange(response.CommandIdentifiers); index = (byte)(commands.Max() + 1); } } while (!complete); _supportedCommandsGenerated.Clear(); _supportedCommandsGenerated.AddRange(commands); } return true; })); }