com.digi.xbee.api.packet.common

## Class ATCommandResponsePacket

- java.lang.Object
- - com.digi.xbee.api.packet.XBeePacket
  - - com.digi.xbee.api.packet.XBeeAPIPacket
    - - com.digi.xbee.api.packet.common.ATCommandResponsePacket

-     public class ATCommandResponsePacket
      extends XBeeAPIPacket

  This class represents an AT Command Response packet. Packet is built using the parameters of the constructor or providing a valid API payload.

  In response to an AT Command message, the module will send an AT Command Response message. Some commands will send back multiple frames (for example, the ND (Node Discover) command).

  This packet is received in response of an `ATCommandPacket`.

  Response also includes an `ATCommandStatus` object with the status of the AT command.

  See Also:
    `ATCommandPacket`, `ATCommandStatus`, `XBeeAPIPacket`

- - ### Field Summary

    - ### Fields inherited from class com.digi.xbee.api.packet.XBeeAPIPacket

      `NO_FRAME_ID`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ATCommandResponsePacket(int frameID, ATCommandStatus status, String command, byte[] commandValue)` Class constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ATCommandResponsePacket` | `createPacket(byte[] payload)` Creates a new `ATCommandResponsePacket` object from the given payload.
    `LinkedHashMap<String,String>` | `getAPIPacketParameters()` Returns a map with the XBee packet parameters and their values.
    `String` | `getCommand()` Returns the AT command.
    `byte[]` | `getCommandValue()` Returns the AT command response value.
    `String` | `getCommandValueAsString()` Returns the AT command response value as String.
    `ATCommandStatus` | `getStatus()` Returns the AT command response status.
    `boolean` | `needsAPIFrameID()` Returns whether the API packet needs API Frame ID or not.
    `void` | `setCommandValue(byte[] commandValue)` Sets the AT command response value.
    `void` | `setCommandValue(String commandValue)` Sets the AT command response value as String.

    - ### Methods inherited from class com.digi.xbee.api.packet.XBeeAPIPacket

      `checkFrameID, getAPIData, getFrameID, getFrameType, getFrameTypeValue, getPacketData, isBroadcast, setFrameID`

    - ### Methods inherited from class com.digi.xbee.api.packet.XBeePacket

      `generateByteArray, generateByteArrayEscaped, getChecksum, getPacketLength, getParameters, parsePacket, parsePacket, toPrettyString, toString`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ATCommandResponsePacket

          public ATCommandResponsePacket(int frameID,
                                 ATCommandStatus status,
                                 String command,
                                 byte[] commandValue)

      Class constructor. Instantiates a new `ATCommandResponsePacket` object with the given parameters.
      Parameters:
        `frameID` - The XBee API frame ID.
        `status` - The AT command response status.
        `command` - The AT command.
        `commandValue` - The AT command response value.
      Throws:
        `IllegalArgumentException` - if `frameID < 0` or if `frameID > 255`.
        `NullPointerException` - if `status == null` or if `command == null`.
      See Also:
        `ATCommandStatus`

  - ### Method Detail

    - #### createPacket

          public static ATCommandResponsePacket createPacket(byte[] payload)

      Creates a new `ATCommandResponsePacket` object from the given payload.
      Parameters:
        `payload` - The API frame payload. It must start with the frame type corresponding to a AT Command Response packet (`0x88`). The byte array must be in `OperatingMode.API` mode.
      Returns:
        Parsed AT Command Response packet.
      Throws:
        `IllegalArgumentException` - if `payload[0] != APIFrameType.AT_COMMAND.getValue()` or if `payload.length <` or if `frameID < 0` or if `frameID > 255`.
        `NullPointerException` - if `payload == null`.

    - #### getAPIPacketParameters

          public LinkedHashMap<String,String> getAPIPacketParameters()

      Description copied from class: `XBeeAPIPacket`
      Returns a map with the XBee packet parameters and their values.
      Returns:
        A sorted map containing the XBee packet parameters with their values.

    - #### getCommand

          public String getCommand()

      Returns the AT command.
      Returns:
        The AT command.

    - #### getCommandValue

          public byte[] getCommandValue()

      Returns the AT command response value.
      Returns:
        The AT command response value.

    - #### getCommandValueAsString

          public String getCommandValueAsString()

      Returns the AT command response value as String.
      Returns:
        The AT command response value as String, `null` if no value is set.

    - #### getStatus

          public ATCommandStatus getStatus()

      Returns the AT command response status.
      Returns:
        The AT command response status.
      See Also:
        `ATCommandStatus`

    - #### needsAPIFrameID

          public boolean needsAPIFrameID()

      Description copied from class: `XBeeAPIPacket`
      Returns whether the API packet needs API Frame ID or not.
      Specified by:
        `needsAPIFrameID` in class `XBeeAPIPacket`
      Returns:
        `true` if the packet needs API Frame ID, `false` otherwise.

    - #### setCommandValue

          public void setCommandValue(byte[] commandValue)

      Sets the AT command response value.
      Parameters:
        `commandValue` - The AT command response value.

    - #### setCommandValue

          public void setCommandValue(String commandValue)

      Sets the AT command response value as String.
      Parameters:
        `commandValue` - The AT command response value as String.

© Copyright 2014–2014 Digi International Inc. All rights reserved.