public class XBeeDevice extends AbstractXBeeDevice
| Constructor and Description |
|---|
XBeeDevice(IConnectionInterface connectionInterface)
Class constructor.
|
XBeeDevice(String port,
int baudRate)
Class constructor.
|
XBeeDevice(String port,
int baudRate,
int dataBits,
int stopBits,
int parity,
int flowControl)
Class constructor.
|
XBeeDevice(String port,
SerialPortParameters serialPortParameters)
Class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBluetoothDataListener(IBluetoothDataReceiveListener listener)
Adds the provided listener to the list of listeners to be notified
when new data from the Bluetooth interface is received in a User Data
Relay frame.
|
void |
addDataListener(IDataReceiveListener listener)
Adds the provided listener to the list of listeners to be notified
when new data from a remote XBee device is received.
|
void |
addIOSampleListener(IIOSampleReceiveListener listener)
Adds the provided listener to the list of listeners to be notified
when new IO samples are received.
|
void |
addMicroPythonDataListener(IMicroPythonDataReceiveListener listener)
Adds the provided listener to the list of listeners to be notified
when new data from the MicroPython interface is received in a User
Data Relay frame.
|
void |
addModemStatusListener(IModemStatusReceiveListener listener)
Adds the provided listener to the list of listeners to be notified
when new Modem Status events are received.
|
void |
addPacketListener(IPacketReceiveListener listener)
Adds the provided listener to the list of listeners to be notified
when new packets are received.
|
void |
addUserDataRelayListener(IUserDataRelayReceiveListener listener)
Adds the provided listener to the list of listeners to be notified
when new User Data Relay message is received.
|
void |
close()
Closes the connection interface associated with this XBee device.
|
XBeeNetwork |
getNetwork()
Returns the network associated with this XBee device.
|
int |
getNextFrameID()
Returns the next Frame ID of this XBee device.
|
OperatingMode |
getOperatingMode()
Returns the Operating mode (AT, API or API escaped) of this XBee device
for a local device, and the operating mode of the local device used as
communication interface for a remote device.
|
int |
getReceiveTimeout()
Returns this XBee device configured timeout for receiving packets in
synchronous operations.
|
boolean |
isOpen()
Returns whether the connection interface associated to this device is
already open.
|
boolean |
isRemote()
Returns whether this XBee device is a remote device.
|
void |
open()
Opens the connection interface associated with this XBee device.
|
XBeeMessage |
readData()
Reads new data received by this XBee device during the configured
receive timeout.
|
XBeeMessage |
readData(int timeout)
Reads new data received by this XBee device during the provided timeout.
|
XBeeMessage |
readDataFrom(RemoteXBeeDevice remoteXBeeDevice)
Reads new data received from the given remote XBee device during the
configured receive timeout.
|
XBeeMessage |
readDataFrom(RemoteXBeeDevice remoteXBeeDevice,
int timeout)
Reads new data received from the given remote XBee device during the
provided timeout.
|
void |
removeBluetoothDataListener(IBluetoothDataReceiveListener listener)
Removes the provided listener from the list of data receive listeners
for the Bluetooth interface.
|
void |
removeDataListener(IDataReceiveListener listener)
Removes the provided listener from the list of data listeners for remote
XBee devices.
|
void |
removeIOSampleListener(IIOSampleReceiveListener listener)
Removes the provided listener from the list of IO samples listeners.
|
void |
removeMicroPythonDataListener(IMicroPythonDataReceiveListener listener)
Removes the provided listener from the list of data receive listeners
for the MicroPython interface.
|
void |
removeModemStatusListener(IModemStatusReceiveListener listener)
Removes the provided listener from the list of Modem Status listeners.
|
void |
removePacketListener(IPacketReceiveListener listener)
Removes the provided listener from the list of packets listeners.
|
void |
removeUserDataRelayListener(IUserDataRelayReceiveListener listener)
Removes the provided listener from the list of User Data Relay listeners.
|
void |
reset()
Performs a software reset on this XBee device and blocks until the
process is completed.
|
void |
sendBluetoothData(byte[] data)
Sends the given data to the XBee Bluetooth interface in a User Data Relay
frame.
|
void |
sendBroadcastData(byte[] data)
Sends the provided data to all the XBee nodes of the network (broadcast).
|
void |
sendData(RemoteXBeeDevice remoteXBeeDevice,
byte[] data)
Sends the provided data to the given XBee device choosing the optimal
send method depending on the protocol of the local XBee device.
|
void |
sendDataAsync(RemoteXBeeDevice remoteXBeeDevice,
byte[] data)
Sends the provided data to the provided XBee device asynchronously
choosing the optimal send method depending on the protocol of the local
XBee device.
|
void |
sendMicroPythonData(byte[] data)
Sends the given data to the XBee MicroPython interface in a User Data
Relay frame.
|
XBeePacket |
sendPacket(XBeePacket packet)
Sends the given XBee packet synchronously and blocks until the response
is received or the configured receive timeout expires.
|
void |
sendPacket(XBeePacket packet,
IPacketReceiveListener packetReceiveListener)
Sends the given XBee packet and registers the given packet listener
(if not
null) to be notified when the answers is received. |
void |
sendPacketAsync(XBeePacket packet)
Sends the given XBee packet asynchronously.
|
void |
sendUserDataRelay(XBeeLocalInterface destInterface,
byte[] data)
Sends the given data to the given XBee local interface.
|
void |
setReceiveTimeout(int receiveTimeout)
Configures this XBee device timeout in milliseconds for receiving
packets in synchronous operations.
|
String |
toString() |
applyChanges, disableBluetooth, enableApplyConfigurationChanges, enableBluetooth, executeParameter, get16BitAddress, get64BitAddress, getADCValue, getBluetoothMacAddress, getConnectionInterface, getDestinationAddress, getDIOChangeDetection, getDIOValue, getFirmwareVersion, getHardwareVersion, getIOConfiguration, getIOSamplingRate, getIPv6Address, getIPv6DestinationAddress, getNodeID, getPANID, getParameter, getPowerLevel, getPWMDutyCycle, getXBeeProtocol, isApplyConfigurationChangesEnabled, readDeviceInfo, readIOSample, setDestinationAddress, setDIOChangeDetection, setDIOValue, setIOConfiguration, setIOSamplingRate, setIPv6DestinationAddress, setNodeID, setPANID, setParameter, setPowerLevel, setPWMDutyCycle, updateBluetoothPassword, updateDeviceDataFrom, writeChangespublic XBeeDevice(IConnectionInterface connectionInterface)
XBeeDevice object with the
given connection interface.connectionInterface - The connection interface with the physical
XBee device.NullPointerException - if connectionInterface == null.XBeeDevice(String, int),
XBeeDevice(String, SerialPortParameters),
XBeeDevice(String, int, int, int, int, int),
IConnectionInterfacepublic XBeeDevice(String port, int baudRate)
XBeeDevice object
physically connected to the given port name and configured at the
provided baud rate.port - Serial port name where XBee device is attached to.baudRate - Serial port baud rate to communicate with the device.
Other connection parameters will be set as default (8
data bits, 1 stop bit, no parity, no flow control).IllegalArgumentException - if baudRate < 0.NullPointerException - if port == null.XBeeDevice(IConnectionInterface),
XBeeDevice(String, SerialPortParameters),
XBeeDevice(String, int, int, int, int, int)public XBeeDevice(String port, int baudRate, int dataBits, int stopBits, int parity, int flowControl)
XBeeDevice object
physically connected to the given port name and configured to communicate
with the provided serial settings.port - Serial port name where XBee device is attached to.baudRate - Serial port baud rate to communicate with the device.dataBits - Serial port data bits.stopBits - Serial port data bits.parity - Serial port data bits.flowControl - Serial port data bits.IllegalArgumentException - if baudRate < 0 or
if dataBits < 0 or
if stopBits < 0 or
if parity < 0 or
if flowControl < 0.NullPointerException - if port == null.XBeeDevice(IConnectionInterface),
XBeeDevice(String, int),
XBeeDevice(String, SerialPortParameters)public XBeeDevice(String port, SerialPortParameters serialPortParameters)
XBeeDevice object
physically connected to the given port name and configured to communicate
with the provided serial settings.port - Serial port name where XBee device is attached to.serialPortParameters - Object containing the serial port parameters.NullPointerException - if port == null or
if serialPortParameters == null.XBeeDevice(IConnectionInterface),
XBeeDevice(String, int),
XBeeDevice(String, int, int, int, int, int),
SerialPortParameterspublic void addBluetoothDataListener(IBluetoothDataReceiveListener listener)
AbstractXBeeDeviceIf the listener has been already included this method does nothing.
listener - Listener to be notified when new data from the Bluetooth
interface is received.AbstractXBeeDevice.removeBluetoothDataListener(IBluetoothDataReceiveListener),
IBluetoothDataReceiveListenerpublic void addDataListener(IDataReceiveListener listener)
AbstractXBeeDeviceIf the listener has been already included this method does nothing.
listener - Listener to be notified when new data from a remote XBee
device is received.AbstractXBeeDevice.removeDataListener(IDataReceiveListener),
IDataReceiveListenerpublic void addIOSampleListener(IIOSampleReceiveListener listener)
AbstractXBeeDeviceIf the listener has been already included this method does nothing.
listener - Listener to be notified when new IO samples are received.AbstractXBeeDevice.removeIOSampleListener(IIOSampleReceiveListener),
IIOSampleReceiveListenerpublic void addMicroPythonDataListener(IMicroPythonDataReceiveListener listener)
AbstractXBeeDeviceIf the listener has been already included this method does nothing.
listener - Listener to be notified when new data from the
MicroPython interface is received.AbstractXBeeDevice.removeMicroPythonDataListener(IMicroPythonDataReceiveListener),
IMicroPythonDataReceiveListenerpublic void addModemStatusListener(IModemStatusReceiveListener listener)
AbstractXBeeDeviceIf the listener has been already included this method does nothing.
listener - Listener to be notified when new Modem Status events are
received.AbstractXBeeDevice.removeModemStatusListener(IModemStatusReceiveListener),
IModemStatusReceiveListenerpublic void addPacketListener(IPacketReceiveListener listener)
AbstractXBeeDeviceIf the listener has been already included, this method does nothing.
listener - Listener to be notified when new packets are received.AbstractXBeeDevice.removePacketListener(IPacketReceiveListener),
IPacketReceiveListenerpublic void addUserDataRelayListener(IUserDataRelayReceiveListener listener)
AbstractXBeeDeviceIf the listener has been already included this method does nothing.
listener - Listener to be notified when new User Data Relay message
is received.AbstractXBeeDevice.removeUserDataRelayListener(IUserDataRelayReceiveListener),
IUserDataRelayReceiveListenerpublic void close()
AbstractXBeeDevicepublic XBeeNetwork getNetwork()
AbstractXBeeDeviceXBeeNetworkpublic int getNextFrameID()
AbstractXBeeDevicepublic OperatingMode getOperatingMode()
AbstractXBeeDeviceAbstractXBeeDevice.isRemote(),
OperatingModepublic int getReceiveTimeout()
AbstractXBeeDeviceAbstractXBeeDevice.setReceiveTimeout(int)public boolean isOpen()
AbstractXBeeDevicetrue if the interface is open, false otherwise.AbstractXBeeDevice.close(),
AbstractXBeeDevice.open()public boolean isRemote()
AbstractXBeeDeviceisRemote in class AbstractXBeeDevicetrue if this XBee device is a remote device,
false otherwise.public void open() throws XBeeException
AbstractXBeeDeviceWhen opening the device an information reading process is automatically performed. This includes:
BluetoothAuthenticationException - if there is any problem in the
Bluetooth authentication.XBeeException - if there is any problem opening this device
connection.AbstractXBeeDevice.close(),
AbstractXBeeDevice.isOpen()public XBeeMessage readData()
AbstractXBeeDeviceThis method blocks until new data is received or the configured receive timeout expires.
The receive timeout is configured using the setReceiveTimeout
method and can be consulted with getReceiveTimeout method.
For non-blocking operations, register a IDataReceiveListener
using the method AbstractXBeeDevice.addDataListener(IDataReceiveListener).
XBeeMessage object containing the data and the source
address of the remote node that sent the data. null if
this did not receive new data during the configured receive
timeout.AbstractXBeeDevice.readData(int),
AbstractXBeeDevice.getReceiveTimeout(),
AbstractXBeeDevice.setReceiveTimeout(int),
AbstractXBeeDevice.readDataFrom(RemoteXBeeDevice),
AbstractXBeeDevice.readDataFrom(RemoteXBeeDevice, int),
XBeeMessagepublic XBeeMessage readData(int timeout)
AbstractXBeeDeviceThis method blocks until new data is received or the provided timeout expires.
For non-blocking operations, register a IDataReceiveListener
using the method AbstractXBeeDevice.addDataListener(IDataReceiveListener).
timeout - The time to wait for new data in milliseconds.XBeeMessage object containing the data and the source
address of the remote node that sent the data. null if
this device did not receive new data during timeout
milliseconds.AbstractXBeeDevice.readData(),
AbstractXBeeDevice.readDataFrom(RemoteXBeeDevice),
AbstractXBeeDevice.readDataFrom(RemoteXBeeDevice, int),
XBeeMessagepublic XBeeMessage readDataFrom(RemoteXBeeDevice remoteXBeeDevice)
AbstractXBeeDeviceThis method blocks until new data from the provided remote XBee device is received or the configured receive timeout expires.
The receive timeout is configured using the setReceiveTimeout
method and can be consulted with getReceiveTimeout method.
For non-blocking operations, register a IDataReceiveListener
using the method AbstractXBeeDevice.addDataListener(IDataReceiveListener).
remoteXBeeDevice - The remote device to read data from.XBeeMessage object containing the data and the source
address of the remote node that sent the data. null if
this device did not receive new data from the provided remote
XBee device during the configured receive timeout.AbstractXBeeDevice.readDataFrom(RemoteXBeeDevice, int),
AbstractXBeeDevice.getReceiveTimeout(),
AbstractXBeeDevice.setReceiveTimeout(int),
AbstractXBeeDevice.readData(),
AbstractXBeeDevice.readData(int),
RemoteXBeeDevice,
XBeeMessagepublic XBeeMessage readDataFrom(RemoteXBeeDevice remoteXBeeDevice, int timeout)
AbstractXBeeDeviceThis method blocks until new data from the provided remote XBee device is received or the given timeout expires.
For non-blocking operations, register a IDataReceiveListener
using the method AbstractXBeeDevice.addDataListener(IDataReceiveListener).
remoteXBeeDevice - The remote device to read data from.timeout - The time to wait for new data in milliseconds.XBeeMessage object containing the data and the source
address of the remote node that sent the data. null if
this device did not receive new data from the provided remote
XBee device during timeout milliseconds.AbstractXBeeDevice.readDataFrom(RemoteXBeeDevice),
AbstractXBeeDevice.getReceiveTimeout(),
AbstractXBeeDevice.setReceiveTimeout(int),
AbstractXBeeDevice.readData(),
AbstractXBeeDevice.readData(int),
RemoteXBeeDevice,
XBeeMessagepublic void removeBluetoothDataListener(IBluetoothDataReceiveListener listener)
AbstractXBeeDeviceIf the listener was not in the list this method does nothing.
listener - Listener to be removed from the list of listeners.AbstractXBeeDevice.addBluetoothDataListener(IBluetoothDataReceiveListener),
IBluetoothDataReceiveListenerpublic void removeDataListener(IDataReceiveListener listener)
AbstractXBeeDeviceIf the listener was not in the list this method does nothing.
listener - Listener to be removed from the list of listeners.AbstractXBeeDevice.addDataListener(IDataReceiveListener),
IDataReceiveListenerpublic void removeIOSampleListener(IIOSampleReceiveListener listener)
AbstractXBeeDeviceIf the listener was not in the list this method does nothing.
listener - Listener to be removed from the list of listeners.AbstractXBeeDevice.addIOSampleListener(IIOSampleReceiveListener),
IIOSampleReceiveListenerpublic void removeMicroPythonDataListener(IMicroPythonDataReceiveListener listener)
AbstractXBeeDeviceIf the listener was not in the list this method does nothing.
listener - Listener to be removed from the list of listeners.AbstractXBeeDevice.addMicroPythonDataListener(IMicroPythonDataReceiveListener),
IMicroPythonDataReceiveListenerpublic void removeModemStatusListener(IModemStatusReceiveListener listener)
AbstractXBeeDeviceIf the listener was not in the list this method does nothing.
listener - Listener to be removed from the list of listeners.AbstractXBeeDevice.addModemStatusListener(IModemStatusReceiveListener),
IModemStatusReceiveListenerpublic void removePacketListener(IPacketReceiveListener listener)
AbstractXBeeDeviceIf the listener was not in the list this method does nothing.
listener - Listener to be removed from the list of listeners.AbstractXBeeDevice.addPacketListener(IPacketReceiveListener),
IPacketReceiveListenerpublic void removeUserDataRelayListener(IUserDataRelayReceiveListener listener)
AbstractXBeeDeviceIf the listener was not in the list this method does nothing.
listener - Listener to be removed from the list of listeners.AbstractXBeeDevice.addUserDataRelayListener(IUserDataRelayReceiveListener),
IUserDataRelayReceiveListenerpublic void reset() throws TimeoutException, XBeeException
AbstractXBeeDevicereset in class AbstractXBeeDeviceTimeoutException - if the configured time expires while waiting
for the command reply.XBeeException - if there is any other XBee related exception.public void sendBluetoothData(byte[] data) throws XBeeException
AbstractXBeeDevicedata - Data to send.XBeeException - if there is any XBee related exception sending the
data.AbstractXBeeDevice.sendMicroPythonData(byte[]),
AbstractXBeeDevice.sendUserDataRelay(XBeeLocalInterface, byte[])public void sendBroadcastData(byte[] data) throws TimeoutException, XBeeException
AbstractXBeeDeviceThis method blocks till a success or error transmit status arrives or the configured receive timeout expires.
The receive timeout is configured using the setReceiveTimeout
method and can be consulted with getReceiveTimeout method.
data - Byte array containing the data to be sent.TimeoutException - if there is a timeout sending the data.XBeeException - if there is any other XBee related exception.AbstractXBeeDevice.getReceiveTimeout(),
AbstractXBeeDevice.setReceiveTimeout(int)public void sendData(RemoteXBeeDevice remoteXBeeDevice, byte[] data) throws TimeoutException, XBeeException
AbstractXBeeDeviceThis method blocks till a success or error response arrives or the configured receive timeout expires.
The receive timeout is configured using the setReceiveTimeout
method and can be consulted with getReceiveTimeout method.
For non-blocking operations use the method
AbstractXBeeDevice.sendDataAsync(RemoteXBeeDevice, byte[]).
remoteXBeeDevice - The XBee device of the network that will receive
the data.data - Byte array containing the data to be sent.TimeoutException - if there is a timeout sending the data.XBeeException - if there is any other XBee related exception.AbstractXBeeDevice.getReceiveTimeout(),
AbstractXBeeDevice.setReceiveTimeout(int),
AbstractXBeeDevice.sendData(XBee64BitAddress, byte[]),
AbstractXBeeDevice.sendData(XBee64BitAddress, XBee16BitAddress, byte[]),
AbstractXBeeDevice.sendDataAsync(RemoteXBeeDevice, byte[]),
AbstractXBeeDevice.sendDataAsync(XBee64BitAddress, byte[]),
AbstractXBeeDevice.sendDataAsync(XBee64BitAddress, XBee16BitAddress, byte[]),
RemoteXBeeDevicepublic void sendDataAsync(RemoteXBeeDevice remoteXBeeDevice, byte[] data) throws XBeeException
AbstractXBeeDeviceAsynchronous transmissions do not wait for answer from the remote device or for transmit status packet.
remoteXBeeDevice - The XBee device of the network that will receive the
data.data - Byte array containing the data to be sent.XBeeException - if there is any XBee related exception.AbstractXBeeDevice.sendData(RemoteXBeeDevice, byte[]),
AbstractXBeeDevice.sendData(XBee64BitAddress, byte[]),
AbstractXBeeDevice.sendData(XBee64BitAddress, XBee16BitAddress, byte[]),
AbstractXBeeDevice.sendDataAsync(XBee64BitAddress, byte[]),
AbstractXBeeDevice.sendDataAsync(XBee64BitAddress, XBee16BitAddress, byte[]),
RemoteXBeeDevicepublic void sendMicroPythonData(byte[] data) throws XBeeException
AbstractXBeeDevicedata - Data to send.XBeeException - if there is any XBee related exception sending the
data.AbstractXBeeDevice.sendBluetoothData(byte[]),
AbstractXBeeDevice.sendUserDataRelay(XBeeLocalInterface, byte[])public XBeePacket sendPacket(XBeePacket packet) throws TimeoutException, XBeeException
AbstractXBeeDeviceThe receive timeout is configured using the setReceiveTimeout
method and can be consulted with getReceiveTimeout method.
Use sendXBeePacketAsync(XBeePacket) or
#sendXBeePacket(XBeePacket, IPacketReceiveListener) for
non-blocking operations.
packet - XBee packet to be sent.XBeePacket object containing the response of the sent
packet or null if there is no response.TimeoutException - if there is a timeout sending the XBee packet.XBeeException - if there is any other XBee related exception.AbstractXBeeDevice.getReceiveTimeout(),
AbstractXBeeDevice.sendXBeePacket(XBeePacket, IPacketReceiveListener),
AbstractXBeeDevice.sendXBeePacketAsync(XBeePacket),
AbstractXBeeDevice.setReceiveTimeout(int),
XBeePacketpublic void sendPacket(XBeePacket packet, IPacketReceiveListener packetReceiveListener) throws XBeeException
AbstractXBeeDevicenull) to be notified when the answers is received.
This is a non-blocking operation. To wait for the answer use
sendPacket(XBeePacket).
packet - XBee packet to be sent.packetReceiveListener - Listener for the operation, null
not to be notified when the answer arrives.XBeeException - if there is any other XBee related exception.AbstractXBeeDevice.sendPacket(XBeePacket),
AbstractXBeeDevice.sendPacketAsync(XBeePacket),
IPacketReceiveListener,
XBeePacketpublic void sendPacketAsync(XBeePacket packet) throws XBeeException
AbstractXBeeDeviceThis is a non-blocking operation that do not wait for the answer and is never notified when it arrives.
To be notified when the answer is received, use
AbstractXBeeDevice.sendXBeePacket(XBeePacket, IPacketReceiveListener).
packet - XBee packet to be sent asynchronously.XBeeException - if there is any other XBee related exception.AbstractXBeeDevice.sendXBeePacket(XBeePacket),
AbstractXBeeDevice.sendXBeePacket(XBeePacket, IPacketReceiveListener),
XBeePacketpublic void sendUserDataRelay(XBeeLocalInterface destInterface, byte[] data) throws XBeeException
AbstractXBeeDevicedestInterface - Destination XBee local interface.data - Data to send.XBeeException - if there is any XBee related exception sending the
User Data Relay message.XBeeLocalInterfacepublic void setReceiveTimeout(int receiveTimeout)
AbstractXBeeDevicereceiveTimeout - The new receive timeout in milliseconds.AbstractXBeeDevice.getReceiveTimeout()public String toString()
toString in class AbstractXBeeDevice© Copyright 2014 - 2019 Digi International Inc. All rights reserved.