Example #1
0
 public override void Execute()
 {
     if (Parameters.Count > 0)
     {
         _Client.Disconnect();
         Console.Write("Connect to server (");
         if (_Client.ConnectToServer(Parameters[0]))
         {
             Console.WriteLine("Complete");
         }
     }
 }
        public LWM2MTestClientFixture()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
            Console.WriteLine(string.Concat("TestClient Version - ", fileVersionInfo.FileVersion));
            CoAP.Log.LogManager.Level = CoAP.Log.LogLevel.None;
            Client = new Client(55863);
            Client.LoadDefaultResources();
            Client.Start();

            // TODO PSK and Certificate versions
            Client.UsePSK(TestConfiguration.TestData.Identity.PSK.Key, TestConfiguration.TestData.Identity.PSK.Secret);

            // FIXME: Should access API for bootstrap servers and PSK/Certificate
            Client.ConnectToServer(TestConfiguration.TestData.LWM2MClient.URI);
        }
 public override void Execute()
 {
     if (Parameters.Count > 0)
     {
         _Client.Disconnect();
         Console.Write("Bootstraping (");
         Console.Write(Parameters[0]);
         Console.Write(") .. ");
         if (_Client.Bootstrap(Parameters[0]))
         {
             Console.WriteLine("Complete");
             Console.Write("Connect to server (");
             if (_Client.ConnectToServer())
             {
                 Console.WriteLine("Complete");
             }
         }
         else
         {
             Console.WriteLine("Failed");
         }
     }
 }
Example #4
0
        static void Main(string[] args)
        {
            Client client = null;

            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
                Console.WriteLine(string.Concat("TestClient Version - ", fileVersionInfo.FileVersion));
                CoAP.Log.LogManager.Level = CoAP.Log.LogLevel.None;
                client = new Client(55863);
                client.LoadResources();
                client.Start();
                Command.RegisterCommand(new PSKCommand(client));
                Command.RegisterCommand(new CertificateFileCommand(client));
                BootstrapCommand bootstrapCommand = new BootstrapCommand(client);
                Command.RegisterCommand(bootstrapCommand);
                ConnectCommand connectCommand = new ConnectCommand(client);
                Command.RegisterCommand(connectCommand);
                Command.RegisterCommand(new EchoCommand());
                Command.RegisterCommand(new FCAPCommand(client));
                Command.RegisterCommand(new HelpCommand());
                Command.RegisterCommand(new SaveCommand(client));
                Command.RegisterCommand(new SetResourceCommand(client));
                Command.RegisterCommand(new DisplayResourceCommand(client));
                Command.RegisterCommand(new Command()
                {
                    Name = "quit"
                });
                Command.RegisterCommand(new Command()
                {
                    Name = "exit"
                });

                bool bootstrap = true;
                if (client.HaveBootstrap())
                {
                    Console.Write("Connect to server (");
                    if (client.ConnectToServer())
                    {
                        Console.WriteLine("Complete");
                        bootstrap = false;
                    }
                    else
                    {
                        Console.WriteLine("Failed");
                    }
                }
                if (bootstrap)
                {
                    //bootstrapCommand.Parameters.Add("coap://delmet-hp.we.imgtec.org:15685");
                    //bootstrapCommand.Parameters.Add("coap://we-dev-lwm2m1.we.imgtec.org:15685");
                    //bootstrapCommand.Execute();
                }
                Console.WriteLine("Type quit to stop the LWM2M client (type help to see other commmands).");
                while (true)
                {
                    Console.Write('>');
                    Command command = Command.Parse(Console.ReadLine());
                    if (command != null)
                    {
                        if ((string.Compare(command.Name, "quit", true) == 0) || (string.Compare(command.Name, "exit", true) == 0))
                        {
                            break;
                        }
                        else
                        {
                            command.Execute();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();
            }
            finally
            {
                if (client != null)
                {
                    client.Stop();
                    client.SaveResources();
                }
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            Client client = null;
            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location);
                Console.WriteLine(string.Concat("TestClient Version - ", fileVersionInfo.FileVersion));
                CoAP.Log.LogManager.Level = CoAP.Log.LogLevel.None;
                client = new Client(55863);
                client.LoadResources();
                client.Start();
                Command.RegisterCommand(new PSKCommand(client));
                Command.RegisterCommand(new CertificateFileCommand(client));
                BootstrapCommand bootstrapCommand = new BootstrapCommand(client);
                Command.RegisterCommand(bootstrapCommand);
                ConnectCommand connectCommand = new ConnectCommand(client);
                Command.RegisterCommand(connectCommand);
                Command.RegisterCommand(new EchoCommand());
                Command.RegisterCommand(new FCAPCommand(client));
                Command.RegisterCommand(new HelpCommand());
                Command.RegisterCommand(new SaveCommand(client));
                Command.RegisterCommand(new SetResourceCommand(client));
                Command.RegisterCommand(new DisplayResourceCommand(client));
                Command.RegisterCommand(new Command() { Name = "quit" });
                Command.RegisterCommand(new Command() { Name = "exit" });

                bool bootstrap = true;
                if (client.HaveBootstrap())
                {
                    Console.Write("Connect to server (");
                    if (client.ConnectToServer())
                    {
                        Console.WriteLine("Complete");
                        bootstrap = false;
                    }
                    else
                        Console.WriteLine("Failed");
                }
                if (bootstrap)
                {
                    //bootstrapCommand.Parameters.Add("coap://delmet-hp.we.imgtec.org:15685");
                    //bootstrapCommand.Parameters.Add("coap://we-dev-lwm2m1.we.imgtec.org:15685");
                    //bootstrapCommand.Execute();
                }
                Console.WriteLine("Type quit to stop the LWM2M client (type help to see other commmands).");
                while (true)
                {
                    Console.Write('>');
                    Command command = Command.Parse(Console.ReadLine());
                    if (command != null)
                    {
                        if ((string.Compare(command.Name, "quit", true) == 0) || (string.Compare(command.Name, "exit", true) == 0))
                            break;
                        else
                        {
                            command.Execute();
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();
            }
            finally
            {
                if (client != null)
                {
                    client.Stop();
                    client.SaveResources();
                }
            }
        }