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,
AbstractXBeeDevice xbeeDevice)
Class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBluetoothDataReceiveListener(IBluetoothDataReceiveListener listener)
Adds the given data receive listener to the list of listeners that will
be notified when new data from the Bluetooth interface is received in
a User Data Relay frame.
|
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 |
addIPDataReceiveListener(IIPDataReceiveListener listener)
Adds the given IP data receive listener to the list of listeners
that will be notified when a IP data packet is received.
|
void |
addMicroPythonDataReceiveListener(IMicroPythonDataReceiveListener listener)
Adds the given data receive listener to the list of listeners that will
be notified when new data from the MicroPython interface is received in
a User Data Relay frame.
|
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.
|
void |
addSerialDataReceiveListener(ISerialDataReceiveListener listener)
Adds the given data receive listener to the list of listeners that will
be notified when new data from the serial interface is received in
a User Data Relay frame.
|
void |
addSMSReceiveListener(ISMSReceiveListener listener)
Adds the given SMS receive listener to the list of listeners that will
be notified when an SMS packet is received.
|
void |
addUserDataRelayReceiveListener(IUserDataRelayReceiveListener listener)
Adds the given User Data Relay receive listener to the list of listeners
that will be notified when a User Data Relay packet 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 |
removeBluetoothDataReceiveListener(IBluetoothDataReceiveListener listener)
Removes the given data receive listener from the list of data receive
listeners for the Bluetooth interface.
|
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 |
removeIPDataReceiveListener(IIPDataReceiveListener listener)
Removes the given IP data receive listener from the list of
IP data receive listeners.
|
void |
removeMicroPythonDataReceiveListener(IMicroPythonDataReceiveListener listener)
Removes the given data receive listener from the list of data receive
listeners for the MicroPython interface.
|
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 |
removeSerialDataReceiveListener(ISerialDataReceiveListener listener)
Removes the given data receive listener from the list of data receive
listeners for the serial interface.
|
void |
removeSMSReceiveListener(ISMSReceiveListener listener)
Removes the given SMS receive listener from the list of SMS receive
listeners.
|
void |
removeUserDataRelayReceiveListener(IUserDataRelayReceiveListener listener)
Removes the given User Data Relay receive listener from the list of User
Data Relay 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, AbstractXBeeDevice 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.IllegalArgumentException - If xbeeDevice.isRemote() == true.IConnectionInterface,
XBeeDevice,
OperatingModepublic void addBluetoothDataReceiveListener(IBluetoothDataReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when new data from the Bluetooth
interface is received.NullPointerException - if listener == null.removeBluetoothDataReceiveListener(IBluetoothDataReceiveListener),
IBluetoothDataReceiveListenerpublic 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.NullPointerException - if listener == null.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.NullPointerException - if listener == null.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.NullPointerException - if listener == null.removeIOSampleReceiveListener(IIOSampleReceiveListener),
IIOSampleReceiveListenerpublic void addIPDataReceiveListener(IIPDataReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when new IP data packets
are received.NullPointerException - if listener == null.removeIPDataReceiveListener(IIPDataReceiveListener),
IIPDataReceiveListenerpublic void addMicroPythonDataReceiveListener(IMicroPythonDataReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when new data from the
MicroPython interface is received.NullPointerException - if listener == null.removeMicroPythonDataReceiveListener(IMicroPythonDataReceiveListener),
IMicroPythonDataReceiveListenerpublic 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.NullPointerException - if listener == null.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.NullPointerException - if listener == null.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.NullPointerException - if listener == null.addPacketReceiveListener(IPacketReceiveListener),
removePacketReceiveListener(IPacketReceiveListener),
IPacketReceiveListenerpublic void addSerialDataReceiveListener(ISerialDataReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when new data from the serial
interface is received.NullPointerException - if listener == null.removeSerialDataReceiveListener(ISerialDataReceiveListener),
ISerialDataReceiveListenerpublic void addSMSReceiveListener(ISMSReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when new SMS packet is received.NullPointerException - if listener == null.removeSMSReceiveListener(ISMSReceiveListener),
ISMSReceiveListenerpublic void addUserDataRelayReceiveListener(IUserDataRelayReceiveListener listener)
If the listener has been already added, this method does nothing.
listener - Listener to be notified when new User Data Relay packet
is received.NullPointerException - if listener == null.removeUserDataRelayReceiveListener(IUserDataRelayReceiveListener),
IUserDataRelayReceiveListenerpublic 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 removeBluetoothDataReceiveListener(IBluetoothDataReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - Data receive listener to remove from the list.addBluetoothDataReceiveListener(IBluetoothDataReceiveListener),
IBluetoothDataReceiveListenerpublic 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 removeIPDataReceiveListener(IIPDataReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - IP data receive listener to remove from the list.addIPDataReceiveListener(IIPDataReceiveListener),
IIPDataReceiveListenerpublic void removeMicroPythonDataReceiveListener(IMicroPythonDataReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - Data receive listener to remove from the list.addMicroPythonDataReceiveListener(IMicroPythonDataReceiveListener),
IMicroPythonDataReceiveListenerpublic 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 removeSerialDataReceiveListener(ISerialDataReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - Data receive listener to remove from the list.addSerialDataReceiveListener(ISerialDataReceiveListener),
ISerialDataReceiveListenerpublic void removeSMSReceiveListener(ISMSReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - SMS receive listener to remove from the list.addSMSReceiveListener(ISMSReceiveListener),
ISMSReceiveListenerpublic void removeUserDataRelayReceiveListener(IUserDataRelayReceiveListener listener)
If the listener is not included in the list, this method does nothing.
listener - User Data Relay receive listener to remove from the list.addUserDataRelayReceiveListener(IUserDataRelayReceiveListener),
IUserDataRelayReceiveListenerpublic void setXBeeReaderMode(OperatingMode mode)
mode - New XBee operating mode.NullPointerException - if mode == null.OperatingModepublic void stopReader()
isRunning()© Copyright 2014 - 2019 Digi International Inc. All rights reserved.