Package jmri.jmrix.ieee802154.xbee
Class XBeeMessage
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRMessage
-
- jmri.jmrix.ieee802154.IEEE802154Message
-
- jmri.jmrix.ieee802154.xbee.XBeeMessage
-
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
XBeeBroadcastMessage
public class XBeeMessage extends IEEE802154Message
This is a wrapper class for a Digi XBeeAPIPacket.
-
-
Field Summary
-
Fields inherited from class jmri.jmrix.AbstractMRMessage
LONG_TIMEOUT, SHORT_TIMEOUT
-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
XBeeMessage()
Suppress the default ctor, as the length must always be specifiedXBeeMessage(byte[] a, int l)
This ctor interprets the byte array as a sequence of characters to send.XBeeMessage(int l)
XBeeMessage(com.digi.xbee.api.packet.XBeeAPIPacket request)
This ctor interprets the parameter as an XBeeAPIPacket message.XBeeMessage(java.lang.String m, int l)
This ctor interprets the String as the exact sequence to send, byte-for-byte.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkParity()
check whether the message has a valid paritystatic XBeeMessage
getFirmwareVersionRequest()
static XBeeMessage
getForceSampleMessage(java.lang.Object address)
Get an XBee Message requesting an IO sample from the node.static XBeeMessage
getHardwareVersionRequest()
static XBeeMessage
getRemoteDoutMessage(java.lang.Object address, int pin)
Get an XBee Message requesting the status of a digital IO pin.static XBeeMessage
getRemoteDoutMessage(java.lang.Object address, int pin, boolean on)
Get an XBee Message requesting a digital output pin be turned on or off.static XBeeMessage
getRemoteTransmissionRequest(com.digi.xbee.api.models.XBee16BitAddress address, byte[] payload)
Get an XBee Message requesting data be sent to the serial port on a remote node.static XBeeMessage
getRemoteTransmissionRequest(com.digi.xbee.api.models.XBee64BitAddress address, byte[] payload)
Get an XBee Message requesting data be sent to the serial port on a remote node.static XBeeMessage
getRemoteTransmissionRequest(java.lang.Object address, byte[] payload)
Get an XBee Message requesting data be sent to the serial port on a remote node.com.digi.xbee.api.packet.XBeeAPIPacket
getXBeeRequest()
boolean
replyExpected()
Is a reply expected to this message?void
setParity()
void
setXBeeRequest(com.digi.xbee.api.packet.XBeeAPIPacket request)
java.lang.String
toMonitorString()
java.lang.String
toString()
-
Methods inherited from class jmri.jmrix.ieee802154.IEEE802154Message
getResponseLength, setResponseLength
-
Methods inherited from class jmri.jmrix.AbstractMRMessage
addIntAsFourHex, addIntAsThree, addIntAsThreeHex, addIntAsTwoHex, getNeededMode, getOpCode, getOpCodeHex, getRetries, getTimeout, isBinary, setBinary, setNeededMode, setOpCode, setRetries, setTimeout
-
Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode, setElement
-
-
-
-
Constructor Detail
-
XBeeMessage
protected XBeeMessage()
Suppress the default ctor, as the length must always be specified
-
XBeeMessage
public XBeeMessage(int l)
-
XBeeMessage
public XBeeMessage(java.lang.String m, int l)
This ctor interprets the String as the exact sequence to send, byte-for-byte.- Parameters:
m
- messagel
- length
-
XBeeMessage
public XBeeMessage(byte[] a, int l)
This ctor interprets the byte array as a sequence of characters to send.- Parameters:
a
- Array of bytes to sendl
- length
-
XBeeMessage
public XBeeMessage(com.digi.xbee.api.packet.XBeeAPIPacket request)
This ctor interprets the parameter as an XBeeAPIPacket message. This is the message form that will generally be used by the implementation.- Parameters:
request
- an XBeeAPIPacket of bytes to send
-
-
Method Detail
-
replyExpected
public boolean replyExpected()
Description copied from class:AbstractMRMessage
Is a reply expected to this message?By default, a reply is expected to every message; either a reply or a timeout is needed before the next message can be sent.
If this returns false, the transmit queue will immediately go on to transmit the next message (if any).
- Overrides:
replyExpected
in classAbstractMRMessage
- Returns:
- true by default in Abstract MR message.
-
getXBeeRequest
public com.digi.xbee.api.packet.XBeeAPIPacket getXBeeRequest()
-
setXBeeRequest
public void setXBeeRequest(com.digi.xbee.api.packet.XBeeAPIPacket request)
-
toMonitorString
public java.lang.String toMonitorString()
- Returns:
- a human-readable representation of the message.
-
toString
public java.lang.String toString()
Description copied from interface:Message
- Specified by:
toString
in interfaceMessage
- Overrides:
toString
in classAbstractMRMessage
-
checkParity
public boolean checkParity()
check whether the message has a valid parity- Overrides:
checkParity
in classIEEE802154Message
- Returns:
- true if parity is valid
-
setParity
public void setParity()
- Overrides:
setParity
in classIEEE802154Message
-
getHardwareVersionRequest
public static XBeeMessage getHardwareVersionRequest()
-
getFirmwareVersionRequest
public static XBeeMessage getFirmwareVersionRequest()
-
getRemoteDoutMessage
public static XBeeMessage getRemoteDoutMessage(java.lang.Object address, int pin, boolean on)
Get an XBee Message requesting a digital output pin be turned on or off.- Parameters:
address
- XBee Address of the node. This can be either 16 bit or 64 bit.pin
- the DIO Pin on the XBee to use.on
- boolean value stating whether the pin should be turned on (true) or off (false)- Returns:
- XBeeMessage with a message requesting a digital IO pin be turned on or off.
-
getRemoteDoutMessage
public static XBeeMessage getRemoteDoutMessage(java.lang.Object address, int pin)
Get an XBee Message requesting the status of a digital IO pin.- Parameters:
address
- XBee Address of the node. This can be either 16 bit or 64 bit.pin
- the DIO Pin on the XBee to use.- Returns:
- XBeeMessage with a digital IO pin status request.
-
getForceSampleMessage
public static XBeeMessage getForceSampleMessage(java.lang.Object address)
Get an XBee Message requesting an IO sample from the node.- Parameters:
address
- XBee Address of the node. This can be either- Returns:
- XBeeMessage with a force IO sample request. 16 bit or 64 bit.
-
getRemoteTransmissionRequest
public static XBeeMessage getRemoteTransmissionRequest(java.lang.Object address, byte[] payload)
Get an XBee Message requesting data be sent to the serial port on a remote node.- Parameters:
address
- XBee Address of the node. This can be either 16 bit or 64 bit.payload
- An byte array containing the bytes to be transfered, as the low order word of the integer.- Returns:
- XBeeMessage with remote transmission request for the provided address containing the provided payload.
-
getRemoteTransmissionRequest
public static XBeeMessage getRemoteTransmissionRequest(com.digi.xbee.api.models.XBee16BitAddress address, byte[] payload)
Get an XBee Message requesting data be sent to the serial port on a remote node.- Parameters:
address
- XBee16BitAddress of the node.payload
- A byte array containing the bytes to be transfered, as the low order word of the integer.- Returns:
- XBeeMessage with remote transmission request for the provided address containing the provided payload.
-
getRemoteTransmissionRequest
public static XBeeMessage getRemoteTransmissionRequest(com.digi.xbee.api.models.XBee64BitAddress address, byte[] payload)
Get an XBee Message requesting data be sent to the serial port on a remote node.- Parameters:
address
- XBee64BitAddress of the node.payload
- A byte array containing the bytes to be transfered, as the low order word of the integer.- Returns:
- XBeeMessage with remote transmission request for the provided address containing the provided payload.
-
-