Class XBeeNode


public class XBeeNode extends IEEE802154Node
Implementation of a Node for XBee networks.

Integrated with XBeeTrafficController.

Each node has 3 addresses associated with it:

  1. A 16 bit PAN (Personal Area Network) ID assigned by the user
  2. A 16 bit User Assigned Address
  3. A 64 bit Globally Unique ID assigned by the manufacturer

All nodes in a given network must have the same PAN ID

  • Constructor Details

    • XBeeNode

      public XBeeNode()
      Create a new instance of XBeeNode.
    • XBeeNode

      public XBeeNode(byte[] pan, byte[] user, byte[] global)
    • XBeeNode

      public XBeeNode(com.digi.xbee.api.RemoteXBeeDevice rxd) throws com.digi.xbee.api.exceptions.XBeeException
      Throws:
      com.digi.xbee.api.exceptions.XBeeException
  • Method Details

    • setTrafficController

      public void setTrafficController(XBeeTrafficController controller)
      Set the Traffic Controller associated with this node.
      Parameters:
      controller - system connection traffic controller.
    • createInitPacket

      Create the needed Initialization packet (AbstractMRMessage) for this node.
      Specified by:
      createInitPacket in class IEEE802154Node
      Returns:
      null because not needed for XBeeNode
    • createOutPacket

      Create an Transmit packet (AbstractMRMessage) to send current state.
      Specified by:
      createOutPacket in class IEEE802154Node
      Returns:
      packet to send current node state.
    • getSensorsActive

      public boolean getSensorsActive()
      Are sensors present, and hence will this node need to be polled?
      Specified by:
      getSensorsActive in class IEEE802154Node
      Returns:
      'true' if at least one sensor is active for this node
    • setPoll

      public void setPoll(boolean poll)
      Set the isPolled attribute.
      Parameters:
      poll - true to set flag polled, else false.
    • getPoll

      public boolean getPoll()
      Get the isPolled attribute.
      Returns:
      true if isPolled flag set, else false.
    • handleTimeout

      Deal with a timeout in the transmission controller.
      Specified by:
      handleTimeout in class IEEE802154Node
      Parameters:
      m - message that didn't receive a reply
      l - listener that sent the message
      Returns:
      true if initialization required
    • resetTimeout

      A reply was received, so there was not timeout; do any needed processing. Implementation does nothing.
      Specified by:
      resetTimeout in class IEEE802154Node
      Parameters:
      m - message to process.
    • getXBeeAddress16

      public com.digi.xbee.api.models.XBee16BitAddress getXBeeAddress16()
      Convert the 16 bit user address to an XBee16BitAddress object.
      Returns:
      converted address object.
    • getXBeeAddress64

      public com.digi.xbee.api.models.XBee64BitAddress getXBeeAddress64()
      Convert the 64 bit address to an XBee64BitAddress object.
      Returns:
      converted address object.
    • setIdentifier

      public void setIdentifier(String id)
      XBee Nodes store an identifier. we want to be able to store and retrieve this information.
      Parameters:
      id - text id for node
    • getIdentifier

    • setPinBean

      public boolean setPinBean(int pin, NamedBean bean)
      Set the bean associated with the specified pin.
      Parameters:
      pin - is the XBee pin assigned.
      bean - is the bean we are attempting to add.
      Returns:
      true if bean added, false if previous assignment exists.
    • removePinBean

      public boolean removePinBean(int pin, NamedBean bean)
      Remove the bean associated with the specified pin.
      Parameters:
      pin - is the XBee pin assigned.
      bean - is the bean we are attempting to remove.
      Returns:
      true if bean removed, false if specified bean was not assigned to the pin.
    • getPinBean

      public NamedBean getPinBean(int pin)
      Get the bean associated with the specified pin.
      Parameters:
      pin - is the XBee pin assigned.
      Returns:
      the bean assigned to the pin, or null if no bean is assigned.
    • getPinAssigned

      public boolean getPinAssigned(int pin)
      Ask if a specified pin is assigned to a bean.
      Parameters:
      pin - is the XBee pin assigned.
      Returns:
      true if the pin has a bean assigned to it, false otherwise.
    • getPreferedName

      Get the prefered name for this XBee Node.
      Returns:
      the identifier string if it is not blank then a string representation of the bytes of the 16 bit address if it is not a broadcast address. Otherwise return the 64 bit GUID.
    • getPreferedTransmitAddress

      Get the prefered transmit address for this XBee Node.
      Returns:
      the 16 bit address if it is not a broadcast address. Otherwise return the 64 bit GUID.
    • getXBee

      public com.digi.xbee.api.RemoteXBeeDevice getXBee()
      Returns:
      RemoteXBeeDevice associated with this node
    • setXBee

      public void setXBee(com.digi.xbee.api.RemoteXBeeDevice rxd)
      Set the RemoteXBeeDevice associated with this node and configure address information.
      Parameters:
      rxd - the RemoteXBeeDevice associated with this node.
    • getIOStream

      Get the stream object associated with this node.
      Returns:
      stream object, created if does not exist.
    • connectPortController

      Connect and configure a StreamPortController object to the XBeeIOStream associated with this node.
      Parameters:
      cont - AbstractSTreamPortController object to connect
    • setPortController

      Connect a StreamPortController object to the XBeeIOStream associated with this node.
      Parameters:
      cont - AbstractSTreamPortController object to connect
    • getPortController

      Get the StreamPortController ojbect associated with the XBeeIOStream associated with this node.
      Returns:
      connected AbstractStreamPortController
    • connectPortController

      Connect and configure a StreamConnectionConfig object to the XBeeIOStream associated with this node.
      Parameters:
      cfg - AbstractStreamConnectionConfig object to connect
    • setPortController

      Connect a StreamConnectionConfig object to the XBeeIOStream associated with this node.
      Parameters:
      cfg - AbstractStreamConnectionConfig object to connect
    • getConnectionConfig

      Get the StreamConnectionConfig ojbect associated with the XBeeIOStream associated with this node.
      Returns:
      connected AbstractStreamConnectionConfig
    • toString

      public String toString()
      Provide a string representation of this XBee Node.
      Overrides:
      toString in class Object
    • setPRParameter

      void setPRParameter(int pin, Sensor.PullResistance pr) throws com.digi.xbee.api.exceptions.TimeoutException, com.digi.xbee.api.exceptions.XBeeException
      Package protected method to set the PR (Pull Resistance) parameter of the node.
      Parameters:
      pin - the pin number to change.
      pr - a jmri.Sensor.PullResistance value used to configure the pin.
      Throws:
      com.digi.xbee.api.exceptions.TimeoutException - lock timed out
      com.digi.xbee.api.exceptions.XBeeException - invalid Xbee values, pins
    • getPRValueForPin

      Sensor.PullResistance getPRValueForPin(int pin) throws com.digi.xbee.api.exceptions.TimeoutException, com.digi.xbee.api.exceptions.XBeeException
      Package protected method to check to see if the PR parameter indicates the specified pin has the pull-up resistor enabled.
      Parameters:
      pin - the pin number
      Returns:
      a jmri.Sensor.PullResistance value indicating the current state of the pullup resistor.
      Throws:
      com.digi.xbee.api.exceptions.TimeoutException - lock timeout
      com.digi.xbee.api.exceptions.XBeeException - invalid pins or values