Ejemplo n.º 1
0
        public override void Parse()
        {
            FrameId       = (byte)parser.ReadByte();
            Command       = parser.ReadATCommand();
            CommandStatus = (byte)parser.ReadByte();

            if (Command == AT.NodeDiscover)
            {
                ParseNetworkDiscovery();
            }

            var type = ((ATAttribute)Command.GetAttr()).ValueType;

            if ((type != ATValueType.None) && parser.HasMoreData())
            {
                switch (type)
                {
                case ATValueType.Number:
                    var vData = parser.ReadData();
                    Value = new ATLongValue().FromByteArray(vData);
                    break;

                case ATValueType.HexString:
                    var hexData = parser.ReadData();
                    Value = new ATStringValue(ByteUtils.ToBase16(hexData));
                    break;

                case ATValueType.String:
                    var str = parser.ReadData();
                    Value = new ATStringValue(Encoding.UTF8.GetString(str));
                    break;
                }
            }
        }
Ejemplo n.º 2
0
 public void TestATQueueCommandDestinationHigh()
 {
     var cmd = new ATQueueCommand(AT.DestinationHigh);
     var v = new ATLongValue(0x11223300);
     cmd.SetValue(v);
     Assert.AreEqual(new byte[] { 0x09, 0x00, (byte)'D', (byte)'H', 0x11, 0x22, 0x33, 0x00 }, cmd.ToByteArray());
 }
        public void TestRemoteATCommandDestinationHigh()
        {
            var broadcast = new XBeeNode { Address16 = XBeeAddress16.ZNET_BROADCAST, Address64 = XBeeAddress64.BROADCAST };

            var cmd = new RemoteATCommand(AT.DestinationHigh, broadcast) { FrameId = 1 };
            var v = new ATLongValue(0x11223300);
            cmd.SetValue(v);

            Assert.AreEqual(new byte[] { 0x17, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, (byte) 'D', (byte) 'H', 0x11, 0x22, 0x33, 0x00 }, cmd.ToByteArray());
        }
Ejemplo n.º 4
0
 public void TestATLongValueToUInt64()
 {
     var value = new ATLongValue(0x1122334444332211);
     Assert.That(value, Is.TypeOf<ATLongValue>());
     Assert.That(value.ToByteArray(), Is.EqualTo(new byte[] { 0x11, 0x22, 0x33, 0x44, 0x44, 0x33, 0x22, 0x11 }));
 }
Ejemplo n.º 5
0
 public void TestATLongValueToUInt16()
 {
     var value = new ATLongValue(0x1122);
     Assert.That(value, Is.TypeOf<ATLongValue>());
     Assert.That(value.ToByteArray(), Is.EqualTo(new byte[] { 0x11, 0x22 }));
 }
Ejemplo n.º 6
0
 public void TestATLongValueFromUInt64()
 {
     var value = new ATLongValue().FromByteArray(new byte[] { 0x11, 0x22, 0x33, 0x44, 0x44, 0x33, 0x22, 0x11 });
     Assert.That(value, Is.TypeOf<ATLongValue>());
     Assert.That(((ATLongValue)value).Value, Is.EqualTo(0x1122334444332211));
 }
Ejemplo n.º 7
0
 public void TestATLongValueFromUInt16()
 {
     var value = new ATLongValue().FromByteArray(new byte[] { 0x11, 0x22 });
     Assert.That(value, Is.TypeOf<ATLongValue>());
     Assert.That(((ATLongValue)value).Value, Is.EqualTo(0x1122));
 }
Ejemplo n.º 8
0
 public void TestATLongValue()
 {
     var value = new ATLongValue();
     Assert.That(value, Is.AssignableTo<ATValue>());
     Assert.That(value, Is.TypeOf<ATLongValue>());
 }