Пример #1
0
        private static void OnStatusChanged(XBeeApi sender, ModemStatus status)
        {
            switch (status)
            {
            case ModemStatus.HardwareReset:
                Debug.Print(sender.Config.SerialNumber + " Hardware reset");
                break;

            case ModemStatus.WatchdogTimerReset:
                Debug.Print(sender.Config.SerialNumber + " Software reset");
                break;

            case ModemStatus.Associated:
                Debug.Print(sender.Config.SerialNumber + " Associated");
                break;

            case ModemStatus.Disassociated:
                Debug.Print(sender.Config.SerialNumber + " Not associated");
                break;

            default:
                Debug.Print(sender.Config.SerialNumber + " Status " + status);
                break;
            }
        }
Пример #2
0
        public static XBeeAddress64 Read(XBeeApi sender, XBeeAddress remoteXbee)
        {
            var sh = sender.Send(AtCmd.SerialNumberHigh).To(remoteXbee).GetResponse();
            var sl = sender.Send(AtCmd.SerialNumberLow).To(remoteXbee).GetResponse();

            return(Parse((AtResponse)sl, (AtResponse)sh));
        }
Пример #3
0
        public static XBeeAddress64 Read(XBeeApi xbee)
        {
            var sh = xbee.Send(AtCmd.SerialNumberHigh).GetResponse();
            var sl = xbee.Send(AtCmd.SerialNumberLow).GetResponse();

            return(Parse(sl, sh));
        }
Пример #4
0
        public static void Write(XBeeApi sender, XBeeAddress remoteXbee, ApiModes mode)
        {
            var request = sender.Send(AtCmd.ApiEnable, new[] {(byte) mode}).To(remoteXbee);
            var response = (AtResponse) request.GetResponse();

            if (!response.IsOk)
                throw new XBeeException("Failed to write api mode");
        }
Пример #5
0
        public static void Write(XBeeApi xbee, ApiModes mode)
        {
            var request = xbee.Send(AtCmd.ApiEnable, new[] {(byte) mode});
            var response = request.GetResponse();

            if (!response.IsOk)
                throw new XBeeException("Failed to write api mode");
        }
Пример #6
0
        public static void Write(XBeeApi xbee, string nodeIdentifier)
        {
            var value = Arrays.ToByteArray(nodeIdentifier, 0, MaxNodeIdentifierLength);
            var response = xbee.Send(AtCmd.NodeIdentifier, value).GetResponse();

            if (!response.IsOk)
                throw new XBeeException("Failed to write node identifier");
        }
Пример #7
0
        public static void Write(XBeeApi sender, XBeeAddress remoteXbee, string nodeIdentifier)
        {
            var value = Arrays.ToByteArray(nodeIdentifier, 0, MaxNodeIdentifierLength);
            var request = sender.Send(AtCmd.NodeIdentifier, value).To(remoteXbee);
            var response = (AtResponse) request.GetResponse();

            if (!response.IsOk)
                throw new XBeeException("Failed to write node identifier");
        }
Пример #8
0
        public static void Write(XBeeApi xbee, string nodeIdentifier)
        {
            var value    = Arrays.ToByteArray(nodeIdentifier, 0, MaxNodeIdentifierLength);
            var response = xbee.Send(AtCmd.NodeIdentifier, value).GetResponse();

            if (!response.IsOk)
            {
                throw new XBeeException("Failed to write node identifier");
            }
        }
Пример #9
0
        public static void Write(XBeeApi xbee, ApiModes mode)
        {
            var request  = xbee.Send(AtCmd.ApiEnable, new[] { (byte)mode });
            var response = request.GetResponse();

            if (!response.IsOk)
            {
                throw new XBeeException("Failed to write api mode");
            }
        }
Пример #10
0
        public static void Write(XBeeApi sender, XBeeAddress remoteXbee, ApiModes mode)
        {
            var request  = sender.Send(AtCmd.ApiEnable, new[] { (byte)mode }).To(remoteXbee);
            var response = (AtResponse)request.GetResponse();

            if (!response.IsOk)
            {
                throw new XBeeException("Failed to write api mode");
            }
        }
Пример #11
0
        public static void Write(XBeeApi sender, XBeeAddress remoteXbee, string nodeIdentifier)
        {
            var value    = Arrays.ToByteArray(nodeIdentifier, 0, MaxNodeIdentifierLength);
            var request  = sender.Send(AtCmd.NodeIdentifier, value).To(remoteXbee);
            var response = (AtResponse)request.GetResponse();

            if (!response.IsOk)
            {
                throw new XBeeException("Failed to write node identifier");
            }
        }
Пример #12
0
 /// <summary>
 /// Reads remote module basic information
 /// </summary>
 /// <param name="sender">XBee module that will send AT command to remote target</param>
 /// <param name="remoteXbee">XBee module which infomation will be retrieved</param>
 /// <returns>Remote XBee basic infomation</returns>
 public static XBeeConfiguration Read(XBeeApi sender, XBeeAddress remoteXbee)
 {
     return new XBeeConfiguration(sender, remoteXbee)
     {
         ApiMode = Common.ApiMode.Read(sender, remoteXbee),
         HardwareVersion = Common.HardwareVersion.Read(sender, remoteXbee),
         Firmware = Common.Firmware.Read(sender, remoteXbee),
         SerialNumber = Common.SerialNumber.Read(sender, remoteXbee),
         NodeIdentifier = Common.NodeIdentifier.Read(sender, remoteXbee)
     };
 }
Пример #13
0
 /// <summary>
 /// Reads module basic information
 /// </summary>
 /// <param name="xbee">XBee module to read data from</param>
 /// <returns>XBee basic information</returns>
 public static XBeeConfiguration Read(XBeeApi xbee)
 {
     return new XBeeConfiguration(xbee)
     {
         ApiMode = Common.ApiMode.Read(xbee),
         HardwareVersion = Common.HardwareVersion.Read(xbee),
         Firmware = Common.Firmware.Read(xbee),
         SerialNumber = Common.SerialNumber.Read(xbee),
         NodeIdentifier = Common.NodeIdentifier.Read(xbee)
     };
 }
Пример #14
0
 /// <summary>
 /// Reads remote module basic information
 /// </summary>
 /// <param name="sender">XBee module that will send AT command to remote target</param>
 /// <param name="remoteXbee">XBee module which infomation will be retrieved</param>
 /// <returns>Remote XBee basic infomation</returns>
 public static XBeeConfiguration Read(XBeeApi sender, XBeeAddress remoteXbee)
 {
     return(new XBeeConfiguration(sender, remoteXbee)
     {
         ApiMode = Common.ApiMode.Read(sender, remoteXbee),
         HardwareVersion = Common.HardwareVersion.Read(sender, remoteXbee),
         Firmware = Common.Firmware.Read(sender, remoteXbee),
         SerialNumber = Common.SerialNumber.Read(sender, remoteXbee),
         NodeIdentifier = Common.NodeIdentifier.Read(sender, remoteXbee)
     });
 }
Пример #15
0
 /// <summary>
 /// Reads module basic information
 /// </summary>
 /// <param name="xbee">XBee module to read data from</param>
 /// <returns>XBee basic information</returns>
 public static XBeeConfiguration Read(XBeeApi xbee)
 {
     return(new XBeeConfiguration(xbee)
     {
         ApiMode = Common.ApiMode.Read(xbee),
         HardwareVersion = Common.HardwareVersion.Read(xbee),
         Firmware = Common.Firmware.Read(xbee),
         SerialNumber = Common.SerialNumber.Read(xbee),
         NodeIdentifier = Common.NodeIdentifier.Read(xbee)
     });
 }
Пример #16
0
        private static void OnDataReceived(XBeeApi receiver, byte[] data, XBeeAddress sender)
        {
            var dataStr = new string(Encoding.UTF8.GetChars(data));

            switch (dataStr)
            {
            case Ping:
                receiver.Send(Pong).To(sender).NoResponse();
                break;

            case Pong:
                Debug.Print("Received Pong from " + sender);
                break;
            }
        }
Пример #17
0
        /// <summary>
        /// Configures this serial line.
        /// </summary>
        /// <remarks>
        /// This should be called at most once.
        /// </remarks>
        /// <param name="baudRate">The baud rate.</param>
        public void Configure(int baudRate = 9600)
        {
            if (_api != null)
            {
                throw new Exception("XBee.Configure can only be called once");
            }

            Logger.Initialize(ErrorPrint, LogLevel.Error, LogLevel.Fatal);
            Logger.Initialize(DebugPrint, LogLevel.Warn, LogLevel.Info, LogLevel.Debug, LogLevel.LowDebug);

            _connection = new SerialConnection(_serialPortName, baudRate);
            _api        = new XBeeApi(_connection);

            Enable();

            _api.Open();
        }
Пример #18
0
        public XBeeResponse[] EndReceive(int timeout = -1)
        {
            if (_finished)
                throw new InvalidOperationException("EndReceive can be called only once!");

            try
            {
                return _responseListener.GetPackets(timeout);
            }
            finally
            {
                _xbee.RemovePacketListener(_responseListener);
                _responseListener = null;
                _xbee = null;
                _finished = true;
            }
        }
Пример #19
0
        public XBeeResponse[] EndReceive(int timeout = -1)
        {
            if (_finished)
            {
                throw new InvalidOperationException("EndReceive can be called only once!");
            }

            try
            {
                return(_responseListener.GetPackets(timeout));
            }
            finally
            {
                _xbee.RemovePacketListener(_responseListener);
                _responseListener = null;
                _xbee             = null;
                _finished         = true;
            }
        }
Пример #20
0
 public static string Read(XBeeApi xbee)
 {
     var request = xbee.Send(AtCmd.FirmwareVersion);
     return Parse(request.GetResponse());
 }
Пример #21
0
        public static HardwareVersions Read(XBeeApi xbee)
        {
            var request = xbee.Send(AtCmd.HardwareVersion);

            return(Parse(request.GetResponse()));
        }
Пример #22
0
        public static string Read(XBeeApi sender, XBeeAddress remoteXbee)
        {
            var request = sender.Send(AtCmd.NodeIdentifier).To(remoteXbee);

            return(Parse((AtResponse)request.GetResponse()));
        }
Пример #23
0
 /// <summary>
 ///   TODO: Update Comments
 ///     
 /// </summary>
 /// <param name="xbee" type="NETMF.OpenSource.XBee.Api.XBee">
 ///     <para>
 ///         
 ///     </para>
 /// </param>
 public DataDelegateRequest(XBeeApi xbee)
     : base(xbee)
 {
 }
Пример #24
0
 protected RequestBase(XBeeApi localXBee)
 {
     LocalXBee = localXBee;
 }
Пример #25
0
        /// <summary>
        ///   TODO: Update Comments
        ///
        /// </summary>
        /// <param name="sender" type="NETMF.OpenSource.XBee.Api.XBee">
        ///     <para>
        ///
        ///     </para>
        /// </param>
        /// <param name="remoteXbee" type="NETMF.OpenSource.XBee.Api.XBeeAddress">
        ///     <para>
        ///
        ///     </para>
        /// </param>
        public static void Write(XBeeApi sender, XBeeAddress remoteXbee)
        {
            var request = sender.Send(AtCmd.Write).To(remoteXbee);

            Parse((AtResponse)request.GetResponse());
        }
Пример #26
0
        public static ApiModes Read(XBeeApi sender, XBeeAddress remoteXbee)
        {
            var request = sender.Send(AtCmd.ApiEnable).To(remoteXbee);

            return(Parse((AtResponse)request.GetResponse()));
        }
Пример #27
0
 public static string Read(XBeeApi sender, XBeeAddress remoteXbee)
 {
     var request = sender.Send(AtCmd.NodeIdentifier).To(remoteXbee);
     return Parse((AtResponse) request.GetResponse());
 }
Пример #28
0
 internal AsyncSendResult(XBeeApi xbee, IPacketListener responseListener)
 {
     _xbee = xbee;
     _responseListener = responseListener;
 }
Пример #29
0
 /// <summary>
 ///   TODO: Update Comments
 ///     
 /// </summary>
 /// <param name="localXBee" type="NETMF.OpenSource.XBee.Api.XBee">
 ///     <para>
 ///         
 ///     </para>
 /// </param>
 public AtRequest(XBeeApi localXBee)
     : base(localXBee)
 {
 }
Пример #30
0
 protected RequestBase(XBeeApi localXBee)
 {
     LocalXBee = localXBee;
 }
Пример #31
0
 /// <summary>
 ///   TODO: Update Comments
 ///     
 /// </summary>
 /// <param name="xbee" type="NETMF.OpenSource.XBee.Api.XBee">
 ///     <para>
 ///         
 ///     </para>
 /// </param>
 public RawRequest(XBeeApi xbee)
     : base(xbee)
 {
 }
Пример #32
0
 /// <summary>
 ///   TODO: Update Comments
 ///
 /// </summary>
 /// <param name="localXBee" type="NETMF.OpenSource.XBee.Api.XBee">
 ///     <para>
 ///
 ///     </para>
 /// </param>
 public AtRequest(XBeeApi localXBee)
     : base(localXBee)
 {
 }
Пример #33
0
 public static XBeeAddress64 Read(XBeeApi sender, XBeeAddress remoteXbee)
 {
     var sh = sender.Send(AtCmd.SerialNumberHigh).To(remoteXbee).GetResponse();
     var sl = sender.Send(AtCmd.SerialNumberLow).To(remoteXbee).GetResponse();
     return Parse((AtResponse)sl, (AtResponse)sh);
 }
Пример #34
0
 private XBeeConfiguration(XBeeApi xbee, XBeeAddress remoteXbee = null)
 {
     _xbee = xbee;
     _remoteXbee = remoteXbee;
 }
Пример #35
0
        public static ApiModes Read(XBeeApi xbee)
        {
            var request = xbee.Send(AtCmd.ApiEnable);

            return(Parse(request.GetResponse()));
        }
Пример #36
0
 /// <summary>
 ///   TODO: Update Comments
 ///     
 /// </summary>
 /// <param name="sender" type="NETMF.OpenSource.XBee.Api.XBee">
 ///     <para>
 ///         
 ///     </para>
 /// </param>
 /// <param name="remoteXbee" type="NETMF.OpenSource.XBee.Api.XBeeAddress">
 ///     <para>
 ///         
 ///     </para>
 /// </param>
 public static void Write(XBeeApi sender, XBeeAddress remoteXbee)
 {
     var request = sender.Send(AtCmd.Write).To(remoteXbee);
     Parse((AtResponse) request.GetResponse());
 }
Пример #37
0
 private XBeeConfiguration(XBeeApi xbee, XBeeAddress remoteXbee = null)
 {
     _xbee       = xbee;
     _remoteXbee = remoteXbee;
 }
Пример #38
0
 public static ApiModes Read(XBeeApi xbee)
 {
     var request = xbee.Send(AtCmd.ApiEnable);
     return Parse(request.GetResponse());
 }
Пример #39
0
        /// <summary>
        ///   TODO: Update Comments
        ///
        /// </summary>
        /// <param name="xbee" type="NETMF.OpenSource.XBee.Api.XBee">
        ///     <para>
        ///
        ///     </para>
        /// </param>
        public static void Write(XBeeApi xbee)
        {
            var request = xbee.Send(AtCmd.Write);

            Parse(request.GetResponse());
        }
Пример #40
0
 public static ApiModes Read(XBeeApi sender, XBeeAddress remoteXbee)
 {
     var request = sender.Send(AtCmd.ApiEnable).To(remoteXbee);
     return Parse((AtResponse) request.GetResponse());
 }
Пример #41
0
 public DataRequest(XBeeApi xbee)
     : base(xbee)
 {
 }
Пример #42
0
 /// <summary>
 ///   TODO: Update Comments
 ///
 /// </summary>
 /// <param name="xbee" type="NETMF.OpenSource.XBee.Api.XBee">
 ///     <para>
 ///
 ///     </para>
 /// </param>
 public DataDelegateRequest(XBeeApi xbee)
     : base(xbee)
 {
 }
Пример #43
0
 /// <summary>
 ///   TODO: Update Comments
 ///     
 /// </summary>
 /// <param name="payloadDelegate" type="NETMF.OpenSource.XBee.Api.XBee.PayloadDelegate">
 ///     <para>
 ///         
 ///     </para>
 /// </param>
 internal void Init(XBeeApi.PayloadDelegate payloadDelegate)
 {
     Init();
     _bytesDelegate = payloadDelegate;
 }
Пример #44
0
 public DataRequest(XBeeApi xbee)
     : base(xbee)
 {
 }
Пример #45
0
        public static HardwareVersions Read(XBeeApi sender, XBeeAddress remoteXBee)
        {
            var request = sender.Send(AtCmd.HardwareVersion).To(remoteXBee);

            return(Parse((AtResponse)request.GetResponse()));
        }
Пример #46
0
 internal AsyncSendResult(XBeeApi xbee, IPacketListener responseListener)
 {
     _xbee             = xbee;
     _responseListener = responseListener;
 }
Пример #47
0
        public static string Read(XBeeApi xbee)
        {
            var request = xbee.Send(AtCmd.NodeIdentifier);

            return(Parse(request.GetResponse()));
        }
Пример #48
0
 /// <summary>
 ///   TODO: Update Comments
 ///
 /// </summary>
 /// <param name="xbee" type="NETMF.OpenSource.XBee.Api.XBee">
 ///     <para>
 ///
 ///     </para>
 /// </param>
 public RawRequest(XBeeApi xbee)
     : base(xbee)
 {
 }
Пример #49
0
 public static string Read(XBeeApi sender, XBeeAddress remoteXbee)
 {
     var request = sender.Send(AtCmd.FirmwareVersion).To(remoteXbee);
     return Parse((AtResponse) request.GetResponse());
 }
Пример #50
0
 public static XBeeAddress64 Read(XBeeApi xbee)
 {
     var sh = xbee.Send(AtCmd.SerialNumberHigh).GetResponse();
     var sl = xbee.Send(AtCmd.SerialNumberLow).GetResponse();
     return Parse(sl, sh);
 }
Пример #51
0
 /// <summary>
 ///   TODO: Update Comments
 ///     
 /// </summary>
 /// <param name="xbee" type="NETMF.OpenSource.XBee.Api.XBee">
 ///     <para>
 ///         
 ///     </para>
 /// </param>
 public static void Write(XBeeApi xbee)
 {
     var request = xbee.Send(AtCmd.Write);
     Parse(request.GetResponse());
 }
Пример #52
0
 public static string Read(XBeeApi xbee)
 {
     var request = xbee.Send(AtCmd.NodeIdentifier);
     return Parse(request.GetResponse());
 }