Ejemplo n.º 1
0
        public void TestSetPort()
        {
            SetPort cmd = new SetPort("{'index':1,'port':5008}");

            Assert.AreEqual("AT+PORT=5008\r", cmd.ToATString());

            cmd = new SetPort("{'port':5008}");
            Assert.AreEqual("AT+PORT=5008\r", cmd.ToATString());

            cmd = new SetPort("{'index':2,'port':5008}");
            Assert.AreEqual("AT+PORT2=5008\r", cmd.ToATString());
        }
Ejemplo n.º 2
0
        public void TestSetPort2()
        {
            SetPort cmd;

            try
            {
                cmd = new SetPort(string.Empty);
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }

            try
            {
                cmd = new SetPort("100");
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }

            try
            {
                cmd = new SetPort("1023");
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }

            try
            {
                cmd = new SetPort(null);
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }

            try
            {
                cmd = new SetPort("abcdefg");
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }
        }
Ejemplo n.º 3
0
        public void TestAtCommandExecutor()
        {
            GprsDtuServer _server = new GprsDtuServer(5055);

            _server.Start();
            string dtu = "12345678";

            Thread.Sleep(500);
            if (client.Connect(12345678, "22222222", "127.0.0.2"))
            {
                Console.WriteLine("Connected");
            }
            else
            {
                Console.WriteLine("ERROR");
            }
            client.OnReceived = (msg, len) => client.Send("OK");
            Thread.Sleep(500);
            GprsDtuConnection conn = (GprsDtuConnection)_server.GetConnection(new DtuNode {
                DtuCode = dtu
            });
            ATCommand       cmd = new EnterConfig();
            CommandExecutor ce  = new CommandExecutor();

            Assert.IsNotNull(conn);

            if (conn != null && conn.IsAvaliable())
            {
                ATCommandResult r = ce.Execute(conn, cmd);
                Assert.IsTrue(r.IsOK);
            }

            if (conn != null && conn.IsAvaliable())
            {
                cmd = new SetPort("{'port':5008}");
                ATCommandResult r = ce.Execute(conn, cmd);
                Assert.IsTrue(r.IsOK);
            }

            if (conn != null && conn.IsAvaliable())
            {
                cmd = new SetPort("{'port':5009");
                ATCommandResult r = ce.Execute(conn, cmd);
                Assert.IsTrue(r.IsOK);
            }
        }