示例#1
0
        static void Main(string[] args)
        {
            var bee = new XBee {ApiType = ApiTypeValue.Enabled};
            bee.SetConnection(new SerialConnection("COM4", 9600));

            var request = new ATCommand(AT.ApiEnable) { FrameId = 1 };
            var frame = bee.ExecuteQuery(request, 1000);
            var value = ((ATCommandResponse) frame).Value;
            Console.WriteLine(String.Format("API type: {0}", ((ATLongValue) value).Value));

            request = new ATCommand(AT.BaudRate) { FrameId = 1 };
            frame = bee.ExecuteQuery(request, 1000);
            value = ((ATCommandResponse) frame).Value;
            Console.WriteLine(String.Format("Baud rate: {0}", ((ATLongValue) value).Value));

            request = new ATCommand(AT.MaximumPayloadLenght) { FrameId = 1 };
            frame = bee.ExecuteQuery(request, 1000);
            value = ((ATCommandResponse) frame).Value;
            Console.WriteLine(String.Format("Maximum Payload is: {0}", ((ATLongValue) value).Value));

            request = new ATCommand(AT.FirmwareVersion) { FrameId = 1 };
            frame = bee.ExecuteQuery(request, 1000);
            value = ((ATCommandResponse) frame).Value;
            Console.WriteLine(String.Format("Firmware Version: {0:X4}", ((ATLongValue) value).Value));

            request = new ATCommand(AT.NodeDiscover) { FrameId = 1 };
            bee.Execute(request);

            while (true) {
                Thread.Sleep(100);
            }
        }
示例#2
0
        public void TestXBeeConnectionNoAPI()
        {
            var conn = new Mock <IXBeeConnection>();
            var xbee = new XBee();

            xbee.SetConnection(conn.Object);

            conn.Verify(connection => connection.SetPacketReader(It.IsAny <IPacketReader>()));
        }
        public void TestXBeeConnectionNoAPI()
        {
            var conn = new Mock<IXBeeConnection>();
            var xbee = new XBee();

            xbee.SetConnection(conn.Object);

            conn.Verify(connection => connection.SetPacketReader(It.IsAny<IPacketReader>()));
        }
        public void TestXBeeConnectionAPIEnabled()
        {
            var conn = new Mock<IXBeeConnection>();
            var xbee = new XBee { ApiType = ApiTypeValue.Enabled };

            xbee.SetConnection(conn.Object);

            conn.Verify(connection => connection.SetPacketReader(It.IsAny<IPacketReader>()));
        }
示例#5
0
        public void TestXBeeConnectionAPIEnabled()
        {
            var conn = new Mock <IXBeeConnection>();
            var xbee = new XBee {
                ApiType = ApiTypeValue.Enabled
            };

            xbee.SetConnection(conn.Object);

            conn.Verify(connection => connection.SetPacketReader(It.IsAny <IPacketReader>()));
        }
示例#6
0
        static void Main(string[] args)
        {
            var bee = new XBee {
                ApiType = ApiTypeValue.Enabled
            };

            bee.SetConnection(new SerialConnection("COM4", 9600));

            var request = new ATCommand(AT.ApiEnable)
            {
                FrameId = 1
            };
            var frame = bee.ExecuteQuery(request, 1000);
            var value = ((ATCommandResponse)frame).Value;

            Console.WriteLine(String.Format("API type: {0}", ((ATLongValue)value).Value));

            request = new ATCommand(AT.BaudRate)
            {
                FrameId = 1
            };
            frame = bee.ExecuteQuery(request, 1000);
            value = ((ATCommandResponse)frame).Value;
            Console.WriteLine(String.Format("Baud rate: {0}", ((ATLongValue)value).Value));

            request = new ATCommand(AT.MaximumPayloadLenght)
            {
                FrameId = 1
            };
            frame = bee.ExecuteQuery(request, 1000);
            value = ((ATCommandResponse)frame).Value;
            Console.WriteLine(String.Format("Maximum Payload is: {0}", ((ATLongValue)value).Value));

            request = new ATCommand(AT.FirmwareVersion)
            {
                FrameId = 1
            };
            frame = bee.ExecuteQuery(request, 1000);
            value = ((ATCommandResponse)frame).Value;
            Console.WriteLine(String.Format("Firmware Version: {0:X4}", ((ATLongValue)value).Value));

            request = new ATCommand(AT.NodeDiscover)
            {
                FrameId = 1
            };
            bee.Execute(request);

            while (true)
            {
                Thread.Sleep(100);
            }
        }
示例#7
0
        public void TestXBeeExecuteQuery()
        {
            var xbee = new XBee() { ApiType = ApiTypeValue.Enabled };
            var conn = new Mock<IXBeeConnection>();
            var frame = new Mock<XBeeFrame>();
            conn.Setup(connection => connection.Write(It.IsAny<byte[]>())).Callback(() => xbee.FrameReceivedEvent(this, new FrameReceivedArgs(frame.Object)));

            xbee.SetConnection(conn.Object);
            var result = xbee.ExecuteQuery(new ATCommand(AT.BaudRate) { FrameId = 1 });

            conn.Verify(connection => connection.SetPacketReader(It.IsAny<IPacketReader>()));
            Assert.That(result, Is.InstanceOf<XBeeFrame>());
        }
        public void TestXBeeConnectionExecute()
        {
            var conn = new Mock<IXBeeConnection>();
            byte[] result = null;

            conn.Setup(connection => connection.Write(It.IsAny<byte[]>())).Callback((byte[] b) => result = b);
            var xbee = new XBee();

            xbee.SetConnection(conn.Object);
            xbee.Execute(new ATCommand(AT.BaudRate) { FrameId = 1 });

            conn.Verify(connection => connection.SetPacketReader(It.IsAny<IPacketReader>()));
            Assert.That(result, Is.EqualTo(new byte[] { 0x7E, 0x00, 0x04, 0x08, 0x01, 0x42, 0x44, 0x70 }));
        }
示例#9
0
        public void TestXBeeConnectionExecute()
        {
            var conn = new Mock <IXBeeConnection>();

            byte[] result = null;

            conn.Setup(connection => connection.Write(It.IsAny <byte[]>())).Callback((byte[] b) => result = b);
            var xbee = new XBee();

            xbee.SetConnection(conn.Object);
            xbee.Execute(new ATCommand(AT.BaudRate)
            {
                FrameId = 1
            });

            conn.Verify(connection => connection.SetPacketReader(It.IsAny <IPacketReader>()));
            Assert.That(result, Is.EqualTo(new byte[] { 0x7E, 0x00, 0x04, 0x08, 0x01, 0x42, 0x44, 0x70 }));
        }
示例#10
0
        public void TestXBeeExecuteQuery()
        {
            var xbee = new XBee()
            {
                ApiType = ApiTypeValue.Enabled
            };
            var conn  = new Mock <IXBeeConnection>();
            var frame = new Mock <XBeeFrame>();

            conn.Setup(connection => connection.Write(It.IsAny <byte[]>())).Callback(() => xbee.FrameReceivedEvent(this, new FrameReceivedArgs(frame.Object)));

            xbee.SetConnection(conn.Object);
            var result = xbee.ExecuteQuery(new ATCommand(AT.BaudRate)
            {
                FrameId = 1
            });

            conn.Verify(connection => connection.SetPacketReader(It.IsAny <IPacketReader>()));
            Assert.That(result, Is.InstanceOf <XBeeFrame>());
        }