Пример #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 TestATCommandDestinationHigh()
 {
     var cmd = new ATCommand(AT.DestinationHigh);
     var v = new ATLongValue(0x11223300);
     cmd.SetValue(v);
     Assert.AreEqual(new byte[] { 0x08, 0x00, (byte)'D', (byte)'H', 0x11, 0x22, 0x33, 0x00 }, cmd.ToByteArray());
 }
Пример #3
0
 public void TestATCommandNodeDiscover()
 {
     var cmd = new ATCommand(AT.NodeDiscover);
     Assert.AreEqual(new byte[] { 0x08, 0x00, (byte)'N', (byte)'D' }, cmd.ToByteArray());
 }
Пример #4
0
 public void TestATCommandDestinationHighWithFrameId()
 {
     var cmd = new ATCommand(AT.DestinationHigh);
     cmd.FrameId = 0x02;
     Assert.AreEqual(new byte[] { 0x08, 0x02, (byte)'D', (byte)'H' }, cmd.ToByteArray());
 }