public abstract class IPConnectionBase extends Object implements Closeable
Modifier and Type | Field and Description |
---|---|
static byte |
CALLBACK_CONNECTED |
static byte |
CALLBACK_DISCONNECTED |
static byte |
CALLBACK_ENUMERATE |
static short |
CONNECT_REASON_AUTO_RECONNECT |
static short |
CONNECT_REASON_REQUEST |
static short |
CONNECTION_STATE_CONNECTED |
static short |
CONNECTION_STATE_DISCONNECTED |
static short |
CONNECTION_STATE_PENDING |
static short |
DISCONNECT_REASON_ERROR |
static short |
DISCONNECT_REASON_REQUEST |
static short |
DISCONNECT_REASON_SHUTDOWN |
static short |
ENUMERATION_TYPE_AVAILABLE |
static short |
ENUMERATION_TYPE_CONNECTED |
static short |
ENUMERATION_TYPE_DISCONNECTED |
static byte |
FUNCTION_ENUMERATE |
Constructor and Description |
---|
IPConnectionBase() |
Modifier and Type | Method and Description |
---|---|
void |
authenticate(String secret)
Performs an authentication handshake with the connected Brick Daemon or
WIFI/Ethernet Extension.
|
protected abstract void |
callConnectedListeners(short connectReason) |
protected abstract void |
callDeviceListener(Device device,
byte functionID,
byte[] packet) |
protected abstract void |
callDisconnectedListeners(short disconnectReason) |
protected abstract void |
callEnumerateListeners(String uid,
String connectedUid,
char position,
short[] hardwareVersion,
short[] firmwareVersion,
int deviceIdentifier,
short enumerationType) |
void |
close()
Implement Closable interface to allow something like
try (IPConnection ipcon = new IPConnection()) { }
|
void |
connect(String host,
int port)
Creates a TCP/IP connection to the given \c host and \c port.
|
void |
disconnect()
Disconnects the TCP/IP connection from the Brick Daemon or the
WIFI/Ethernet Extension.
|
void |
enumerate()
Broadcasts an enumerate request.
|
boolean |
getAutoReconnect()
Returns *true* if auto-reconnect is enabled, *false* otherwise.
|
short |
getConnectionState()
Can return the following states:
- CONNECTION_STATE_DISCONNECTED: No connection is established.
|
int |
getTimeout()
Returns the timeout as set by setTimeout.
|
protected abstract boolean |
hasEnumerateListeners() |
void |
setAutoReconnect(boolean autoReconnect)
Enables or disables auto-reconnect.
|
void |
setTimeout(int timeout)
Sets the timeout in milliseconds for getters and for setters for which the
response expected flag is activated.
|
public static final byte FUNCTION_ENUMERATE
public static final byte CALLBACK_ENUMERATE
public static final byte CALLBACK_CONNECTED
public static final byte CALLBACK_DISCONNECTED
public static final short ENUMERATION_TYPE_AVAILABLE
public static final short ENUMERATION_TYPE_CONNECTED
public static final short ENUMERATION_TYPE_DISCONNECTED
public static final short CONNECT_REASON_REQUEST
public static final short CONNECT_REASON_AUTO_RECONNECT
public static final short DISCONNECT_REASON_REQUEST
public static final short DISCONNECT_REASON_ERROR
public static final short DISCONNECT_REASON_SHUTDOWN
public static final short CONNECTION_STATE_DISCONNECTED
public static final short CONNECTION_STATE_CONNECTED
public static final short CONNECTION_STATE_PENDING
public void connect(String host, int port) throws NetworkException, AlreadyConnectedException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void disconnect() throws NotConnectedException
NotConnectedException
public void authenticate(String secret) throws TinkerforgeException
TinkerforgeException
public short getConnectionState()
public void setAutoReconnect(boolean autoReconnect)
public boolean getAutoReconnect()
public void setTimeout(int timeout)
public int getTimeout()
public void enumerate() throws NotConnectedException
NotConnectedException
protected abstract void callEnumerateListeners(String uid, String connectedUid, char position, short[] hardwareVersion, short[] firmwareVersion, int deviceIdentifier, short enumerationType)
protected abstract boolean hasEnumerateListeners()
protected abstract void callConnectedListeners(short connectReason)
protected abstract void callDisconnectedListeners(short disconnectReason)
protected abstract void callDeviceListener(Device device, byte functionID, byte[] packet)
Copyright © 2022 Tinkerforge GmbH. All rights reserved.