org.llrp.ltk.net
Class LLRPConnector

java.lang.Object
  extended by org.llrp.ltk.net.LLRPConnection
      extended by org.llrp.ltk.net.LLRPConnector

public class LLRPConnector
extends LLRPConnection

LLRPConnector implements a self-initiated LLRP connection. Here is a simple code example:

LLRPConnector c = new LLRPConnector(endpoint,ip);

c.connect();

// send message asynchronously - response needs to handled via

// the message received method of the endpoint

c.send(llrpmessage);

// send message synchronously

LLRPMessage m = c.transact(llrpmessage);

The connect method checks the status of the ConnectionAttemptStatus field in in the READER_EVENT_NOTIFICATION message. If the status field is not 'Success", an LLRPConnectionAttemptFailedException is thrown.


Field Summary
 
Fields inherited from class org.llrp.ltk.net.LLRPConnection
CONNECT_TIMEOUT, endpoint, handler, session, SYNC_MESSAGE_ANSWER
 
Constructor Summary
LLRPConnector()
           
LLRPConnector(LLRPEndpoint endpoint, java.lang.String host)
          LLRPConnector using parameters provided and LLRPIoAdapterHandlerImpl as default IoHandler and default port 5084
LLRPConnector(LLRPEndpoint endpoint, java.lang.String host, int port)
          LLRPConnector using parameters provided and LLRPIoAdapterHandlerImpl as default IoHandler
LLRPConnector(LLRPEndpoint endpoint, java.lang.String host, int port, LLRPIoHandlerAdapter handler)
          LLRPConnector using parameters provided
LLRPConnector(LLRPEndpoint endpoint, java.lang.String host, LLRPIoHandlerAdapter handler)
          LLRPConnector using parameters provided and default port 5084
 
Method Summary
 void connect()
          connects to a LLRP device at the host address and port specified.
 void connect(long timeout)
          connects to a LLRP device at the host address and port specified.
 void disconnect()
          disconnect existing connection to LLRP device.
 java.lang.String getHost()
          get host address of reader device.
 int getPort()
          get port on which to connect to reader device.
 boolean reconnect()
          reconnect to LLRP device using host, port and handler specified.
 void setHost(java.lang.String host)
          set host address of reader device.
 void setPort(int port)
          set port on which to connect to reader device.
 
Methods inherited from class org.llrp.ltk.net.LLRPConnection
checkLLRPConnectionAttemptStatus, getEndpoint, getHandler, send, setEndpoint, setHandler, transact, transact
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LLRPConnector

public LLRPConnector()

LLRPConnector

public LLRPConnector(LLRPEndpoint endpoint,
                     java.lang.String host,
                     int port)
LLRPConnector using parameters provided and LLRPIoAdapterHandlerImpl as default IoHandler


LLRPConnector

public LLRPConnector(LLRPEndpoint endpoint,
                     java.lang.String host)
LLRPConnector using parameters provided and LLRPIoAdapterHandlerImpl as default IoHandler and default port 5084


LLRPConnector

public LLRPConnector(LLRPEndpoint endpoint,
                     java.lang.String host,
                     LLRPIoHandlerAdapter handler)
LLRPConnector using parameters provided and default port 5084


LLRPConnector

public LLRPConnector(LLRPEndpoint endpoint,
                     java.lang.String host,
                     int port,
                     LLRPIoHandlerAdapter handler)
LLRPConnector using parameters provided

Method Detail

connect

public void connect()
             throws LLRPConnectionAttemptFailedException
connects to a LLRP device at the host address and port specified. the connect method waits by default 10 s for a response. If the READER_NOTIFICATION does not arrive or the ConnectionAttemptEventStatus is not set to 'Success', a LLRPConnectionAttemptFailedException is thrown.

Throws:
LLRPConnectionAttemptFailedException

connect

public void connect(long timeout)
             throws LLRPConnectionAttemptFailedException
connects to a LLRP device at the host address and port specified. the connect method waits for the timeperiod specified (in ms) for a response. If the READER_NOTIFICATION does not arrive or the ConnectionAttemptEventStatus is not set to 'Success', a LLRPConnectionAttemptFailedException is thrown.

Parameters:
timeout - time in ms
Throws:
LLRPConnectionAttemptFailedException

disconnect

public void disconnect()
disconnect existing connection to LLRP device.


reconnect

public boolean reconnect()
reconnect to LLRP device using host, port and handler specified.

Specified by:
reconnect in class LLRPConnection
Returns:
true if connection could be established and ConnectionAttemptEvent Status was set to 'Success', set to false otherwise

getHost

public java.lang.String getHost()
get host address of reader device.

Returns:
the host

setHost

public void setHost(java.lang.String host)
set host address of reader device.

Parameters:
host - the host to set

getPort

public int getPort()
get port on which to connect to reader device.

Returns:
the port

setPort

public void setPort(int port)
set port on which to connect to reader device.

Parameters:
port - the port to set


Copyright © 2007 ETH Zurich.