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 Detail

      • 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 Detail

      • setTrafficController

        public void setTrafficController​(XBeeTrafficController controller)
        Set the Traffic Controller associated with this node.
        Parameters:
        controller - system connection traffic controller.
      • 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.
      • 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​(java.lang.String id)
        XBee Nodes store an identifier. we want to be able to store and retrieve this information.
        Parameters:
        id - text id for node
      • 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

        public java.lang.String 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

        public java.lang.Object 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

        public XBeeIOStream getIOStream()
        Get the stream object associated with this node.
        Returns:
        stream object, created if does not exist.
      • connectPortController

        public void connectPortController​(AbstractStreamPortController cont)
        Connect and configure a StreamPortController object to the XBeeIOStream associated with this node.
        Parameters:
        cont - AbstractSTreamPortController object to connect
      • setPortController

        public void setPortController​(AbstractStreamPortController cont)
        Connect a StreamPortController object to the XBeeIOStream associated with this node.
        Parameters:
        cont - AbstractSTreamPortController object to connect
      • connectPortController

        public void connectPortController​(AbstractStreamConnectionConfig cfg)
        Connect and configure a StreamConnectionConfig object to the XBeeIOStream associated with this node.
        Parameters:
        cfg - AbstractStreamConnectionConfig object to connect
      • setPortController

        public void setPortController​(AbstractStreamConnectionConfig cfg)
        Connect a StreamConnectionConfig object to the XBeeIOStream associated with this node.
        Parameters:
        cfg - AbstractStreamConnectionConfig object to connect
      • toString

        public java.lang.String toString()
        Provide a string representation of this XBee Node.
        Overrides:
        toString in class java.lang.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