# Class BluetoothClassic

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

public class BluetoothClassic extends Object

The classic Bluetooth (BR/EDR) role: device discovery, bonding and RFCOMM stream connections. Obtain via `Bluetooth.getInstance().getClassic()`; the instance is owned by the active port and never `null`.

Classic Bluetooth is available on Android, the JavaSE simulator and desktop targets. iOS does not expose it to applications -- branch via `Bluetooth.getInstance().isClassicSupported()`; on unsupported ports every operation fails fast with `BluetoothError.NOT_SUPPORTED`.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `BluetoothClassic()`
  Ports construct subclasses.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AsyncResource<RfcommConnection>`
  `connect(BluetoothDevice device, BluetoothUuid serviceUuid, boolean secure)`
  Opens an RFCOMM connection to the given device's service -- `BluetoothUuid.SPP` for classic serial-port devices.
  `AsyncResource<RfcommConnection>`
  `connect(String address, BluetoothUuid serviceUuid, boolean secure)`
  Opens an RFCOMM connection to the device with the given address (persisted earlier) without a prior discovery.
  `AsyncResource<Boolean>`
  `createBond(BluetoothDevice device)`
  Initiates bonding with the given device, prompting the user where the platform requires it.
  `List<BluetoothDevice>`
  `getBondedDevices()`
  The classic devices bonded with this adapter.
  `AsyncResource<RfcommServer>`
  `listen(String serviceName, BluetoothUuid serviceUuid, boolean secure)`
  Registers a listening RFCOMM endpoint (SPP server) under the given name and service UUID with the local SDP database.
  `AsyncResource<Boolean>`
  `requestDiscoverable(int durationSeconds)`
  Asks the user to make this device discoverable for the given duration (the Android system dialog).
  `ClassicDiscovery`
  `startDiscovery(ClassicDiscoveryListener listener)`
  Starts an inquiry scan (~12 seconds); the listener fires on the EDT per sighting.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### BluetoothClassic

    protected BluetoothClassic()
    Ports construct subclasses. Application code obtains the active instance via `Bluetooth.getInstance().getClassic()`.

- ## Method Details

  - ### startDiscovery

    public ClassicDiscovery startDiscovery(ClassicDiscoveryListener listener)
    Starts an inquiry scan (~12 seconds); the listener fires on the EDT per sighting. Returns a live `ClassicDiscovery` handle that resolves when the inquiry ends. On ports without classic Bluetooth the handle is already failed with `BluetoothError.NOT_SUPPORTED`.

  - ### getBondedDevices

    public List<BluetoothDevice> getBondedDevices()
    The classic devices bonded with this adapter. Empty on ports without classic Bluetooth.

  - ### createBond

    public AsyncResource<Boolean> createBond(BluetoothDevice device)
    Initiates bonding with the given device, prompting the user where the platform requires it. Resolves `true` once bonded.

  - ### requestDiscoverable

    public AsyncResource<Boolean> requestDiscoverable(int durationSeconds)
    Asks the user to make this device discoverable for the given duration (the Android system dialog). Resolves `true` when granted; `false` when declined or unsupported.

  - ### connect

    public AsyncResource<RfcommConnection> connect(BluetoothDevice device, BluetoothUuid serviceUuid, boolean secure)
    Opens an RFCOMM connection to the given device's service -- `BluetoothUuid.SPP` for classic serial-port devices. `secure` requests an authenticated, encrypted link (pairing if needed).

  - ### connect

    public AsyncResource<RfcommConnection> connect(String address, BluetoothUuid serviceUuid, boolean secure)
    Opens an RFCOMM connection to the device with the given address (persisted earlier) without a prior discovery.

  - ### listen

    public AsyncResource<RfcommServer> listen(String serviceName, BluetoothUuid serviceUuid, boolean secure)
    Registers a listening RFCOMM endpoint (SPP server) under the given name and service UUID with the local SDP database. Resolves with the `RfcommServer`; call `RfcommServer.accept()` to take clients.