Package jmri.jmrix.ieee802154
Class IEEE802154Node
- java.lang.Object
-
- jmri.jmrix.AbstractNode
-
- jmri.jmrix.ieee802154.IEEE802154Node
-
- Direct Known Subclasses:
SerialNode
,XBeeNode
public abstract class IEEE802154Node extends AbstractNode
Basic implementation of a node for IEEE 802.15.4 networks.Integrated with
IEEE802154TrafficController
.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 Modifier and Type Field Description protected byte[]
globaladdress
(package private) boolean
needSend
protected byte[]
panaddress
protected byte[]
useraddress
-
Fields inherited from class jmri.jmrix.AbstractNode
nodeAddress
-
-
Constructor Summary
Constructors Constructor Description IEEE802154Node()
Creates a new instance of AbstractNodeIEEE802154Node(byte[] pan, byte[] user, byte[] global)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
checkNodeAddress(int address)
Check for valid address with respect to range, etc.abstract AbstractMRMessage
createInitPacket()
Create the needed Initialization packet (AbstractMRMessage) for this node.abstract AbstractMRMessage
createOutPacket()
Create an Transmit packet (AbstractMRMessage) to send current statebyte[]
getGlobalAddress()
Get the Global addressbyte[]
getPANAddress()
Get the PAN addressabstract boolean
getSensorsActive()
Are there sensors present, and hence this node will need to be polled?byte[]
getUserAddress()
Get the User addressabstract boolean
handleTimeout(AbstractMRMessage m, AbstractMRListener l)
Deal with a timeout in the transmission controller.boolean
mustSend()
Return state of needSend flag.void
resetMustSend()
Public to reset state of needSend flag.abstract void
resetTimeout(AbstractMRMessage m)
A reply was received, so there was not timeout, do any needed processing.void
setGlobalAddress(byte[] addr)
Set global address.void
setMustSend()
Public to set state of needSend flag.void
setNodeAddress(int address)
Public method to set the node address.void
setPANAddress(byte[] addr)
Set PAN address.void
setUserAddress(byte[] addr)
Set User address.-
Methods inherited from class jmri.jmrix.AbstractNode
getNodeAddress
-
-
-
-
Field Detail
-
panaddress
protected byte[] panaddress
-
useraddress
protected byte[] useraddress
-
globaladdress
protected byte[] globaladdress
-
needSend
boolean needSend
-
-
Constructor Detail
-
IEEE802154Node
public IEEE802154Node()
Creates a new instance of AbstractNode
-
IEEE802154Node
public IEEE802154Node(byte[] pan, byte[] user, byte[] global)
-
-
Method Detail
-
setNodeAddress
public void setNodeAddress(int address)
Public method to set the node address. Address range is checked in subclasses.- Overrides:
setNodeAddress
in classAbstractNode
- Parameters:
address
- address index to set in node- Throws:
java.lang.IllegalArgumentException
- if out of range
-
checkNodeAddress
protected boolean checkNodeAddress(int address)
Check for valid address with respect to range, etc.- Specified by:
checkNodeAddress
in classAbstractNode
- Parameters:
address
- node number to check.- Returns:
- true if valid
-
setPANAddress
public void setPANAddress(byte[] addr)
Set PAN address.- Parameters:
addr
- byte array containing upper and lower bytes of the 16 bit PAN address.
-
getPANAddress
public byte[] getPANAddress()
Get the PAN address- Returns:
- byte array containing the upper and lower bytes of the PAN address
-
setUserAddress
public void setUserAddress(byte[] addr)
Set User address.- Parameters:
addr
- byte array containing upper and lower bytes of the 16 bit user assigned address.
-
getUserAddress
public byte[] getUserAddress()
Get the User address- Returns:
- byte array containing the upper and lower bytes of the User assigned address
-
setGlobalAddress
public void setGlobalAddress(byte[] addr)
Set global address.- Parameters:
addr
- byte array containing bytes of the 64 bit global address.
-
getGlobalAddress
public byte[] getGlobalAddress()
Get the Global address- Returns:
- byte array containing the 8 bytes of the global address
-
createInitPacket
public abstract AbstractMRMessage createInitPacket()
Create the needed Initialization packet (AbstractMRMessage) for this node. Returns null if not needed.- Specified by:
createInitPacket
in classAbstractNode
- Returns:
- the packet, or 'null' if not needed
-
createOutPacket
public abstract AbstractMRMessage createOutPacket()
Create an Transmit packet (AbstractMRMessage) to send current state- Specified by:
createOutPacket
in classAbstractNode
- Returns:
- packet to send current node state.
-
getSensorsActive
public abstract boolean getSensorsActive()
Are there sensors present, and hence this node will need to be polled? Note: returns 'true' if at least one sensor is active for this node- Specified by:
getSensorsActive
in classAbstractNode
- Returns:
- 'true' if at least one sensor is active for this node
-
handleTimeout
public abstract boolean handleTimeout(AbstractMRMessage m, AbstractMRListener l)
Deal with a timeout in the transmission controller.- Specified by:
handleTimeout
in classAbstractNode
- Parameters:
m
- message that didn't receive a replyl
- listener that sent the message- Returns:
- true if initialization required
-
resetTimeout
public abstract void resetTimeout(AbstractMRMessage m)
A reply was received, so there was not timeout, do any needed processing.- Specified by:
resetTimeout
in classAbstractNode
- Parameters:
m
- message received that has reset the timeout and is waiting to be handled
-
mustSend
public boolean mustSend()
Return state of needSend flag.- Overrides:
mustSend
in classAbstractNode
- Returns:
- state of needSend flag.
-
resetMustSend
public void resetMustSend()
Public to reset state of needSend flag. Subclasses may override to enforce conditions.- Overrides:
resetMustSend
in classAbstractNode
-
setMustSend
public void setMustSend()
Public to set state of needSend flag.- Overrides:
setMustSend
in classAbstractNode
-
-