Package jmri.jmrix.ieee802154.xbee
Class XBeeNode
- java.lang.Object
-
- jmri.jmrix.AbstractNode
-
- jmri.jmrix.ieee802154.IEEE802154Node
-
- jmri.jmrix.ieee802154.xbee.XBeeNode
-
public class XBeeNode extends IEEE802154Node
Implementation of a Node for XBee networks.Integrated with
XBeeTrafficController
.Each node has 3 addresses associated with it:
- A 16 bit PAN (Personal Area Network) ID assigned by the user
- A 16 bit User Assigned Address
- A 64 bit Globally Unique ID assigned by the manufacturer
All nodes in a given network must have the same PAN ID
-
-
Field Summary
-
Fields inherited from class jmri.jmrix.ieee802154.IEEE802154Node
globaladdress, panaddress, useraddress
-
Fields inherited from class jmri.jmrix.AbstractNode
nodeAddress
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
connectPortController(AbstractStreamConnectionConfig cfg)
Connect and configure a StreamConnectionConfig object to the XBeeIOStream associated with this node.void
connectPortController(AbstractStreamPortController cont)
Connect and configure a StreamPortController object to the XBeeIOStream associated with this node.AbstractMRMessage
createInitPacket()
Create the needed Initialization packet (AbstractMRMessage) for this node.AbstractMRMessage
createOutPacket()
Create an Transmit packet (AbstractMRMessage) to send current state.AbstractStreamConnectionConfig
getConnectionConfig()
Get the StreamConnectionConfig ojbect associated with the XBeeIOStream associated with this node.java.lang.String
getIdentifier()
XBeeIOStream
getIOStream()
Get the stream object associated with this node.boolean
getPinAssigned(int pin)
Ask if a specified pin is assigned to a bean.NamedBean
getPinBean(int pin)
Get the bean associated with the specified pin.boolean
getPoll()
Get the isPolled attribute.AbstractStreamPortController
getPortController()
Get the StreamPortController ojbect associated with the XBeeIOStream associated with this node.java.lang.String
getPreferedName()
Get the prefered name for this XBee Node.java.lang.Object
getPreferedTransmitAddress()
Get the prefered transmit address for this XBee Node.(package private) Sensor.PullResistance
getPRValueForPin(int pin)
Package protected method to check to see if the PR parameter indicates the specified pin has the pull-up resistor enabled.boolean
getSensorsActive()
Are sensors present, and hence will this node need to be polled?com.digi.xbee.api.RemoteXBeeDevice
getXBee()
com.digi.xbee.api.models.XBee16BitAddress
getXBeeAddress16()
Convert the 16 bit user address to an XBee16BitAddress object.com.digi.xbee.api.models.XBee64BitAddress
getXBeeAddress64()
Convert the 64 bit address to an XBee64BitAddress object.boolean
handleTimeout(AbstractMRMessage m, AbstractMRListener l)
Deal with a timeout in the transmission controller.boolean
removePinBean(int pin, NamedBean bean)
Remove the bean associated with the specified pin.void
resetTimeout(AbstractMRMessage m)
A reply was received, so there was not timeout; do any needed processing.void
setIdentifier(java.lang.String id)
XBee Nodes store an identifier. we want to be able to store and retrieve this information.boolean
setPinBean(int pin, NamedBean bean)
Set the bean associated with the specified pin.void
setPoll(boolean poll)
Set the isPolled attribute.void
setPortController(AbstractStreamConnectionConfig cfg)
Connect a StreamConnectionConfig object to the XBeeIOStream associated with this node.void
setPortController(AbstractStreamPortController cont)
Connect a StreamPortController object to the XBeeIOStream associated with this node.(package private) void
setPRParameter(int pin, Sensor.PullResistance pr)
Package protected method to set the PR (Pull Resistance) parameter of the node.void
setTrafficController(XBeeTrafficController controller)
Set the Traffic Controller associated with this node.void
setXBee(com.digi.xbee.api.RemoteXBeeDevice rxd)
Set the RemoteXBeeDevice associated with this node and configure address information.java.lang.String
toString()
Provide a string representation of this XBee Node.-
Methods inherited from class jmri.jmrix.ieee802154.IEEE802154Node
checkNodeAddress, getGlobalAddress, getPANAddress, getUserAddress, mustSend, resetMustSend, setGlobalAddress, setMustSend, setNodeAddress, setPANAddress, setUserAddress
-
Methods inherited from class jmri.jmrix.AbstractNode
getNodeAddress
-
-
-
-
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.
-
createInitPacket
public AbstractMRMessage createInitPacket()
Create the needed Initialization packet (AbstractMRMessage) for this node.- Specified by:
createInitPacket
in classIEEE802154Node
- Returns:
- null because not needed for XBeeNode
-
createOutPacket
public AbstractMRMessage createOutPacket()
Create an Transmit packet (AbstractMRMessage) to send current state.- Specified by:
createOutPacket
in classIEEE802154Node
- 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 classIEEE802154Node
- 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
public boolean handleTimeout(AbstractMRMessage m, AbstractMRListener l)
Deal with a timeout in the transmission controller.- Specified by:
handleTimeout
in classIEEE802154Node
- Parameters:
m
- message that didn't receive a replyl
- listener that sent the message- Returns:
- true if initialization required
-
resetTimeout
public void resetTimeout(AbstractMRMessage m)
A reply was received, so there was not timeout; do any needed processing. Implementation does nothing.- Specified by:
resetTimeout
in classIEEE802154Node
- 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(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
-
getIdentifier
public java.lang.String 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
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
-
getPortController
public AbstractStreamPortController getPortController()
Get the StreamPortController ojbect associated with the XBeeIOStream associated with this node.- Returns:
- connected
AbstractStreamPortController
-
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
-
getConnectionConfig
public AbstractStreamConnectionConfig getConnectionConfig()
Get the StreamConnectionConfig ojbect associated with the XBeeIOStream associated with this node.- Returns:
- connected
AbstractStreamConnectionConfig
-
toString
public java.lang.String toString()
Provide a string representation of this XBee Node.- Overrides:
toString
in classjava.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 outcom.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 timeoutcom.digi.xbee.api.exceptions.XBeeException
- invalid pins or values
-
-