com.digi.xbee.api.packet

## Class XBeeAPIPacket

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

- Direct Known Subclasses:
    ATCommandPacket, ATCommandQueuePacket, ATCommandResponsePacket, GenericXBeePacket, IODataSampleRxIndicatorPacket, ModemStatusPacket, ReceivePacket, RemoteATCommandPacket, RemoteATCommandResponsePacket, RX16IOPacket, RX16Packet, RX64IOPacket, RX64Packet, TransmitPacket, TransmitStatusPacket, TX16Packet, TX64Packet, TXStatusPacket, UnknownXBeePacket

      public abstract class XBeeAPIPacket
      extends XBeePacket

  This abstract class provides the basic structure of a ZigBee API frame.

  Derived classes should implement their own methods to generate the API data and frame ID in case they support it.

  Basic operations such as frame type retrieval are performed in this class.

  See Also:
    `XBeePacket`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `NO_FRAME_ID`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `checkFrameID(int id)` Returns whether the given ID is the current frame ID.
    `byte[]` | `getAPIData()` Returns the XBee API packet data.
    `int` | `getFrameID()` Returns the Frame ID of the API packet.
    `APIFrameType` | `getFrameType()` Returns the XBee packet frame type.
    `int` | `getFrameTypeValue()` Returns the XBee packet frame type integer value.
    `byte[]` | `getPacketData()` Returns the packet data.
    `boolean` | `isBroadcast()` Returns whether or not the packet is a broadcast packet.
    `abstract boolean` | `needsAPIFrameID()` Returns whether the API packet needs API Frame ID or not.
    `void` | `setFrameID(int frameID)` Sets the frame ID of the API packet.

    - ### 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`

- - ### Field Detail

    - #### NO_FRAME_ID

          public static final int NO_FRAME_ID

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### checkFrameID

          public boolean checkFrameID(int id)

      Returns whether the given ID is the current frame ID.
      Parameters:
        `id` - The frame id to check.
      Returns:
        `true` if frame ID is equal to the `id` provided, `false` otherwise or if the frame does not need an ID.
      See Also:
        `getFrameID()`, `needsAPIFrameID()`, `setFrameID(int)`

    - #### getAPIData

          public byte[] getAPIData()

      Returns the XBee API packet data.

      This does not include the frame ID if it is needed.

      Returns:
        The XBee API packet data.

    - #### getFrameID

          public int getFrameID()

      Returns the Frame ID of the API packet.

      If the frame ID is not configured or if the API packet does not need a Frame ID (`if (!needsAPIFrameID())`) this method returns `NO_FRAME_ID` (9999).

      Returns:
        The frame ID.
      See Also:
        `NO_FRAME_ID`, `needsAPIFrameID()`, `setFrameID(int)`

    - #### getFrameType

          public APIFrameType getFrameType()

      Returns the XBee packet frame type.
      Returns:
        The XBee packet frame type.
      See Also:
        `APIFrameType`

    - #### getFrameTypeValue

          public int getFrameTypeValue()

      Returns the XBee packet frame type integer value.
      Returns:
        The XBee packet frame type integer value.

    - #### getPacketData

          public byte[] getPacketData()

      Description copied from class: `XBeePacket`
      Returns the packet data.
      Specified by:
        `getPacketData` in class `XBeePacket`
      Returns:
        The packet data.

    - #### isBroadcast

          public boolean isBroadcast()

      Returns whether or not the packet is a broadcast packet.
      Returns:
        `true` if the packet is a broadcast packet, `false` otherwise.

    - #### needsAPIFrameID

          public abstract boolean needsAPIFrameID()

      Returns whether the API packet needs API Frame ID or not.
      Returns:
        `true` if the packet needs API Frame ID, `false` otherwise.

    - #### setFrameID

          public void setFrameID(int frameID)

      Sets the frame ID of the API packet.

      If the API packet does not need a frame ID (`if (!needsAPIFrameID())`), this method does nothing.

      Parameters:
        `frameID` - The frame ID to set.
      Throws:
        `IllegalArgumentException` - if `frameID < 0` or if `frameID > 255`.
      See Also:
        `getFrameID()`

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