示例#1
0
        void SetLevelOnDevice(uint newLevel)
        {
            ZclCommand command = null;

            // look for level control cluster and move to level command
            var levelControlCluster = m_endPoint.GetCluster(LevelControlCluster.CLUSTER_ID);

            if (levelControlCluster == null ||
                !levelControlCluster.CommandList.TryGetValue(LevelControlCluster.COMMAND_MOVETOLEVEL, out command))
            {
                return;
            }

            // get level parameter
            var parameter = command.GetInputParamByName(LevelControlCluster.LEVEL_PARAM);

            if (parameter == null)
            {
                return;
            }

            // level is a byte in ZCL and a uint32 in LSF
            parameter.Data = (byte)(newLevel / LIGHTLEVEL_SCALERATIO);
            command.Send();
            m_level = newLevel;
        }
示例#2
0
        private void SetOnOffStateOnDevice(bool newOnOffState)
        {
            ZclCommand command = null;

            // look for OnOff cluster of this end point
            var onOffCluster = m_endPoint.GetCluster(OnOffCluster.CLUSTER_ID);

            if (onOffCluster == null)
            {
                return;
            }

            // get on or off command depending on the on/off state to set
            if (newOnOffState)
            {
                onOffCluster.CommandList.TryGetValue(OnOffCluster.COMMAND_ON, out command);
            }
            else
            {
                onOffCluster.CommandList.TryGetValue(OnOffCluster.COMMAND_OFF, out command);
            }

            if (command == null)
            {
                return;
            }

            // send the command
            command.Send();
            m_onOffState = newOnOffState;
        }