Package de.freaklamarsch.systarest
Class DeviceTouchSearch
java.lang.Object
de.freaklamarsch.systarest.DeviceTouchSearch
public class DeviceTouchSearch
extends java.lang.Object
A utility class for searching and interacting with DeviceTouch devices. This
class provides methods to create search messages, parse responses, and
extract device information.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDeviceTouchSearch.DeviceTouchDeviceInfoInformation returned from a device supporting the DeviceTouch protocol -
Field Summary
Fields Modifier and Type Field Description private static intBCAST_PORTprivate static intMAX_DATA_LENGTH -
Constructor Summary
Constructors Constructor Description DeviceTouchSearch() -
Method Summary
Modifier and Type Method Description static java.net.DatagramPacketcreatePasswordRequestMessage(java.lang.String mac, java.net.InetAddress bcastAddress)Creates the DatagramPacket to request the password from a DeviceTouch device.static java.net.DatagramPacketcreatePortRequestMessage(java.lang.String mac, java.net.InetAddress bcastAddress)Creates the DatagramPacket to request the port number used from communication from a DeviceTouch device.static java.net.DatagramPacketcreateSearchMessage(java.net.InetAddress bcastAddress)Creates a search message to broadcast on the network for discovering DeviceTouch devices.static java.lang.StringgetPasswordReplyString(java.net.DatagramPacket receivePacket)Extracts the password reply string from a DatagramPacket received from a DeviceTouch device.static java.lang.StringgetPortReplyString(java.net.DatagramPacket receivePacket)Extracts the search reply string from a DatagramPacket.static java.lang.StringgetSearchReplyString(java.net.DatagramPacket receivePacket)Extracts the search reply string from a DatagramPacket.static DeviceTouchSearch.DeviceTouchDeviceInfoparseDeviceTouchInfoString(java.lang.String deviceTouchInfoString)Function to parse the info string returned from a Paradigma SystaComfort The string looks like SC2 1 192.168.11.23 255.255.255.0 192.168.11.1 SystaComfort-II0 0809720001 0 V0.34 V1.00 2CBE9700BEE9static java.lang.StringparsePasswordReplyString(java.lang.String reply)Parses a password reply message received from a DeviceTouch device.static intparsePortReplyString(java.lang.String reply)Parses a port reply message received from a DeviceTouch device.private static voidprintByteArrayAsHex(byte[] bytes)static DeviceTouchSearch.DeviceTouchDeviceInfosearch()Search for devices supporting the DeviceTouch protocol.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
MAX_DATA_LENGTH
private static final int MAX_DATA_LENGTH- See Also:
- Constant Field Values
-
BCAST_PORT
private static final int BCAST_PORT- See Also:
- Constant Field Values
-
-
Constructor Details
-
DeviceTouchSearch
public DeviceTouchSearch()
-
-
Method Details
-
search
Search for devices supporting the DeviceTouch protocol. The search sends UDP broadcasts and returns theDeviceTouchSearch.DeviceTouchDeviceInfoobject parsed from received reply messages- Returns:
- received
DeviceTouchSearch.DeviceTouchDeviceInfo
-
parsePasswordReplyString
public static java.lang.String parsePasswordReplyString(java.lang.String reply)Parses a password reply message received from a DeviceTouch device.- Parameters:
reply- the reply string containing the password- Returns:
- the extracted password
-
getPasswordReplyString
public static java.lang.String getPasswordReplyString(java.net.DatagramPacket receivePacket) throws java.lang.NumberFormatExceptionExtracts the password reply string from a DatagramPacket received from a DeviceTouch device.- Parameters:
receivePacket- the DatagramPacket containing the password reply- Returns:
- the extracted password reply string
- Throws:
java.lang.NumberFormatException
-
createPasswordRequestMessage
public static java.net.DatagramPacket createPasswordRequestMessage(java.lang.String mac, java.net.InetAddress bcastAddress)Creates the DatagramPacket to request the password from a DeviceTouch device.- Parameters:
mac- the MAC address of the target DeviceTouch devicebcastAddress- the broadcast address used for communication with the DeviceTouch device- Returns:
- a DatagramPacket containing the password request message
-
parsePortReplyString
public static int parsePortReplyString(java.lang.String reply) throws java.lang.NumberFormatExceptionParses a port reply message received from a DeviceTouch device.- Parameters:
reply- the reply string containing the port- Returns:
- the extracted port
- Throws:
java.lang.NumberFormatException- if the reply dows not contain a validInteger
-
getPortReplyString
public static java.lang.String getPortReplyString(java.net.DatagramPacket receivePacket)Extracts the search reply string from a DatagramPacket.- Parameters:
receivePacket- the DatagramPacket containing the port reply- Returns:
- the extracted port reply string
-
createPortRequestMessage
public static java.net.DatagramPacket createPortRequestMessage(java.lang.String mac, java.net.InetAddress bcastAddress)Creates the DatagramPacket to request the port number used from communication from a DeviceTouch device.- Parameters:
mac- the MAC address of the target DeviceTouch devicebcastAddress- the broadcast address used for communication with the DeviceTouch device- Returns:
- a DatagramPacket containing the port request message
-
getSearchReplyString
public static java.lang.String getSearchReplyString(java.net.DatagramPacket receivePacket)Extracts the search reply string from a DatagramPacket.- Parameters:
receivePacket- the DatagramPacket containing the search reply- Returns:
- the extracted search reply string
-
createSearchMessage
public static java.net.DatagramPacket createSearchMessage(java.net.InetAddress bcastAddress)Creates a search message to broadcast on the network for discovering DeviceTouch devices.- Parameters:
bcastAddress- the broadcast address to send the search message- Returns:
- a DatagramPacket containing the search message
-
parseDeviceTouchInfoString
public static DeviceTouchSearch.DeviceTouchDeviceInfo parseDeviceTouchInfoString(java.lang.String deviceTouchInfoString)Function to parse the info string returned from a Paradigma SystaComfort The string looks like SC2 1 192.168.11.23 255.255.255.0 192.168.11.1 SystaComfort-II0 0809720001 0 V0.34 V1.00 2CBE9700BEE9- Parameters:
deviceTouchInfoString- the string received from the Paradigma SystaComfort- Returns:
- the SCInfoString object parsed from the string
-
printByteArrayAsHex
private static void printByteArrayAsHex(byte[] bytes)
-