Class BluetoothClassic
java.lang.Object
com.codename1.bluetooth.classic.BluetoothClassic
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 -
Method Summary
Modifier and TypeMethodDescriptionconnect(BluetoothDevice device, BluetoothUuid serviceUuid, boolean secure) Opens an RFCOMM connection to the given device's service --BluetoothUuid.SPPfor classic serial-port devices.connect(String address, BluetoothUuid serviceUuid, boolean secure) Opens an RFCOMM connection to the device with the given address (persisted earlier) without a prior discovery.createBond(BluetoothDevice device) Initiates bonding with the given device, prompting the user where the platform requires it.The classic devices bonded with this adapter.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.requestDiscoverable(int durationSeconds) Asks the user to make this device discoverable for the given duration (the Android system dialog).startDiscovery(ClassicDiscoveryListener listener) Starts an inquiry scan (~12 seconds); the listener fires on the EDT per sighting.
-
Constructor Details
-
BluetoothClassic
protected BluetoothClassic()Ports construct subclasses. Application code obtains the active instance viaBluetooth.getInstance().getClassic().
-
-
Method Details
-
startDiscovery
Starts an inquiry scan (~12 seconds); the listener fires on the EDT per sighting. Returns a liveClassicDiscoveryhandle that resolves when the inquiry ends. On ports without classic Bluetooth the handle is already failed withBluetoothError.NOT_SUPPORTED. -
getBondedDevices
The classic devices bonded with this adapter. Empty on ports without classic Bluetooth. -
createBond
Initiates bonding with the given device, prompting the user where the platform requires it. Resolvestrueonce bonded. -
requestDiscoverable
Asks the user to make this device discoverable for the given duration (the Android system dialog). Resolvestruewhen granted;falsewhen 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.SPPfor classic serial-port devices.securerequests 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 theRfcommServer; callRfcommServer.accept()to take clients.
-