internal override bool handleInsteonPacket(InsteonPacket packet)
        {
            bool changed = false;

            if (packet.Flags.MessageType == InsteonPacket.InsteonFlags.MessageTypeEnum.GroupBroadcast)
            {
                // Do other stuff in here.
            }
            else
            {
                InsteonPacket.Command cmd = packet.ComposedCommand;
                switch (cmd)
                {
                case InsteonPacket.Command.LightOn:
                case InsteonPacket.Command.LightOnFast:
                    this.onLevel = packet.Command2;
                    changed      = true;
                    break;

                case InsteonPacket.Command.LightOff:
                case InsteonPacket.Command.LightOffFast:
                    this.onLevel = 0;
                    changed      = true;
                    break;
                }
            }
            return(base.handleInsteonPacket(packet) || changed);
        }
Beispiel #2
0
        /// <summary>
        /// Sends a standard command off to do stuff.
        /// </summary>
        /// <param name="cmd">The command to send</param>
        /// <param name="command2">The second part of the command to update</param>
        /// <returns></returns>
        protected Messages.PowerLineModemMessage.MessageResponse SendStandardCommand(InsteonPacket.Command cmd, byte command2)
        {
            InsteonPacket packet = new InsteonPacket(this.deviceId, cmd);

            packet.Command2 |= command2;
            InsteonPacket response;

            return(coms.SendDirectInsteonPacket(packet, out response));
        }
Beispiel #3
0
        internal override StateChanged handleInsteonPacket(InsteonPacket packet)
        {
            StateChanged changed = null;

            switch (packet.Flags.MessageType)
            {
            case InsteonPacket.InsteonFlags.MessageTypeEnum.GroupBroadcast:
                InsteonPacket.Command cmd = packet.StandardCommand;
                switch (cmd)
                {
                case InsteonPacket.Command.LightOn:
                case InsteonPacket.Command.LightOnFast:
                    this.onLevel = 0xff;
                    changed      = new StateChanged(this, packet.ToAddress.Address[2], StateChanged.StateThatChanged.TurnedOn);
                    break;

                case InsteonPacket.Command.LightOff:
                case InsteonPacket.Command.LightOffFast:
                    this.onLevel = 0;
                    changed      = new StateChanged(this, packet.ToAddress.Address[2], StateChanged.StateThatChanged.TurnedOff);
                    break;

                case InsteonPacket.Command.Dim:
                    changed = new StateChanged(this, packet.ToAddress.Address[2], StateChanged.StateThatChanged.Dim);
                    break;

                case InsteonPacket.Command.Bright:
                    changed = new StateChanged(this, packet.ToAddress.Address[2], StateChanged.StateThatChanged.Bright);
                    break;
                }
                break;

            case InsteonPacket.InsteonFlags.MessageTypeEnum.GroupCleanupDirect:
                break;
            }
            if (changed == null)
            {
                return(base.handleInsteonPacket(packet));
            }
            return(changed);
        }
Beispiel #4
0
        /// <summary>
        /// Sends a standard command off to do stuff.
        /// </summary>
        /// <param name="cmd">The command to send</param>
        /// <param name="command2">The second part of the command to update</param>
        /// <returns></returns>
        protected Messages.PowerLineModemMessage.MessageResponse SendStandardCommandWithResponse(InsteonPacket.Command cmd, byte command2, out byte outCommand2)
        {
            InsteonPacket packet = new InsteonPacket(this.deviceId, cmd);

            packet.Command2 |= command2;
            InsteonPacket response;

            Messages.PowerLineModemMessage.MessageResponse ret = coms.SendDirectInsteonPacket(packet, out response);
            if (ret == Messages.PowerLineModemMessage.MessageResponse.Ack)
            {
                outCommand2 = response.Command2;
            }
            else
            {
                outCommand2 = 0;
            }
            return(ret);
        }