public static void Main(string[] args)
        {
            HandleArgs(args);

            if (WhatToDo == Action.Unknown)
            {
                return;
            }

            if (WhatToDo == Action.Decode)
            {
                uint node, action;

                Ev1527Decoder.Decode(PULSES, out node, out action);

                Console.WriteLine("{{\n \"message\": {{\n    \"unitcode\": {0},\n    \"command\": {1}\n  }}\n}}", node, action);
            }

            if (WhatToDo == Action.Encode)
            {
                int[] pulses = Ev1527Decoder.Encode(Node, Command);
                for (int i = 0; i < pulses.Length; i++)
                {
                    if (i > 0)
                    {
                        Console.Write(" ");
                    }
                    Console.Write(pulses[i]);
                }
                Console.WriteLine();
            }
        }
Example #2
0
        async Task Service_LampSwitched(LightService service, bool on)
        {
            var cmd = on ? service.OnCommand : service.OffCommand;

            // Encode command
            int[] pulses = Ev1527Decoder.Encode(cmd.Unitcode, cmd.Operation, 256, 200, 1000);

            for (int i = 0; i < Configuration.Repeats; i++)
            {
                if (i > 0 && Configuration.RepeatDelay > 0)
                {
                    Thread.Sleep(Configuration.RepeatDelay);
                }

                var msg = new PilightRawMessage();
                msg.Code.SetPulsesAsCode(pulses);

                await Socket.SendMesage(msg.ToString());
            }
        }