Example #1
0
        public static DiscoverResult Parse(AtResponse response)
        {
            if (response.Command != (ushort) AtCmd.NodeDiscover)
                throw new ArgumentException("This method is only applicable for the ND command");

            var input = new InputStream(response.Value);

            var frame = new DiscoverResult
            {
                NodeInfo = new NodeInfo
                {
                    NetworkAddress = new XBeeAddress16(input.Read(2)),
                    SerialNumber = new XBeeAddress64(input.Read(8))
                }
            };

            byte ch;

            // NI is terminated with 0
            while ((ch = input.Read()) != 0)
                if (ch > 32 && ch < 126)
                    frame.NodeInfo.NodeIdentifier += (char)ch;

            frame.Parent = new XBeeAddress16(input.Read(2));
            frame.NodeType = (NodeType) input.Read();
            frame.Status = input.Read();
            frame.ProfileId = input.Read(2);
            frame.MfgId = input.Read(2);

            return frame;
        }
Example #2
0
        public static DiscoverResult Parse(AtResponse response)
        {
            if (response.Command != (ushort) AtCmd.NodeDiscover)
                throw new ArgumentException("This method is only applicable for the ND command");

            // empty response is received after the last disovered node
            // this happens only with Wpan nodes, not Zigbee
            if (response.Value == null || response.Value.Length == 0)
                return null;

            var input = new InputStream(response.Value);

            var frame = new DiscoverResult
            {
                NodeInfo = new NodeInfo
                {
                    NetworkAddress = new XBeeAddress16(input.Read(2)),
                    SerialNumber = new XBeeAddress64(input.Read(8)),
                },
                Rssi = -1 * input.Read()
            };

            byte ch;

            // NI is terminated with 0
            while ((ch = input.Read()) != 0)
                if (ch > 32 && ch < 126)
                    frame.NodeInfo.NodeIdentifier += (char)ch;

            return frame;
        }
Example #3
0
        public static IoSampleResponse ParseIsSample(AtResponse response)
        {
            if (response.Command != (ushort) Common.AtCmd.ForceSample)
                throw new ArgumentException("This is only applicable to the 'IS' AT command");

            var input = new InputStream(response.Value);
            var sample = new IoSampleResponse();
            //sample.ParseIoSample(input);

            return sample;
        }