public class DataReader extends Thread
Depending on the XBee operating mode, read data is notified as is to the subscribed listeners or is parsed to a packet using the packet parser and then notified to subscribed listeners.
Thread.State, Thread.UncaughtExceptionHandlerMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
DataReader(IConnectionInterface connectionInterface,
OperatingMode mode,
XBeeDevice xbeeDevice)
Class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDataReceiveListener(IDataReceiveListener listener)
Adds the given data receive listener to the list of listeners that will
be notified when XBee data packets are received.
|
void |
addExplicitDataReceiveListener(IExplicitDataReceiveListener listener)
Adds the given explicit data receive listener to the list of listeners
that will be notified when an explicit data packet is received.
|
void |
addIOSampleReceiveListener(IIOSampleReceiveListener listener)
Adds the given IO sample receive listener to the list of listeners that
will be notified when an IO sample packet is received.
|
void |
addModemStatusReceiveListener(IModemStatusReceiveListener listener)
Adds the given Modem Status receive listener to the list of listeners
that will be notified when a modem status packet is received.
|
void |
addPacketReceiveListener(IPacketReceiveListener listener)
Adds the given packet receive listener to the list of listeners that will
be notified when any XBee packet is received.
|
void |
addPacketReceiveListener(IPacketReceiveListener listener,
int frameID)
Adds the given packet receive listener to the list of listeners that will
be notified when an XBee packet with the given frame ID is received.
|
RemoteXBeeDevice |
getRemoteXBeeDeviceFromPacket(XBeeAPIPacket packet)
Returns the remote XBee device from where the given package was sent
from.
|
XBeePacketsQueue |
getXBeePacketsQueue()
Returns the queue of read XBee packets.
|
boolean |
isRunning()
Returns whether this Data reader is running or not.
|
void |
removeDataReceiveListener(IDataReceiveListener listener)
Removes the given data receive listener from the list of data receive
listeners.
|
void |
removeExplicitDataReceiveListener(IExplicitDataReceiveListener listener)
Removes the given explicit data receive listener from the list of
explicit data receive listeners.
|
void |
removeIOSampleReceiveListener(IIOSampleReceiveListener listener)
Removes the given IO sample receive listener from the list of IO sample
receive listeners.
|
void |
removeModemStatusReceiveListener(IModemStatusReceiveListener listener)
Removes the given Modem Status receive listener from the list of Modem
Status receive listeners.
|
void |
removePacketReceiveListener(IPacketReceiveListener listener)
Removes the given packet receive listener from the list of XBee packet
receive listeners.
|
void |
run() |
void |
setXBeeReaderMode(OperatingMode mode)
Sets the XBee operating mode of this data reader.
|
void |
stopReader()
Stops the Data reader thread.
|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldpublic DataReader(IConnectionInterface connectionInterface, OperatingMode mode, XBeeDevice xbeeDevice)
DataReader object for the
given connection interface using the given XBee operating mode and XBee
device.connectionInterface - Connection interface to read data from.mode - XBee operating mode.xbeeDevice - Reference to the XBee device containing this
DataReader object.NullPointerException - if connectionInterface == null or
mode == null.IConnectionInterface,
XBeeDevice,
OperatingModepublic void addDataReceiveListener(IDataReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when new XBee data packets are
received.removeDataReceiveListener(IDataReceiveListener),
IDataReceiveListenerpublic void addExplicitDataReceiveListener(IExplicitDataReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when new explicit data packets
are received.removeExplicitDataReceiveListener(IExplicitDataReceiveListener),
IExplicitDataReceiveListenerpublic void addIOSampleReceiveListener(IIOSampleReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when new IO sample packets are
received.removeIOSampleReceiveListener(IIOSampleReceiveListener),
IIOSampleReceiveListenerpublic void addModemStatusReceiveListener(IModemStatusReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when new modem status packets are
received.removeModemStatusReceiveListener(IModemStatusReceiveListener),
IModemStatusReceiveListenerpublic void addPacketReceiveListener(IPacketReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when any XBee packet is received.addPacketReceiveListener(IPacketReceiveListener, int),
removePacketReceiveListener(IPacketReceiveListener),
IPacketReceiveListenerpublic void addPacketReceiveListener(IPacketReceiveListener listener, int frameID)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when an XBee packet with the
provided frame ID is received.frameID - Frame ID for which this listener should be notified and
removed after.
Using ALL_FRAME_IDS this listener will be
notified always and will be removed only by user request.addPacketReceiveListener(IPacketReceiveListener),
removePacketReceiveListener(IPacketReceiveListener),
IPacketReceiveListenerpublic RemoteXBeeDevice getRemoteXBeeDeviceFromPacket(XBeeAPIPacket packet) throws XBeeException
This is for internal use only.
If the package does not contain information about the source, this
method returns null (for example, ModemStatusPacket).
First the device that sent the provided package is looked in the network of the local XBee device. If the remote device is not in the network, it is automatically added only if the packet contains information about the origin of the package.
packet - The packet sent from the remote device.null if the packet is not a known frame (see
APIFrameType) or if it does not contain information of
the source device.NullPointerException - if packet == nullXBeeException - if any error occur while adding the device to the
network.public XBeePacketsQueue getXBeePacketsQueue()
XBeePacketsQueuepublic boolean isRunning()
true if the Data reader is running, false
otherwise.stopReader()public void removeDataReceiveListener(IDataReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - Data receive listener to be remove from the list.addDataReceiveListener(IDataReceiveListener),
IDataReceiveListenerpublic void removeExplicitDataReceiveListener(IExplicitDataReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - Explicit data receive listener to remove from the list.addExplicitDataReceiveListener(IExplicitDataReceiveListener),
IExplicitDataReceiveListenerpublic void removeIOSampleReceiveListener(IIOSampleReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - IO sample receive listener to remove from the list.addIOSampleReceiveListener(IIOSampleReceiveListener),
IIOSampleReceiveListenerpublic void removeModemStatusReceiveListener(IModemStatusReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - Modem Status receive listener to remove from the list.addModemStatusReceiveListener(IModemStatusReceiveListener),
IModemStatusReceiveListenerpublic void removePacketReceiveListener(IPacketReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - Packet receive listener to remove from the list.addPacketReceiveListener(IPacketReceiveListener),
addPacketReceiveListener(IPacketReceiveListener, int),
IPacketReceiveListenerpublic void setXBeeReaderMode(OperatingMode mode)
mode - New XBee operating mode.NullPointerException - if mode == null.OperatingModepublic void stopReader()
isRunning()© Copyright 2014?2015 Digi International Inc. All rights reserved.