|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttuwien.auto.calimero.knxnetip.KNXnetIPDevMgmt
public class KNXnetIPDevMgmt
KNXnet/IP connection for KNX local device management.
The communication on OSI layer 4 is done using UDP.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface tuwien.auto.calimero.knxnetip.KNXnetIPConnection |
---|
KNXnetIPConnection.BlockingMode |
Field Summary | |
---|---|
static int |
ACK_ERROR
Status code of communication: in idle state, received an acknowledge error in response, ready to send. |
static int |
ACK_PENDING
Status code of communication: waiting for acknowledge after send, no error, not ready to send. |
static int |
CEMI_CON_PENDING
Status code of communication: waiting for confirmation after acknowledge, no error, not ready to send. |
static short |
DEVICE_MGMT_CONNECTION
Connection type used to configure a KNXnet/IP device. |
static int |
UNKNOWN_ERROR
Status code of communication: unknown error, no send possible. |
Fields inherited from interface tuwien.auto.calimero.knxnetip.KNXnetIPConnection |
---|
CLOSED, IP_PORT, KNXNETIP_VERSION_10, NONBLOCKING, OK, WAIT_FOR_ACK, WAIT_FOR_CON |
Constructor Summary | |
---|---|
KNXnetIPDevMgmt(java.net.InetSocketAddress localEP,
java.net.InetSocketAddress serverCtrlEP,
boolean useNAT)
Creates a new KNXnet/IP device management connection to a remote device. |
Method Summary | |
---|---|
void |
addConnectionListener(KNXListener l)
Adds the specified event listener l to receive events from this
connection. |
void |
close()
Ends communication with the remote server/client as specified by the used protocol. |
protected void |
connect(java.net.InetSocketAddress localEP,
java.net.InetSocketAddress serverCtrlEP,
CRI cri,
boolean useNAT)
Opens a new IP communication channel to a remote server. |
protected void |
fireFrameReceived(CEMI frame)
Fires a frame received event ( KNXListener.frameReceived(FrameEvent) ) for
the supplied cEMI frame . |
java.lang.String |
getName()
Returns the name of this connection, a brief textual representation to identify a KNXnet/IP connection. |
java.net.InetSocketAddress |
getRemoteAddress()
Returns the address (endpoint) this connection endpoint is communicating to. |
protected int |
getSeqNoRcv()
Returns the protocol's current receive sequence number. |
protected int |
getSeqNoSend()
Returns the protocol's current send sequence number. |
int |
getState()
Returns information about the current KNXnet/IP communication state. |
protected void |
incSeqNoRcv()
Increments the protocol's receive sequence number, with increment on sequence number 255 resulting in 0. |
protected void |
incSeqNoSend()
Increments the protocol's send sequence number, with increment on sequence number 255 resulting in 0. |
void |
removeConnectionListener(KNXListener l)
Removes the specified event listener l , so it does no longer
receive events from this connection. |
void |
send(CEMI frame,
KNXnetIPConnection.BlockingMode mode)
Sends a cEMI device management frame to the remote server communicating with this endpoint. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final short DEVICE_MGMT_CONNECTION
public static final int ACK_ERROR
public static final int ACK_PENDING
public static final int CEMI_CON_PENDING
public static final int UNKNOWN_ERROR
Constructor Detail |
---|
public KNXnetIPDevMgmt(java.net.InetSocketAddress localEP, java.net.InetSocketAddress serverCtrlEP, boolean useNAT) throws KNXException
localEP
- the local endpoint to use for communication channelserverCtrlEP
- the remote server control endpoint used for connect requestuseNAT
- true
to use a NAT (network address translation) aware
communication mechanism, false
to use the default way
KNXException
- on socket communication error
KNXTimeoutException
- on no connect response before connect timeout
KNXRemoteException
- if response indicates an error condition at the server
concerning the request
KNXInvalidResponseException
- if connect response is in wrong formatMethod Detail |
---|
public java.lang.String getName()
KNXnetIPConnection
The name has to be unique at least for connections with different IP addresses for
the remote control endpoint.
The returned name is used by this connection for the name of its log service.
public void send(CEMI frame, KNXnetIPConnection.BlockingMode mode) throws KNXTimeoutException, KNXConnectionClosedException
send
in interface KNXnetIPConnection
frame
- cEMI device management message of type CEMIDevMgmt
to sendmode
- specifies the behavior in regard to response messages, this parameter
will be ignored by protocols in case no response is expected at all;KNXnetIPConnection.BlockingMode
constants, with following blocking
behavior in increasing orderKNXnetIPConnection.NONBLOCKING
KNXnetIPConnection.WAIT_FOR_ACK
KNXnetIPConnection.WAIT_FOR_CON
KNXTimeoutException
- in a blocking mode
if a timeout
regarding a response message was encountered
KNXConnectionClosedException
- if no communication was established in the
first place or communication was closedpublic void addConnectionListener(KNXListener l)
KNXnetIPConnection
l
to receive events from this
connection.
If l
was already added as listener, no action is performed.
Note: the method KNXListener.frameReceived(tuwien.auto.calimero.FrameEvent)
of an added listener will be invoked by the KNXnet/IP receiver, and not in the
context of the calling thread. Lengthy tasks have to be avoided during the
notification, and should be relayed into their own worker thread. Otherwise
subsequent listener invocations will suffer from time delays since the receiver can
not move on.
addConnectionListener
in interface KNXnetIPConnection
l
- the listener to addpublic final void close()
KNXnetIPConnection
All registered event listeners get notified. The close event is the last event the
listeners receive.
If this connection endpoint is already closed, no action is performed.
close
in interface KNXnetIPConnection
protected void connect(java.net.InetSocketAddress localEP, java.net.InetSocketAddress serverCtrlEP, CRI cri, boolean useNAT) throws KNXException
The communication state of this object is assumed to be closed state. This method is designed to be called only once during the objects lifetime!
localEP
- the local endpoint to use for communication channelserverCtrlEP
- the remote server control endpoint used for connect requestcri
- connect request information used to configure the communication
attributesuseNAT
- true
to use a NAT (network address translation) aware
communication mechanism, false
to use the default way
KNXException
- on socket communication error
KNXTimeoutException
- on no connect response before connect timeout
KNXRemoteException
- if response indicates an error condition at the server
concerning the request
KNXInvalidResponseException
- if connect response is in wrong formatprotected void fireFrameReceived(CEMI frame)
KNXListener.frameReceived(FrameEvent)
) for
the supplied cEMI frame
.
frame
- the cEMI to generate the event forpublic final java.net.InetSocketAddress getRemoteAddress()
KNXnetIPConnection
The address returned is equal to the one used to establish the communication (e.g.
control endpoint), although internal there might be used different addresses.
If no communication is established, the unspecified (wildcard) address with port
number 0 is returned.
getRemoteAddress
in interface KNXnetIPConnection
InetSocketAddress
protected int getSeqNoRcv()
protected int getSeqNoSend()
public final int getState()
KNXnetIPConnection
getState
in interface KNXnetIPConnection
protected void incSeqNoRcv()
protected void incSeqNoSend()
public void removeConnectionListener(KNXListener l)
KNXnetIPConnection
l
, so it does no longer
receive events from this connection.
If l
was not added in the first place, no action is performed.
removeConnectionListener
in interface KNXnetIPConnection
l
- the listener to remove
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |