de.avetana.bluetooth.rfcomm
Class RFCommConnectionImpl

java.lang.Object
  extended by de.avetana.bluetooth.connection.BTConnection
      extended by de.avetana.bluetooth.rfcomm.RFCommConnectionImpl

public class RFCommConnectionImpl
extends BTConnection

The top-class for the management of stream-oriented connections.

COPYRIGHT:
(c) Copyright 2004 Avetana GmbH ALL RIGHTS RESERVED.

This file is part of the Avetana bluetooth API for Linux.

The Avetana bluetooth API for Linux is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

The Avetana bluetooth API is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

The development of the Avetana bluetooth API is based on the work of Christian Lorenz (see the Javabluetooth Stack at http://www.javabluetooth.org) for some classes, on the work of the jbluez team (see http://jbluez.sourceforge.net/) and on the work of the bluez team (see the BlueZ linux Stack at http://www.bluez.org) for the C code. Classes, part of classes, C functions or part of C functions programmed by these teams and/or persons are explicitly mentioned.



Description:
This class allows the management of data streams between a remote and local device. It provides an InputStream and an OutputStream for easily receiving and sending data from/to a remote device. The InputStream stores all retrieved data into its buffer: no data is therefore lost.


Nested Class Summary
protected  class RFCommConnectionImpl.MInputStream
          An own extension of the classical java InputStream class.
protected  class RFCommConnectionImpl.MOutputStream
          An own extension of the classical java OutputStream class.
 
Field Summary
protected  RFCommConnectionImpl.MInputStream inStream
          The own defined and implemented input stream.
protected  RFCommConnectionImpl.MOutputStream outStream
          The own defined and implemented output stream.
 
Fields inherited from class de.avetana.bluetooth.connection.BTConnection
closed, dataBuffer, fid, m_remote
 
Constructor Summary
protected RFCommConnectionImpl(int a_fid)
           
  RFCommConnectionImpl(int fid, java.lang.String string)
           
 
Method Summary
static RFCommConnectionImpl createRFCommConnection(JSR82URL url, int timeout)
          Creates a new RFCOMM connection with a remote BT device.
 java.io.DataInputStream openDataInputStream()
          If the nested input stream was not opened before, opens it and starts reading.
 java.io.DataOutputStream openDataOutputStream()
          Opens the nested output stream and returns the DataOutputStream based on it.
 java.io.InputStream openInputStream()
          Returns the inputstream used by this connection
 java.io.OutputStream openOutputStream()
          Opens and returns the nested output stream.
 
Methods inherited from class de.avetana.bluetooth.connection.BTConnection
available, close, getConnectionID, getRemoteDevice, isClosed, newData, read, setRemoteDevice
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inStream

protected RFCommConnectionImpl.MInputStream inStream
The own defined and implemented input stream.


outStream

protected RFCommConnectionImpl.MOutputStream outStream
The own defined and implemented output stream.

Constructor Detail

RFCommConnectionImpl

protected RFCommConnectionImpl(int a_fid)

RFCommConnectionImpl

public RFCommConnectionImpl(int fid,
                            java.lang.String string)
Parameters:
fid -
string -
Method Detail

createRFCommConnection

public static RFCommConnectionImpl createRFCommConnection(JSR82URL url,
                                                          int timeout)
                                                   throws java.lang.Exception
Creates a new RFCOMM connection with a remote BT device.

Parameters:
url - The connection URL encapsulating all connection options
Returns:
An instance of RFCommConnection with manages the Output and InputStream connections streams
Throws:
java.lang.Exception

openDataInputStream

public java.io.DataInputStream openDataInputStream()
                                            throws java.io.IOException
If the nested input stream was not opened before, opens it and starts reading. Returns the DataInputStream based on this opened nested input stream.

Returns:
The DataInputStream based on this opened nested input stream.
Throws:
java.io.IOException

openOutputStream

public java.io.OutputStream openOutputStream()
                                      throws java.io.IOException
Opens and returns the nested output stream.

Returns:
The nested ouput stream
Throws:
java.io.IOException

openDataOutputStream

public java.io.DataOutputStream openDataOutputStream()
                                              throws java.io.IOException
Opens the nested output stream and returns the DataOutputStream based on it.

Returns:
The nested OuputStream.
Throws:
java.io.IOException

openInputStream

public java.io.InputStream openInputStream()
                                    throws java.io.IOException
Returns the inputstream used by this connection

Returns:
The inputstream used by this connection
Throws:
java.io.IOException