Class HelperBleBackend
- All Implemented Interfaces:
BleBackend
The real-radio BleBackend: drives the host machine's Bluetooth
adapter through the bundled cn1-ble-helper subprocess (a Rust
btleplug bridge --
CoreBluetooth on macOS, BlueZ on Linux, WinRT on Windows). Commands and
events travel as line-delimited JSON over the helper's stdin/stdout; see
Ports/JavaSE/native/cn1-ble-helper/PROTOCOL.md.
This class is transport-agnostic: the child process's standard I/O is
reached only through a HelperTransport created by the injected
HelperTransportFactory, so a host with an operating-system process
API (the JavaSE simulator) and a host without it (the native Windows/Linux
ports, reaching the subprocess through a native bridge) share this exact
protocol, GATT and lifecycle logic. Nothing here references an OS process
API or a shutdown hook -- the owner calls shutdown() on app
exit.
btleplug is central-only: LE scanning and GATT client operations are
supported; peripheral mode (GATT server / advertising), classic
Bluetooth, L2CAP channels and bonding are not, and the corresponding
capability queries report false.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCompletion of one in-flight helper command.Nested classes/interfaces inherited from interface BleBackend
BleBackend.AdapterStateSink, BleBackend.ScanSink -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHelperBleBackend(HelperTransportFactory transportFactory) Creates a backend that (re)starts the helper through the given transport factory. -
Method Summary
Modifier and TypeMethodDescriptiongetConnectedPeripherals(BluetoothUuid serviceFilter) getName()A stable identifier, e.g.getPeripheral(String address) The canonical peripheral at the address, ornull.booleanhelperSupports(String capability) True when the helper's capability handshake advertises the key.booleanbooleanbooleanbooleanstatic AdapterStatemapAdapterState(String state) static BluetoothErrormapErrorCode(String code) openGattServer(GattServerListener listener) openL2capServer(boolean secure) voidRegisters the single adapter-state observer (the port owner).voidshutdown()Releases backend resources when it is switched away.startAdvertising(AdvertiseSettings settings, AdvertiseData data, AdvertiseData scanResponse) voidstartScan(BleBackend.ScanSink sink) Starts the single platform scan; sightings flow into the sink.voidstopScan()Stops the platform scan.
-
Field Details
-
NAME
-
PROTOCOL_VERSION
public static final long PROTOCOL_VERSIONThe wire protocol version this backend speaks.- See Also:
-
-
Constructor Details
-
HelperBleBackend
Creates a backend that (re)starts the helper through the given transport factory. The factory is responsible for how the child process is launched -- resolving the binary and, on the JavaSE simulator, building the OS subprocess.
-
-
Method Details
-
mapAdapterState
-
mapErrorCode
-
helperSupports
True when the helper's capability handshake advertises the key. -
getName
Description copied from interface:BleBackendA stable identifier, e.g."simulator"or"native".- Specified by:
getNamein interfaceBleBackend
-
isLeSupported
public boolean isLeSupported()- Specified by:
isLeSupportedin interfaceBleBackend
-
isPeripheralModeSupported
public boolean isPeripheralModeSupported()- Specified by:
isPeripheralModeSupportedin interfaceBleBackend
-
isClassicSupported
public boolean isClassicSupported()- Specified by:
isClassicSupportedin interfaceBleBackend
-
isL2capSupported
public boolean isL2capSupported()- Specified by:
isL2capSupportedin interfaceBleBackend
-
getAdapterState
- Specified by:
getAdapterStatein interfaceBleBackend
-
setAdapterStateSink
Description copied from interface:BleBackendRegisters the single adapter-state observer (the port owner).- Specified by:
setAdapterStateSinkin interfaceBleBackend
-
startScan
Description copied from interface:BleBackendStarts the single platform scan; sightings flow into the sink.- Specified by:
startScanin interfaceBleBackend
-
stopScan
public void stopScan()Description copied from interface:BleBackendStops the platform scan.- Specified by:
stopScanin interfaceBleBackend
-
getPeripheral
Description copied from interface:BleBackendThe canonical peripheral at the address, ornull.- Specified by:
getPeripheralin interfaceBleBackend
-
getConnectedPeripherals
- Specified by:
getConnectedPeripheralsin interfaceBleBackend
-
getBondedPeripherals
- Specified by:
getBondedPeripheralsin interfaceBleBackend
-
openGattServer
- Specified by:
openGattServerin interfaceBleBackend
-
startAdvertising
public AsyncResource<BleAdvertisement> startAdvertising(AdvertiseSettings settings, AdvertiseData data, AdvertiseData scanResponse) - Specified by:
startAdvertisingin interfaceBleBackend
-
openL2capServer
- Specified by:
openL2capServerin interfaceBleBackend
-
shutdown
public void shutdown()Description copied from interface:BleBackendReleases backend resources when it is switched away.- Specified by:
shutdownin interfaceBleBackend
-