Class RfcommConnection

java.lang.Object
com.codename1.bluetooth.classic.RfcommConnection

public abstract class RfcommConnection extends Object

An open RFCOMM (Serial Port Profile style) stream connection to a classic Bluetooth device, obtained via BluetoothClassic.connect(BluetoothDevice, BluetoothUuid, boolean) or accepted from an RfcommServer.

The streams block and must be consumed off the EDT; reads/writes throw plain java.io.IOException on transport failure. Always close() the connection when done.

  • Constructor Details

    • RfcommConnection

      protected RfcommConnection(BluetoothDevice device)
      Constructed by ports; not application API.
  • Method Details

    • getInputStream

      public abstract InputStream getInputStream() throws IOException
      The blocking input stream; consume off the EDT.
      Throws:
      IOException
    • getOutputStream

      public abstract OutputStream getOutputStream() throws IOException
      The blocking output stream; use off the EDT.
      Throws:
      IOException
    • close

      public abstract void close() throws IOException
      Closes the connection and both streams.
      Throws:
      IOException
    • isOpen

      public abstract boolean isOpen()
      true while the connection is open.
    • getDevice

      public BluetoothDevice getDevice()
      The remote device of this connection.