com.digi.xbee.api.models

## Class XBeePacketsQueue

- java.lang.Object
- - com.digi.xbee.api.models.XBeePacketsQueue

-     public class XBeePacketsQueue
      extends Object

  This class represents a queue of XBee packets used for sequential packets reading within the XBee Java API.

  The class provides some methods to get specific packet types from different source nodes.

  See Also:
    `XBeePacket`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_MAX_LENGTH` Default maximum number of packets to store in the queue (value: 50).

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XBeePacketsQueue()` Class constructor.
    `XBeePacketsQueue(int maxLength)` Class constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addPacket(XBeePacket xbeePacket)` Adds the provided packet to the list of packets.
    `void` | `clearQueue()` Clears the list of packets.
    `int` | `getCurrentSize()` Returns the current size of the XBee packets queue.
    `XBeePacket` | `getFirstDataPacket(int timeout)` Returns the first data packet from the queue waiting up to the specified timeout if necessary for an XBee data packet to become available.
    `XBeePacket` | `getFirstDataPacketFrom(RemoteXBeeDevice remoteXBeeDevice, int timeout)` Returns the first data packet from the queue whose 64-bit source address matches the address of the provided remote XBee device.
    `XBeePacket` | `getFirstPacket(int timeout)` Returns the first packet from the queue waiting up to the specified timeout if necessary for an XBee packet to become available.
    `XBeePacket` | `getFirstPacketFrom(RemoteXBeeDevice remoteXBeeDevice, int timeout)` Returns the first packet from the queue whose 64-bit source address matches the address of the provided remote XBee device.
    `int` | `getMaxSize()` Returns the maximum size of the XBee packets queue.

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

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

- - ### Field Detail

    - #### DEFAULT_MAX_LENGTH

          public static final int DEFAULT_MAX_LENGTH

      Default maximum number of packets to store in the queue (value: 50).
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### XBeePacketsQueue

          public XBeePacketsQueue()

      Class constructor. Instantiates a new object of type `XBeePacketsQueue`.

    - #### XBeePacketsQueue

          public XBeePacketsQueue(int maxLength)

      Class constructor. Instantiates a new object of type `XBeePacketsQueue` with the given maximum length.
      Parameters:
        `maxLength` - Maximum length of the queue.
      Throws:
        `IllegalArgumentException` - if `maxLength < 1`.

  - ### Method Detail

    - #### addPacket

          public void addPacket(XBeePacket xbeePacket)

      Adds the provided packet to the list of packets. If the queue is full the first packet will be discarded to add the given one.
      Parameters:
        `xbeePacket` - The XBee packet to be added to the list.
      See Also:
        `XBeePacket`

    - #### clearQueue

          public void clearQueue()

      Clears the list of packets.

    - #### getCurrentSize

          public int getCurrentSize()

      Returns the current size of the XBee packets queue.
      Returns:
        The current size of the XBee packets queue.

    - #### getFirstDataPacket

          public XBeePacket getFirstDataPacket(int timeout)

      Returns the first data packet from the queue waiting up to the specified timeout if necessary for an XBee data packet to become available. `null` if the queue is empty or there is not any data packet inside.
      Parameters:
        `timeout` - The time in milliseconds to wait for an XBee data packet to become available. 0 to return immediately.
      Returns:
        The first data packet from the queue, `null` if it is empty or no data packets are contained in the queue.
      See Also:
        `XBeePacket`

    - #### getFirstDataPacketFrom

          public XBeePacket getFirstDataPacketFrom(RemoteXBeeDevice remoteXBeeDevice,
                                          int timeout)

      Returns the first data packet from the queue whose 64-bit source address matches the address of the provided remote XBee device.

      The methods waits up to the specified timeout if necessary for an XBee data packet to become available. `null` if the queue is empty or there is not any XBee data packet sent by the provided remote XBee device.

      Parameters:
        `remoteXBeeDevice` - The XBee device containing the 64-bit address to look for in the list of packets.
        `timeout` - The time in milliseconds to wait for an XBee data packet from the specified remote XBee device to become available. 0 to return immediately.
      Returns:
        The first XBee data packet whose its 64-bit address matches the address of the provided remote XBee device. `null` if no data packets from the specified XBee device are found in the queue.
      See Also:
        `RemoteXBeeDevice`, `XBeePacket`

    - #### getFirstPacket

          public XBeePacket getFirstPacket(int timeout)

      Returns the first packet from the queue waiting up to the specified timeout if necessary for an XBee packet to become available. `null` if the queue is empty.
      Parameters:
        `timeout` - The time in milliseconds to wait for an XBee packet to become available. 0 to return immediately.
      Returns:
        The first packet from the queue, `null` if it is empty.
      See Also:
        `XBeePacket`

    - #### getFirstPacketFrom

          public XBeePacket getFirstPacketFrom(RemoteXBeeDevice remoteXBeeDevice,
                                      int timeout)

      Returns the first packet from the queue whose 64-bit source address matches the address of the provided remote XBee device.

      The methods waits up to the specified timeout if necessary for an XBee packet to become available. Null if the queue is empty or there is not any XBee packet sent by the provided remote XBee device.

      Parameters:
        `remoteXBeeDevice` - The remote XBee device containing the 64-bit address to look for in the list of packets.
        `timeout` - The time in milliseconds to wait for an XBee packet from the specified remote XBee device to become available. 0 to return immediately.
      Returns:
        The first XBee packet whose 64-bit address matches the address of the provided remote XBee device. `null` if no packets from the specified XBee device are found in the queue.
      See Also:
        `RemoteXBeeDevice`, `XBeePacket`

    - #### getMaxSize

          public int getMaxSize()

      Returns the maximum size of the XBee packets queue.
      Returns:
        The maximum size of the XBee packets queue.

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