Exemplo n.º 1
0
 static void Main(string[] args)
 {
     var options = new Options();
     if (!CommandLine.Parser.Default.ParseArguments(args, options))
     {
         Environment.Exit(0);
     }
     if (options.Ip.CompareTo("0.0.0.0") == 0)
     {
         options.Ip = GetIp();
     }
     if (options.Port == 0)
     {
         options.Port = GetPort();
     }
     RplethProxy ard = new RplethProxy(options.Ip, options.Port);
     if (options.Command == -1)
     {
         options.Command = GetCmd();
     }
     if (options.Time == -1)
     {
         options.Time = GetSize(options.Command);
     }
     if (options.Message == null && (options.Command == 15 || options.Command == 16 || options.Command == 7))
     {
         options.Message = GetMessage();
     }
     if (options.Command == 8 && options.Lenght == 16 && options.Offset == 1 && options.TramSize == 26)
     {
         options = GetWiegand(options);
     }
     if (options.Command == 6 && options.Time == -1)
     {
         options.Time = GetNewPort();
     }
     if (options.Command > 2 && options.Command < 6 && options.Message == null)
     {
         options.Message = GetNewIp();
     }
     Command(ard, options);
 }
Exemplo n.º 2
0
 public static void Command(RplethProxy ard, Options op)
 {
     byte size = Convert.ToByte(op.Time);
     if (op.Command < 21)
     {
         ard.Connect();
         switch (op.Command)
         {
             case 0:
                 Console.WriteLine(ard.StateDhcp());
                 break;
             case 1:
                 ard.ChangeDhcp();
                 break;
             case 2:
                 ard.ChangeMac(op.Message);
                 break;
             case 3:
                 ard.ChangeIp(op.Message);
                 break;
             case 4:
                 ard.ChangeSubnet(op.Message);
                 break;
             case 5:
                 ard.ChangeGateway(op.Message);
                 break;
             case 6:
                 ard.ChangePort(op.Time);
                 break;
             case 7:
                 ard.ChangeWelcomeMessage(op.Message);
                 break;
             case 9:
                 ard.Reset();
                 break;
             case 10:
                 ard.Beep(size);
                 break;
             case 11:
                 ard.BlinkLed1(size);
                 break;
             case 12:
                 ard.BlinkLed1(size);
                 break;
             case 13:
                 ard.Nop();
                 break;
             case 14:
                 if (op.Time != 0)
                     Console.WriteLine(ard.Badge(op.Time));
                 else
                     Console.WriteLine(ard.Badge());
                 break;
             case 15:
                 ard.DisplayLcd(op.Message);
                 break;
             case 16:
                 ard.DisplayLcd(op.Message, op.Time);
                 break;
             case 17:
                 ard.BlinkLcd();
                 break;
             case 18:
                 ard.ScrollLcd();
                 break;
             case 19:
                 ard.ChangeDisplayTimeLcd(size);
                 break;
             case 20:
                 Console.Write(ard.SendCommand(op.Message));
                 break;
         }
         ard.Disconnect();
     }
     else
     {
         Console.WriteLine("Bad command");
     }
 }