com.digi.xbee.api.packet.common

## Class TransmitPacket

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

-     public class TransmitPacket
      extends XBeeAPIPacket

  This class represents a Transmit Packet. Packet is built using the parameters of the constructor or providing a valid API payload.

  A Transmit Request API frame causes the module to send data as an RF packet to the specified destination.

  The 64-bit destination address should be set to `0x000000000000FFFF` for a broadcast transmission (to all devices).

  The coordinator can be addressed by either setting the 64-bit address to all `0x00` and the 16-bit address to `0xFFFE`, OR by setting the 64-bit address to the coordinator's 64-bit address and the 16-bit address to `0x0000`.

  For all other transmissions, setting the 16-bit address to the correct 16-bit address can help improve performance when transmitting to multiple destinations.

  If a 16-bit address is not known, this field should be set to `0xFFFE` (unknown).

  The Transmit Status frame (`APIFrameType.TRANSMIT_REQUEST`) will indicate the discovered 16-bit address, if successful (see `TransmitStatusPacket`).

  The broadcast radius can be set from `0` up to `NH`. If set to `0`, the value of `NH` specifies the broadcast radius (recommended). This parameter is only used for broadcast transmissions.

  The maximum number of payload bytes can be read with the `NP` command.

  Several transmit options can be set using the transmit options bitfield.

  See Also:
    `XBeeTransmitOptions`, `XBee16BitAddress.COORDINATOR_ADDRESS`, `XBee16BitAddress.UNKNOWN_ADDRESS`, `XBee64BitAddress.BROADCAST_ADDRESS`, `XBee64BitAddress.COORDINATOR_ADDRESS`, `XBeeAPIPacket`

- - ### Field Summary

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

      `NO_FRAME_ID`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TransmitPacket(int frameID, XBee64BitAddress destAddress64, XBee16BitAddress destAddress16, int broadcastRadius, int transmitOptions, byte[] rfData)` Class constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static TransmitPacket` | `createPacket(byte[] payload)` Creates a new `TransmitPacket` object from the given payload.
    `XBee16BitAddress` | `get16bitDestinationAddress()` Returns the 16-bit destination address.
    `XBee64BitAddress` | `get64bitDestinationAddress()` Returns the 64-bit destination address.
    `LinkedHashMap<String,String>` | `getAPIPacketParameters()` Returns a map with the XBee packet parameters and their values.
    `int` | `getBroadcastRadius()` Returns the broadcast radius.
    `byte[]` | `getRFData()` Returns the RF Data to send.
    `int` | `getTransmitOptions()` Returns the transmit options bitfield.
    `boolean` | `isBroadcast()` Returns whether or not the packet is a broadcast packet.
    `boolean` | `needsAPIFrameID()` Returns whether the API packet needs API Frame ID or not.
    `void` | `setRFData(byte[] rfData)` Sets the RF Data to send.

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

      `checkFrameID, getAPIData, getFrameID, getFrameType, getFrameTypeValue, getPacketData, 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

    - #### TransmitPacket

          public TransmitPacket(int frameID,
                        XBee64BitAddress destAddress64,
                        XBee16BitAddress destAddress16,
                        int broadcastRadius,
                        int transmitOptions,
                        byte[] rfData)

      Class constructor. Instantiates a new `TransmitPacket` object with the given parameters.
      Parameters:
        `frameID` - Frame ID.
        `destAddress64` - 64-bit address of the destination device.
        `destAddress16` - 16-bit address of the destination device.
        `broadcastRadius` - maximum number of hops a broadcast transmission can occur.
        `transmitOptions` - Bitfield of supported transmission options.
        `rfData` - RF Data that is sent to the destination device.
      Throws:
        `IllegalArgumentException` - if `frameID < 0` or if `frameID > 255` or if `broadcastRadius < 0` or if `broadcastRadius > 255` or if `transmitOptions < 0` or if `transmitOptions > 255`.
        `NullPointerException` - if `destAddress64 == null` or if `destAddress16 == null`.
      See Also:
        `XBeeTransmitOptions`, `XBee16BitAddress`, `XBee64BitAddress`

  - ### Method Detail

    - #### createPacket

          public static TransmitPacket createPacket(byte[] payload)

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

    - #### get16bitDestinationAddress

          public XBee16BitAddress get16bitDestinationAddress()

      Returns the 16-bit destination address.
      Returns:
        The 16-bit destination address.
      See Also:
        `XBee16BitAddress`

    - #### get64bitDestinationAddress

          public XBee64BitAddress get64bitDestinationAddress()

      Returns the 64-bit destination address.
      Returns:
        The 64-bit destination address.
      See Also:
        `XBee64BitAddress`

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

    - #### getBroadcastRadius

          public int getBroadcastRadius()

      Returns the broadcast radius.
      Returns:
        The broadcast radius.

    - #### getRFData

          public byte[] getRFData()

      Returns the RF Data to send.
      Returns:
        RF Data to send.

    - #### getTransmitOptions

          public int getTransmitOptions()

      Returns the transmit options bitfield.
      Returns:
        The transmit options bitfield.
      See Also:
        `XBeeTransmitOptions`

    - #### isBroadcast

          public boolean isBroadcast()

      Description copied from class: `XBeeAPIPacket`
      Returns whether or not the packet is a broadcast packet.
      Overrides:
        `isBroadcast` in class `XBeeAPIPacket`
      Returns:
        `true` if the packet is a broadcast packet, `false` otherwise.

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

    - #### setRFData

          public void setRFData(byte[] rfData)

      Sets the RF Data to send.
      Parameters:
        `rfData` - RF Data to send.

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