public class BluetoothLE
- Object
- BluetoothLE
The BLE central role: scanning for peripherals and re-obtaining known
ones. Obtain via Bluetooth.getInstance().getLE(); the instance is
owned by the active port and never null – on ports without BLE it
reports every operation as unsupported.
Any number of scans may run concurrently. This base class multiplexes
them over a single platform scan: each BleScan handle only receives
advertisements matching its own ScanSettings filters, and the
platform scan stops when the last handle stops.
Constructors
protected BluetoothLE() | Ports construct subclasses. |
Methods
Inherited methods
Constructor details
BluetoothLE
protected BluetoothLE()Bluetooth.getInstance().getLE().Method details
startScan
public final BleScan startScan(ScanSettings settings, ScanListener listener)BleScan handle – keep a reference and call BleScan.stop()
when done. On ports without BLE the returned handle is already
failed with BluetoothError.NOT_SUPPORTED.getPeripheral
public BlePeripheral getPeripheral(String address)BluetoothDevice.getAddress() for the
address semantics) without scanning. Returns null when the
platform cannot resolve the address.getConnectedPeripherals
public List<BlePeripheral> getConnectedPeripherals(BluetoothUuid serviceFilter)The peripherals the system currently holds connected (e.g. paired wearables), optionally filtered to those offering the given service. Empty on ports without BLE.
iOS filters exactly (CoreBluetooth resolves services); Android can only consult its cached SDP/GATT UUIDs, so the filter is best-effort there and devices with an empty cache are retained.
getBondedPeripherals
public List<BlePeripheral> getBondedPeripherals()openGattServer
public AsyncResource<GattServer> openGattServer(GattServerListener listener)BluetoothError.NOT_SUPPORTED on ports without peripheral mode –
branch via Bluetooth.getInstance().isPeripheralModeSupported().startAdvertising
public AsyncResource<BleAdvertisement> startAdvertising(AdvertiseSettings settings, AdvertiseData data, AdvertiseData scanResponse)BleAdvertisement handle
once the platform actually started broadcasting, or fails with
BluetoothError.ADVERTISE_FAILED /
BluetoothError.NOT_SUPPORTED. scanResponse may be null.openL2capServer
public AsyncResource<L2capServer> openL2capServer(boolean secure)L2capServer.getPsm() to centrals (typically via a GATT
characteristic). Fails with BluetoothError.NOT_SUPPORTED where
L2CAP or peripheral mode is unavailable.isScanSupported
protected boolean isScanSupported()true when this port can scan; the base class returns false,
making startScan(ScanSettings, ScanListener) fail fast.startPlatformScan
protected void startPlatformScan()BleScan handle registers. Sightings are reported via
fireScanResult(ScanResult). May throw a RuntimeException to
fail the initiating handle.stopPlatformScan
protected void stopPlatformScan()onScanRegistrationsChanged
protected void onScanRegistrationsChanged()getActiveScanSettings(). Default does nothing.getActiveScanSettings
protected final List<ScanSettings> getActiveScanSettings()getAggregateScanMode
protected final ScanMode getAggregateScanMode()ScanMode among the active handles –
convenience for ports mapping the merged scan onto a platform scan
mode.fireScanResult
protected final void fireScanResult(ScanResult result)fireScanFailed
protected final void fireScanFailed(BluetoothException reason)stopPlatformScan() on this path – the
platform scan is presumed dead, so ports must clean up their own
scanner state before (or when) calling this.