Class HelperBluetooth
java.lang.Object
com.codename1.bluetooth.Bluetooth
com.codename1.bluetooth.helper.HelperBluetooth
A Bluetooth entry point backed by the cn1-ble-helper subprocess --
the shared implementation for the native Win32 and Linux desktop ports.
Those ports have no java.lang.ProcessBuilder, so they pass a
HelperTransportFactory built on their native process bridge (see
NativeSubprocessTransport); this class wires it into a
HelperBleBackend and exposes real BLE central (scan / connect / GATT
client / notifications). btleplug -- the helper's backend -- is
central-only, so peripheral mode, L2CAP and classic Bluetooth report
unsupported.
A port creates one instance in its getBluetooth() and calls
shutdown() on app exit.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe current state of the local adapter.getLE()The BLE central role entry point -- scanning, connections, GATT client.booleanhasPermission(BluetoothPermission permission) Desktop Linux/Windows have no app-level runtime Bluetooth permission (access is governed by the OS/user session), so permissions are reported granted and requests resolvetrue.booleantruewhen classic Bluetooth (discovery, RFCOMM) is available.booleantruewhen L2CAP connection-oriented channels are available (Android 10+, iOS 11+).booleantruewhen the BLE central role (scanning, connections, GATT client) is available.booleantruewhen the BLE peripheral role (advertising and a local GATT server) is available.booleantruewhen this port/device exposes any Bluetooth functionality at all.There is no programmatic adapter-enable on the desktop helper path; resolvestruewhen the adapter is already powered on, elsefalse.requestPermissions(BluetoothPermission... permissions) Requests the given runtime permissions, prompting the user where needed.voidshutdown()Tears down the helper subprocess.Methods inherited from class Bluetooth
addAdapterStateListener, fireAdapterStateChanged, getClassic, getInstance, isEnabled, removeAdapterStateListener
-
Constructor Details
-
HelperBluetooth
-
-
Method Details
-
isSupported
public boolean isSupported()Description copied from class:Bluetoothtruewhen this port/device exposes any Bluetooth functionality at all. Returnsfalseon the fallback base class.- Overrides:
isSupportedin classBluetooth
-
isLeSupported
public boolean isLeSupported()Description copied from class:Bluetoothtruewhen the BLE central role (scanning, connections, GATT client) is available. Defaults tofalse.- Overrides:
isLeSupportedin classBluetooth
-
isClassicSupported
public boolean isClassicSupported()Description copied from class:Bluetoothtruewhen classic Bluetooth (discovery, RFCOMM) is available. Alwaysfalseon iOS, which does not expose classic Bluetooth to apps. Defaults tofalse.- Overrides:
isClassicSupportedin classBluetooth
-
isPeripheralModeSupported
public boolean isPeripheralModeSupported()Description copied from class:Bluetoothtruewhen the BLE peripheral role (advertising and a local GATT server) is available.falseon tvOS/watchOS and on the JavaScript port. Defaults tofalse.- Overrides:
isPeripheralModeSupportedin classBluetooth
-
isL2capSupported
public boolean isL2capSupported()Description copied from class:Bluetoothtruewhen L2CAP connection-oriented channels are available (Android 10+, iOS 11+). Defaults tofalse.- Overrides:
isL2capSupportedin classBluetooth
-
getAdapterState
Description copied from class:BluetoothThe current state of the local adapter. The fallback base class reportsAdapterState.UNSUPPORTED.- Overrides:
getAdapterStatein classBluetooth
-
getLE
Description copied from class:BluetoothThe BLE central role entry point -- scanning, connections, GATT client. Nevernull: on ports without BLE a no-op instance is returned whose operations fail fast withBluetoothError.NOT_SUPPORTED; branch viaBluetooth.isLeSupported(). -
hasPermission
Desktop Linux/Windows have no app-level runtime Bluetooth permission (access is governed by the OS/user session), so permissions are reported granted and requests resolvetrue.- Overrides:
hasPermissionin classBluetooth
-
requestPermissions
Description copied from class:BluetoothRequests the given runtime permissions, prompting the user where needed. Resolvestruewhen every requested permission is granted. Resolvesfalse(rather than failing) when denied or when the platform has no Bluetooth support at all.- Overrides:
requestPermissionsin classBluetooth
-
requestEnable
There is no programmatic adapter-enable on the desktop helper path; resolvestruewhen the adapter is already powered on, elsefalse.- Overrides:
requestEnablein classBluetooth
-
shutdown
public void shutdown()Tears down the helper subprocess. Call from the port on app exit.
-