public void connect() throws Exception {		
		// Start up our MINA stuff 
		// Setup MINA codecs
		final IT100CodecFactory it100CodecFactory = new IT100CodecFactory();
		final ProtocolCodecFilter protocolCodecFilter = new ProtocolCodecFilter(it100CodecFactory);
		final CommandLogFilter loggingFilter = new CommandLogFilter(LOGGER, Level.DEBUG);
		final PollKeepAliveFilter pollKeepAliveFilter = new PollKeepAliveFilter(KeepAliveRequestTimeoutHandler.EXCEPTION);
		
		// Connect to system serial port.
		connector = configuration.getConnector();
		
		// Typical configuration
		connector.setConnectTimeoutMillis(configuration.getConnectTimeout());
		connector.getSessionConfig().setUseReadOperation(true);

		// Add IT100 codec to MINA filter chain to interpret messages.
		connector.getFilterChain().addLast("codec", protocolCodecFilter);
		connector.getFilterChain().addLast("logger", loggingFilter);   
	    connector.getFilterChain().addLast("keepalive", pollKeepAliveFilter);
	    
	    
	    if (configuration.getStatusPollingInterval() != -1) {
	    	connector.getFilterChain().addLast("statusrequest", new StatusRequestFilter(configuration.getStatusPollingInterval()));
	    }
	    
	    final DemuxingIoHandler demuxIoHandler = new DemuxingIoHandler();
	    
	    // Setup a read message handler
		// OnSubscribe will allow us to create an Observable to received messages.
		final ReadCommandOnSubscribe readCommandObservable = new ReadCommandOnSubscribe();
		demuxIoHandler.addReceivedMessageHandler(ReadCommand.class, readCommandObservable);
		demuxIoHandler.addExceptionHandler(Exception.class, readCommandObservable);
	    
	    // Handle Envisalink 505 request for password events
	    if (configuration.getEnvisalinkPassword() != null) {
	    	final EnvisalinkLoginHandler envisalinkLoginHandler = new EnvisalinkLoginHandler(configuration.getEnvisalinkPassword());
	    	demuxIoHandler.addReceivedMessageHandler(EnvisalinkLoginInteractionCommand.class, envisalinkLoginHandler);
	    }
	    
	    // We don't need to subscribe to the messages we sent.
		demuxIoHandler.addSentMessageHandler(Object.class, MessageHandler.NOOP);		

		connector.setHandler(demuxIoHandler);
		 
		// Connect now
		final ConnectFuture future = connector.connect(configuration.getAddress()); 
		future.awaitUninterruptibly();

		// Get a reference to the session
		session = future.getSession(); 
		
		// Create and return our Observable for received IT-100 commands.
		final ConnectableObservable<ReadCommand> connectableReadObservable = Observable.create(readCommandObservable).publish();
		connectableReadObservable.connect();
		readObservable = connectableReadObservable.share().asObservable();
		
		// Create a write observer.
		writeObservable = PublishSubject.create();
		writeObservable.subscribe(new Observer<WriteCommand>() {

			@Override
			public void onCompleted() {
			}

			@Override
			public void onError(Throwable e) {
			}

			@Override
			public void onNext(WriteCommand command) {
				session.write(command);
			}
		});
		
		
	}
public void connect ( ) throws Exception { final IT100CodecFactory it100CodecFactory = new IT100CodecFactory ( ) ; final ProtocolCodecFilter protocolCodecFilter = new ProtocolCodecFilter ( it100CodecFactory ) ; final CommandLogFilter loggingFilter = new CommandLogFilter ( LOGGER , Level . DEBUG ) ; final PollKeepAliveFilter pollKeepAliveFilter = new PollKeepAliveFilter ( KeepAliveRequestTimeoutHandler . EXCEPTION ) ; connector = configuration . getConnector ( ) ; connector . setConnectTimeoutMillis ( configuration . getConnectTimeout ( ) ) ; connector . getSessionConfig ( ) . setUseReadOperation ( true ) ; connector . getFilterChain ( ) . addLast ( "codec" , protocolCodecFilter ) ; connector . getFilterChain ( ) . addLast ( "logger" , loggingFilter ) ; connector . getFilterChain ( ) . addLast ( "keepalive" , pollKeepAliveFilter ) ; if ( configuration . getStatusPollingInterval ( ) != - 1 ) { connector . getFilterChain ( ) . addLast ( "statusrequest" , new StatusRequestFilter ( configuration . getStatusPollingInterval ( ) ) ) ; } final DemuxingIoHandler demuxIoHandler = new DemuxingIoHandler ( ) ; final ReadCommandOnSubscribe readCommandObservable = new ReadCommandOnSubscribe ( ) ; demuxIoHandler . addReceivedMessageHandler ( ReadCommand . class , readCommandObservable ) ; demuxIoHandler . addExceptionHandler ( Exception . class , readCommandObservable ) ; if ( configuration . getEnvisalinkPassword ( ) != null ) { final EnvisalinkLoginHandler envisalinkLoginHandler = new EnvisalinkLoginHandler ( configuration . getEnvisalinkPassword ( ) ) ; demuxIoHandler . addReceivedMessageHandler ( EnvisalinkLoginInteractionCommand . class , envisalinkLoginHandler ) ; } demuxIoHandler . addSentMessageHandler ( Object . class , MessageHandler . NOOP ) ; connector . setHandler ( demuxIoHandler ) ; final ConnectFuture future = connector . connect ( configuration . getAddress ( ) ) ; future . awaitUninterruptibly ( ) ; session = future . getSession ( ) ; final ConnectableObservable < ReadCommand > connectableReadObservable = Observable . create ( readCommandObservable ) . publish ( ) ; connectableReadObservable . connect ( ) ; readObservable = connectableReadObservable . share ( ) . asObservable ( ) ; writeObservable = PublishSubject . create ( ) ; writeObservable . subscribe ( new Observer < WriteCommand > ( ) { @ Override public void onCompleted ( ) { } @ Override public void onError ( Throwable e ) { } @ Override public void onNext ( WriteCommand command ) { session . write ( command ) ; } } ) ; }
Begin communicating with the IT-100.

@throws Exception If an error occurs while connecting to the IT-100