public class IPDevice extends XBeeDevice
CellularDevice
,
WiFiDevice
Modifier and Type | Field and Description |
---|---|
static String |
BROADCAST_IP |
Modifier and Type | Method and Description |
---|---|
void |
addIPDataListener(IIPDataReceiveListener listener)
Adds the provided listener to the list of listeners to be notified
when new IP data is received.
|
Inet4Address |
getDestinationIPAddress()
Returns the destination IP address.
|
Inet4Address |
getIPAddress()
Returns the IP address of this IP device.
|
void |
readDeviceInfo()
Reads some parameters from this device and obtains its protocol.
|
IPMessage |
readIPData()
Reads new IP data received by this XBee device during the
configured receive timeout.
|
IPMessage |
readIPData(int timeout)
Reads new IP data received by this XBee device during the provided
timeout.
|
IPMessage |
readIPDataFrom(Inet4Address ipAddress)
Reads new IP data received from the given IP address during the
configured receive timeout.
|
IPMessage |
readIPDataFrom(Inet4Address ipAddress,
int timeout)
Reads new IP data received from the given IP address during the
provided timeout.
|
void |
removeIPDataListener(IIPDataReceiveListener listener)
Removes the provided listener from the list of IP data listeners.
|
void |
sendBroadcastIPData(int destPort,
byte[] data)
Sends the provided IP data to all clients.
|
void |
sendIPData(Inet4Address ipAddress,
int destPort,
IPProtocol protocol,
boolean closeSocket,
byte[] data)
Sends the provided IP data to the given IP address and port using
the specified IP protocol.
|
void |
sendIPData(Inet4Address ipAddress,
int destPort,
IPProtocol protocol,
byte[] data)
Sends the provided IP data to the given IP address and port using
the specified IP protocol.
|
void |
sendIPDataAsync(Inet4Address ipAddress,
int destPort,
IPProtocol protocol,
boolean closeSocket,
byte[] data)
Sends the provided IP data to the given IP address and port
asynchronously using the specified IP protocol.
|
void |
sendIPDataAsync(Inet4Address ipAddress,
int destPort,
IPProtocol protocol,
byte[] data)
Sends the provided IP data to the given IP address and port
asynchronously.
|
void |
setDestinationIPAddress(Inet4Address address)
Sets the destination IP address.
|
void |
startListening(int sourcePort)
Starts listening for incoming IP transmissions in the provided port.
|
void |
stopListening()
Stops listening for incoming IP transmissions.
|
addBluetoothDataListener, addDataListener, addIOSampleListener, addMicroPythonDataListener, addModemStatusListener, addPacketListener, addUserDataRelayListener, close, getNetwork, getNextFrameID, getOperatingMode, getReceiveTimeout, isOpen, isRemote, open, readData, readData, readDataFrom, readDataFrom, readPacket, readPacket, readPacketFrom, readPacketFrom, removeBluetoothDataListener, removeDataListener, removeIOSampleListener, removeMicroPythonDataListener, removeModemStatusListener, removePacketListener, removeUserDataRelayListener, reset, sendBluetoothData, sendBroadcastData, sendData, sendDataAsync, sendMicroPythonData, sendPacket, sendPacket, sendPacketAsync, sendUserDataRelay, setReceiveTimeout, 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, readIOSample, setDestinationAddress, setDIOChangeDetection, setDIOValue, setIOConfiguration, setIOSamplingRate, setIPv6DestinationAddress, setNodeID, setPANID, setParameter, setPowerLevel, setPWMDutyCycle, updateBluetoothPassword, updateDeviceDataFrom, writeChanges
public static final String BROADCAST_IP
public void addIPDataListener(IIPDataReceiveListener listener)
AbstractXBeeDevice
If the listener has been already included this method does nothing.
listener
- Listener to be notified when new IP data is
received.AbstractXBeeDevice.removeIPDataListener(IIPDataReceiveListener)
,
IIPDataReceiveListener
public Inet4Address getDestinationIPAddress() throws TimeoutException, XBeeException
TimeoutException
- if there is a timeout reading the destination
address.XBeeException
- if there is any other XBee related exception.setDestinationIPAddress(Inet4Address)
,
Inet4Address
public Inet4Address getIPAddress()
To refresh this value use the readDeviceInfo()
method.
Inet4Address
public void readDeviceInfo() throws TimeoutException, XBeeException
AbstractXBeeDevice
This method refresh the values of:
readDeviceInfo
in class AbstractXBeeDevice
TimeoutException
- if there is a timeout reading the parameters.XBeeException
- if there is any error trying to read the device information or
if there is any other XBee related exception.AbstractXBeeDevice.get16BitAddress()
,
AbstractXBeeDevice.get64BitAddress()
,
AbstractXBeeDevice.getHardwareVersion()
,
AbstractXBeeDevice.getNodeID()
,
AbstractXBeeDevice.getFirmwareVersion()
,
AbstractXBeeDevice.getXBeeProtocol()
,
AbstractXBeeDevice.setNodeID(String)
public IPMessage readIPData()
This method blocks until new IP 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 IIPDataReceiveListener
using the method addIPDataListener(IIPDataReceiveListener)
.
Before reading IP data you need to start listening for incoming
IP data at a specific port. Use the startListening
method
for that purpose. When finished, you can use the stopListening
method to stop listening for incoming IP data.
IPMessage
object containing the IP data and
the IP address that sent the data. null
if this did not
receive new IP data during the configured receive timeout.InterfaceNotOpenException
- if this device connection is not open.XBeeDevice.getReceiveTimeout()
,
readIPData(int)
,
readIPDataFrom(Inet4Address)
,
readIPDataFrom(Inet4Address, int)
,
XBeeDevice.setReceiveTimeout(int)
,
startListening(int)
,
stopListening()
,
IPMessage
public IPMessage readIPData(int timeout)
This method blocks until new IP data is received or the provided timeout expires.
For non-blocking operations, register a IIPDataReceiveListener
using the method addIPDataListener(IIPDataReceiveListener)
.
Before reading IP data you need to start listening for incoming
IP data at a specific port. Use the startListening
method
for that purpose. When finished, you can use the stopListening
method to stop listening for incoming IP data.
timeout
- The time to wait for new IP data in milliseconds.IPMessage
object containing the data and the IP
address that sent the data. null
if this device did not
receive new data during timeout
milliseconds.IllegalArgumentException
- if timeout < 0
.InterfaceNotOpenException
- if this device connection is not open.readIPData()
,
readIPDataFrom(Inet4Address)
,
readIPDataFrom(Inet4Address, int)
,
startListening(int)
,
stopListening()
,
IPMessage
public IPMessage readIPDataFrom(Inet4Address ipAddress)
This method blocks until new data from the provided IP address 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 IIPDataReceiveListener
using the method addIPDataListener(IIPDataReceiveListener)
.
Before reading IP data you need to start listening for incoming
IP data at a specific port. Use the startListening
method
for that purpose. When finished, you can use the stopListening
method to stop listening for incoming IP data.
ipAddress
- The IP address to read data from.IPMessage
object containing the IP data and
the IP address of the remote node that sent the data.
null
if this device did not receive new IP data
from the provided IP address during the configured receive
timeout.InterfaceNotOpenException
- if this device connection is not open.NullPointerException
- if ipAddress == null
.XBeeDevice.getReceiveTimeout()
,
readIPData()
,
readIPData(int)
,
readIPDataFrom(Inet4Address, int)
,
XBeeDevice.setReceiveTimeout(int)
,
startListening(int)
,
stopListening()
,
IPMessage
,
Inet4Address
public IPMessage readIPDataFrom(Inet4Address ipAddress, int timeout)
This method blocks until new IP data from the provided IP address is received or the given timeout expires.
For non-blocking operations, register a IIPDataReceiveListener
using the method addIPDataListener(IIPDataReceiveListener)
.
Before reading IP data you need to start listening for incoming
IP data at a specific port. Use the startListening
method
for that purpose. When finished, you can use the stopListening
method to stop listening for incoming IP data.
ipAddress
- The IP address to read data from.timeout
- The time to wait for new IP data in milliseconds.IPMessage
object containing the IP data and
the IP address that sent the data. null
if this device
did not receive new IP data from the provided IP address
during timeout
milliseconds.IllegalArgumentException
- if timeout < 0
.InterfaceNotOpenException
- if this device connection is not open.NullPointerException
- if ipAddress == null
.readIPDataFrom(Inet4Address)
,
readIPData()
,
readIPData(int)
,
startListening(int)
,
stopListening()
,
IPMessage
,
Inet4Address
public void removeIPDataListener(IIPDataReceiveListener listener)
AbstractXBeeDevice
If the listener was not in the list this method does nothing.
listener
- Listener to be removed from the list of listeners.AbstractXBeeDevice.addIPDataListener(IIPDataReceiveListener)
,
IIPDataReceiveListener
public void sendBroadcastIPData(int destPort, byte[] data) throws TimeoutException, XBeeException
This 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.
destPort
- The destination port of the transmission.data
- Byte array containing the IP data to be sent.IllegalArgumentException
- if destPort < 0
or
if destPort > 65535
InterfaceNotOpenException
- if this device connection is not open.NullPointerException
- if data == null
.TimeoutException
- if there is a timeout sending the data.XBeeException
- if there is any other XBee related exception.XBeeDevice.getReceiveTimeout()
,
sendIPData(Inet4Address, int, IPProtocol, byte[])
,
sendIPData(Inet4Address, int, IPProtocol, boolean, byte[])
,
sendIPDataAsync(Inet4Address, int, IPProtocol, byte[])
,
sendIPDataAsync(Inet4Address, int, IPProtocol, boolean, byte[])
,
XBeeDevice.setReceiveTimeout(int)
public void sendIPData(Inet4Address ipAddress, int destPort, IPProtocol protocol, boolean closeSocket, byte[] data) throws TimeoutException, XBeeException
This 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
sendIPDataAsync(Inet4Address, int, IPProtocol, byte[])
.
ipAddress
- The IP address to send IP data to.destPort
- The destination port of the transmission.protocol
- The IP protocol used for the transmission.closeSocket
- true
to close the socket just after the
transmission. false
to keep it open.data
- Byte array containing the IP data to be sent.IllegalArgumentException
- if destPort < 0
or
if destPort > 65535
InterfaceNotOpenException
- if this device connection is not open.NullPointerException
- if ipAddress == null
or
if protocol == null
or
if data == null
.TimeoutException
- if there is a timeout sending the data.XBeeException
- if there is any other XBee related exception.XBeeDevice.getReceiveTimeout()
,
sendBroadcastIPData(int, byte[])
,
sendIPData(Inet4Address, int, IPProtocol, byte[])
,
sendIPDataAsync(Inet4Address, int, IPProtocol, byte[])
,
sendIPDataAsync(Inet4Address, int, IPProtocol, boolean, byte[])
,
XBeeDevice.setReceiveTimeout(int)
,
IPProtocol
,
Inet4Address
public void sendIPData(Inet4Address ipAddress, int destPort, IPProtocol protocol, byte[] data) throws TimeoutException, XBeeException
This 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
sendIPDataAsync(Inet4Address, int, IPProtocol, byte[])
.
ipAddress
- The IP address to send IP data to.destPort
- The destination port of the transmission.protocol
- The IP protocol used for the transmission.data
- Byte array containing the IP data to be sent.IllegalArgumentException
- if destPort < 0
or
if destPort > 65535
InterfaceNotOpenException
- if this device connection is not open.NullPointerException
- if ipAddress == null
or
if protocol == null
or
if data == null
.TimeoutException
- if there is a timeout sending the data.XBeeException
- if there is any other XBee related exception.XBeeDevice.getReceiveTimeout()
,
sendBroadcastIPData(int, byte[])
,
sendIPData(Inet4Address, int, IPProtocol, boolean, byte[])
,
sendIPDataAsync(Inet4Address, int, IPProtocol, byte[])
,
sendIPDataAsync(Inet4Address, int, IPProtocol, boolean, byte[])
,
XBeeDevice.setReceiveTimeout(int)
,
IPProtocol
,
Inet4Address
public void sendIPDataAsync(Inet4Address ipAddress, int destPort, IPProtocol protocol, boolean closeSocket, byte[] data) throws XBeeException
Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.
ipAddress
- The IP address to send IP data to.destPort
- The destination port of the transmission.protocol
- The IP protocol used for the transmission.closeSocket
- true
to close the socket just after the
transmission. false
to keep it open.data
- Byte array containing the IP data to be sent.IllegalArgumentException
- if destPort < 0
or
if destPort > 65535
InterfaceNotOpenException
- if this device connection is not open.NullPointerException
- if ipAddress == null
or
if protocol == null
or
if data == null
.TimeoutException
- if there is a timeout sending the data.XBeeException
- if there is any other XBee related exception.sendBroadcastIPData(int, byte[])
,
sendIPData(Inet4Address, int, IPProtocol, byte[])
,
sendIPData(Inet4Address, int, IPProtocol, boolean, byte[])
,
sendIPDataAsync(Inet4Address, int, IPProtocol, byte[])
,
IPProtocol
,
Inet4Address
public void sendIPDataAsync(Inet4Address ipAddress, int destPort, IPProtocol protocol, byte[] data) throws TimeoutException, XBeeException
Asynchronous transmissions do not wait for answer from the remote device or for transmit status packet.
ipAddress
- The IP address to send IP data to.destPort
- The destination port of the transmission.protocol
- The IP protocol used for the transmission.data
- Byte array containing the IP data to be sent.IllegalArgumentException
- if destPort < 0
or
if destPort > 65535
InterfaceNotOpenException
- if this device connection is not open.NullPointerException
- if ipAddress == null
or
if protocol == null
or
if data == null
.TimeoutException
- if there is a timeout sending the data.XBeeException
- if there is any other XBee related exception.sendBroadcastIPData(int, byte[])
,
sendIPData(Inet4Address, int, IPProtocol, byte[])
,
sendIPData(Inet4Address, int, IPProtocol, boolean, byte[])
,
sendIPDataAsync(Inet4Address, int, IPProtocol, boolean, byte[])
,
IPProtocol
,
Inet4Address
public void setDestinationIPAddress(Inet4Address address) throws TimeoutException, XBeeException
address
- Destination IP address.NullPointerException
- if address == null
.TimeoutException
- if there is a timeout setting the destination
address.XBeeException
- if there is any other XBee related exception.getDestinationIPAddress()
,
Inet4Address
public void startListening(int sourcePort) throws TimeoutException, XBeeException
sourcePort
- Port to listen for incoming transmissions.IllegalArgumentException
- if sourcePort < 0
or
if sourcePort > 65535
.TimeoutException
- if there is a timeout setting the source port.XBeeException
- if there is any error setting the source port.stopListening()
public void stopListening() throws TimeoutException, XBeeException
TimeoutException
- if there is a timeout processing the operation.XBeeException
- if there is any other XBee related exception.startListening(int)
© Copyright 2014 - 2024 Digi International Inc. All rights reserved.