Esempio n. 1
0
        /**
         * Class constructor. Instantiates a new
         * {@code RemoteATCommandResponsePacket} object with the given parameters.
         *
         * @param frameID frame ID.
         * @param sourceAddress64 64-bit address of the remote radio returning
         *                        response.
         * @param sourceAddress16 16-bit network address of the remote.
         * @param command The AT command.
         * @param status The command status.
         * @param commandValue The AT command response value.
         *
         * @throws ArgumentException if {@code frameID < 0} or
         *                                  if {@code frameID > 255}.
         * @throws ArgumentNullException if {@code sourceAddress64 == null} or
         *                              if {@code sourceAddress16 == null} or
         *                              if {@code command == null} or
         *                              if {@code status == null}.
         *
         * @see com.digi.xbee.api.models.ATCommandStatus
         * @see com.digi.xbee.api.models.XBee16BitAddress
         * @see com.digi.xbee.api.models.XBee64BitAddress
         */
        public RemoteATCommandResponsePacket(byte frameID, XBee64BitAddress sourceAddress64, XBee16BitAddress sourceAddress16,
                                             String command, ATCommandStatus status, byte[] commandValue)
            : base(APIFrameType.REMOTE_AT_COMMAND_RESPONSE)
        {
            if (sourceAddress64 == null)
            {
                throw new ArgumentNullException("64-bit source address cannot be null.");
            }
            if (sourceAddress16 == null)
            {
                throw new ArgumentNullException("16-bit source address cannot be null.");
            }
            if (command == null)
            {
                throw new ArgumentNullException("AT command cannot be null.");
            }
            if (status == null)
            {
                throw new ArgumentNullException("AT command status cannot be null.");
            }
            if (frameID < 0 || frameID > 255)
            {
                throw new ArgumentException("Frame ID must be between 0 and 255.");
            }

            this.frameID         = frameID;
            this.sourceAddress64 = sourceAddress64;
            this.sourceAddress16 = sourceAddress16;
            this.Command         = command;
            this.Status          = status;
            this.commandValue    = commandValue;
            this.logger          = LogManager.GetLogger <RemoteATCommandResponsePacket>();
        }
Esempio n. 2
0
 /// <summary>
 /// Class constructor. Instantiates a <see cref="ATCommandResponsePacket"/> with the given parameters.
 /// </summary>
 /// <param name="frameID">The XBee API frame ID.</param>
 /// <param name="status">The AT command response status.</param>
 /// <param name="command">The AT command.</param>
 /// <param name="commandValue">The AT command response value.</param>
 /// <exception cref="ArgumentException">If <c><paramref name="frameID"/> <![CDATA[<]]> 0</c>
 /// or if <c><paramref name="frameID"/> <![CDATA[>]]> 255</c>.</exception>
 /// <exception cref="ArgumentNullException">If <paramref name="command"/> is <c>null</c>.</exception>
 /// <seealso cref="ATCommandStatus"/>
 public ATCommandResponsePacket(byte frameID, ATCommandStatus status, string command, byte[] commandValue)
     : base(APIFrameType.AT_COMMAND_RESPONSE)
 {
     FrameID      = frameID;
     Status       = status;
     Command      = command ?? throw new ArgumentNullException("AT command cannot be null.");
     CommandValue = commandValue;
     logger       = LogManager.GetLogger <ATCommandResponsePacket>();
 }
        /// <summary>
        /// Initializes a new instance of the class <see cref="ATCommandResponse"/>.
        /// </summary>
        /// <param name="command">The <see cref="ATCommand"/> that generated the response.</param>
        /// <param name="response">The command response in byte array format.</param>
        /// <param name="status">The <see cref="ATCommandStatus"/> containing the response status.</param>
        /// <exception cref="ArgumentNullException">if <paramref name="command"/> is null or <paramref name="status"/> is null.</exception>
        /// <seealso cref="ATCommand"/>
        /// <seealso cref="ATCommandStatus"/>
        public ATCommandResponse(ATCommand command, byte[] response, ATCommandStatus status)
        {
            Contract.Requires<ArgumentNullException>(command != null, "Command cannot be null.");
            Contract.Requires<ArgumentNullException>(status != null, "Status cannot be null.");

            Command = command;
            Response = response;
            Status = status;
        }
		/// <summary>
		/// Initializes a new instance of the class <see cref="ATCommandResponse"/>.
		/// </summary>
		/// <param name="command">The <see cref="ATCommand"/> that generated the response.</param>
		/// <param name="response">The command response in byte array format.</param>
		/// <param name="status">The <see cref="ATCommandStatus"/> containing the response status.</param>
		/// <exception cref="ArgumentNullException">if <paramref name="command"/> is null or <paramref name="status"/> is null.</exception>
		/// <seealso cref="ATCommand"/>
		/// <seealso cref="ATCommandStatus"/>
		public ATCommandResponse(ATCommand command, byte[] response, ATCommandStatus status)
		{
			Contract.Requires<ArgumentNullException>(command != null, "Command cannot be null.");
			Contract.Requires<ArgumentNullException>(status != null, "Status cannot be null.");

			Command = command;
			Response = response;
			Status = status;
		}
Esempio n. 5
0
        /// <summary>
        /// Gest the <see cref="ATCommandStatus"/> associated to the specified <paramref name="id"/>.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="id">Id to retrieve the corresponding <paramref name="source"/>.</param>
        /// <returns>The <see cref="ATCommandStatus"/> associated to the specified <paramref name="id"/>.</returns>
        public static ATCommandStatus Get(this ATCommandStatus source, byte id)
        {
            var values = Enum.GetValues(typeof(ATCommandStatus)).OfType <ATCommandStatus>();

            if (values.Cast <byte>().Contains(id))
            {
                return((ATCommandStatus)id);
            }

            return(ATCommandStatus.UNKNOWN);
        }
        /**
         * Class constructor. Instantiates a new {@code ATCommandResponsePacket}
         * object with the given parameters.
         *
         * @param frameID The XBee API frame ID.
         * @param status The AT command response status.
         * @param command The AT command.
         * @param commandValue The AT command response value.
         *
         * @throws ArgumentException if {@code frameID < 0} or
         *                                  if {@code frameID > 255}.
         * @throws ArgumentNullException if {@code status == null} or
         *                              if {@code command == null}.
         *
         * @see com.digi.xbee.api.models.ATCommandStatus
         */
        public ATCommandResponsePacket(byte frameID, ATCommandStatus status, String command, byte[] commandValue)
            : base(APIFrameType.AT_COMMAND_RESPONSE)
        {
            if (command == null)
            {
                throw new ArgumentNullException("AT command cannot be null.");
            }
            if (status == null)
            {
                throw new ArgumentNullException("AT command status cannot be null.");
            }

            this.frameID      = frameID;
            this.Status       = status;
            this.Command      = command;
            this.CommandValue = commandValue;
            this.logger       = LogManager.GetLogger <ATCommandResponsePacket>();
        }
        /**
         * Class constructor. Instantiates a new
         * {@code RemoteATCommandResponsePacket} object with the given parameters.
         *
         * @param frameID frame ID.
         * @param sourceAddress64 64-bit address of the remote radio returning
         *                        response.
         * @param sourceAddress16 16-bit network address of the remote.
         * @param command The AT command.
         * @param status The command status.
         * @param commandValue The AT command response value.
         *
         * @throws ArgumentException if {@code frameID < 0} or
         *                                  if {@code frameID > 255}.
         * @throws ArgumentNullException if {@code sourceAddress64 == null} or
         *                              if {@code sourceAddress16 == null} or
         *                              if {@code command == null} or
         *                              if {@code status == null}.
         *
         * @see com.digi.xbee.api.models.ATCommandStatus
         * @see com.digi.xbee.api.models.XBee16BitAddress
         * @see com.digi.xbee.api.models.XBee64BitAddress
         */
        public RemoteATCommandResponsePacket(byte frameID, XBee64BitAddress sourceAddress64, XBee16BitAddress sourceAddress16,
            String command, ATCommandStatus status, byte[] commandValue)
            : base(APIFrameType.REMOTE_AT_COMMAND_RESPONSE)
        {
            if (sourceAddress64 == null)
                throw new ArgumentNullException("64-bit source address cannot be null.");
            if (sourceAddress16 == null)
                throw new ArgumentNullException("16-bit source address cannot be null.");
            if (command == null)
                throw new ArgumentNullException("AT command cannot be null.");
            if (status == null)
                throw new ArgumentNullException("AT command status cannot be null.");
            if (frameID < 0 || frameID > 255)
                throw new ArgumentException("Frame ID must be between 0 and 255.");

            this.frameID = frameID;
            this.sourceAddress64 = sourceAddress64;
            this.sourceAddress16 = sourceAddress16;
            this.Command = command;
            this.Status = status;
            this.commandValue = commandValue;
            this.logger = LogManager.GetLogger<RemoteATCommandResponsePacket>();
        }
		/// <summary>
		/// Initializes a new instance of the class <see cref="ATCommandResponse"/>.
		/// </summary>
		/// <param name="command">The <see cref="ATCommand"/> that generated the response.</param>
		/// <param name="status">The <see cref="ATCommandStatus"/> containing the response status.</param>
		/// <exception cref="ArgumentNullException">if <paramref name="command"/> is null or <paramref name="status"/> is null.</exception>
		/// <seealso cref="ATCommand"/>
		/// <seealso cref="ATCommandStatus"/>
		public ATCommandResponse(ATCommand command, ATCommandStatus status)
			: this(command, null, status)
		{
		}
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ATCommandException"/> class with a specified
 /// error message.
 /// </summary>
 /// <param name="message">ThThe error message that explains the reason for this exception.</param>
 /// <param name="atCommandStatus">The status of the AT command response.</param>
 public ATCommandException(string message, ATCommandStatus atCommandStatus) : base(message)
 {
     CommandStatus = atCommandStatus;
 }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ATCommandException"/> class with a specified error
 /// message and the exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">ThThe error message that explains the reason for this exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a null
 /// reference if no inner exception is specified.</param>
 /// <param name="atCommandStatus">The status of the AT command response.</param>
 public ATCommandException(string message, Exception innerException, ATCommandStatus atCommandStatus) : base(message, innerException)
 {
     CommandStatus = atCommandStatus;
 }
Esempio n. 11
0
 /// <summary>
 /// Gets the AT Command Status description.
 /// </summary>
 /// <param name="source"></param>
 /// <returns>The AT Command Status description.</returns>
 public static string GetDescription(this ATCommandStatus source)
 {
     return(lookupTable[source]);
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ATCommandException"/> class.
 /// </summary>
 public ATCommandException(ATCommandStatus atCommandStatus) : base(DEFAULT_MESSAGE)
 {
     CommandStatus = atCommandStatus;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ATCommandException"/> class with a specified error message.
 /// </summary>
 /// <param name="message">ThThe error message that explains the reason for this exception.</param>
 /// <param name="atCommandStatus">The status of the AT command response.</param>
 public ATCommandException(string message, ATCommandStatus atCommandStatus)
     : base(message)
 {
     this.CommandStatus = atCommandStatus;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ATCommandException"/> class with a specified error message and the exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">ThThe error message that explains the reason for this exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
 /// <param name="atCommandStatus">The status of the AT command response.</param>
 public ATCommandException(string message, Exception innerException, ATCommandStatus atCommandStatus)
     : base(message, innerException)
 {
     this.CommandStatus = atCommandStatus;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ATCommandException"/> class.
 /// </summary>
 public ATCommandException(ATCommandStatus atCommandStatus)
     : base(DEFAULT_MESSAGE)
 {
     this.CommandStatus = atCommandStatus;
 }
Esempio n. 16
0
 /// <summary>
 /// Gets the AT Command Status ID.
 /// </summary>
 /// <param name="source"></param>
 /// <returns>The AT Command Status ID.</returns>
 public static byte GetId(this ATCommandStatus source)
 {
     return((byte)source);
 }
Esempio n. 17
0
 /// <summary>
 /// Returns the <see cref="ATCommandStatus"/> in string format.
 /// </summary>
 /// <param name="source"></param>
 /// <returns>The <see cref="ATCommandStatus"/> in string format.</returns>
 public static string ToDisplayString(this ATCommandStatus source)
 {
     return(lookupTable[source]);
 }
 /// <summary>
 /// Initializes a new instance of the class <see cref="ATCommandResponse"/>.
 /// </summary>
 /// <param name="command">The <see cref="ATCommand"/> that generated the response.</param>
 /// <param name="response">The command response in byte array format.</param>
 /// <param name="status">The <see cref="ATCommandStatus"/> containing the response status.</param>
 /// <exception cref="ArgumentNullException">if <paramref name="command"/> is <c>null</c>.</exception>
 /// <seealso cref="ATCommand"/>
 /// <seealso cref="ATCommandStatus"/>
 public ATCommandResponse(ATCommand command, byte[] response, ATCommandStatus status)
 {
     Command  = command ?? throw new ArgumentNullException("Command cannot be null.");
     Response = response;
     Status   = status;
 }
 /// <summary>
 /// Initializes a new instance of the class <see cref="ATCommandResponse"/>.
 /// </summary>
 /// <param name="command">The <see cref="ATCommand"/> that generated the response.</param>
 /// <param name="status">The <see cref="ATCommandStatus"/> containing the response status.</param>
 /// <exception cref="ArgumentNullException">if <paramref name="command"/> is null or <paramref name="status"/> is null.</exception>
 /// <seealso cref="ATCommand"/>
 /// <seealso cref="ATCommandStatus"/>
 public ATCommandResponse(ATCommand command, ATCommandStatus status)
     : this(command, null, status)
 {
 }