public override void Parse()
        {
            FrameId = (byte) parser.ReadByte();
            Source = new XBeeNode { Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16() };

            Command = parser.ReadATCommand();
            CommandStatus = (CommandStatusType) 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;
                }
            }
        }
        public override void Parse()
        {
            FrameId = (byte)parser.ReadByte();
            Source  = new XBeeNode {
                Address64 = parser.ReadAddress64(), Address16 = parser.ReadAddress16()
            };

            Command       = parser.ReadATCommand();
            CommandStatus = (CommandStatusType)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;
                }
            }
        }
Beispiel #3
0
 public void SetValue(ATValue value)
 {
     hasValue   = true;
     this.value = value;
 }
 public void SetValue(ATValue value)
 {
     hasValue = true;
     this.value = value;
 }