Esempio n. 1
0
        public void CommandReceived(ZigBeeCommand command)
        {
            // We are only interested in READ ATTRIBUTE commands
            if (!(command is ReadAttributesCommand))
            {
                return;
            }

            ReadAttributesCommand readCommand = (ReadAttributesCommand)command;

            if (readCommand.ClusterId != ZclBasicCluster.CLUSTER_ID && readCommand.CommandDirection != ZclCommandDirection.SERVER_TO_CLIENT)
            {
                return;
            }

            List <ReadAttributeStatusRecord> attributeRecords = new List <ReadAttributeStatusRecord>();

            foreach (ushort attributeId in readCommand.Identifiers)
            {
                attributeRecords.Add(GetAttributeRecord(attributeId));
            }

            ReadAttributesResponse readResponse = new ReadAttributesResponse();

            readResponse.Records            = attributeRecords;
            readResponse.DestinationAddress = readCommand.SourceAddress;
            readResponse.CommandDirection   = ZclCommandDirection.CLIENT_TO_SERVER;
            readResponse.TransactionId      = command.TransactionId;
            _networkManager.SendCommand(readResponse);
        }
Esempio n. 2
0
        /// <summary>
        /// The Read Attributes Command
        ///
        /// The read attributes command is generated when a device wishes to determine the       /// values of one or more attributes located on another device. Each attribute       /// identifier field shall contain the identifier of the attribute to be read.       ///
        /// @param identifiers {@link List<ushort>} Identifiers
        /// @return the Task<CommandResult> command result Task
        /// </summary>
        public Task <CommandResult> ReadAttributesCommand(List <ushort> identifiers)
        {
            ReadAttributesCommand command = new ReadAttributesCommand();

            // Set the fields
            command.Identifiers = identifiers;

            return(Send(command));
        }
Esempio n. 3
0
        /// <summary>
        /// Read a number of attributes given a list of attribute IDs. Care must be taken not to request too many attributes
        /// so as to exceed the allowable frame length
        ///
        /// <param name="attributes">List of attribute identifiers to read</param>
        /// <returns>command Task</returns>
        /// </summary>
        public Task <CommandResult> Read(List <ushort> attributes)
        {
            ReadAttributesCommand command = new ReadAttributesCommand();

            command.ClusterId          = _clusterId;
            command.Identifiers        = attributes;
            command.DestinationAddress = _zigbeeEndpoint.GetEndpointAddress();

            return(Send(command));
        }