# Class HelperBleBackend

java.lang.Object
com.codename1.bluetooth.helper.HelperBleBackend

All Implemented Interfaces:
  `BleBackend`

public class HelperBleBackend extends Object implements 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 Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `HelperBleBackend.PendingOp`
  Completion of one in-flight helper command.

  ### Nested classes/interfaces inherited from interface BleBackend

  `BleBackend.AdapterStateSink, BleBackend.ScanSink`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `NAME`
  The backend name reported by `getName()`.
  `static final long`
  `PROTOCOL_VERSION`
  The wire protocol version this backend speaks.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HelperBleBackend(HelperTransportFactory transportFactory)`
  Creates a backend that (re)starts the helper through the given transport factory.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AdapterState`
  `getAdapterState()`
  `List<BlePeripheral>`
  `getBondedPeripherals()`
  `List<BlePeripheral>`
  `getConnectedPeripherals(BluetoothUuid serviceFilter)`
  `String`
  `getName()`
  A stable identifier, e.g.
  `BlePeripheral`
  `getPeripheral(String address)`
  The canonical peripheral at the address, or `null`.
  `boolean`
  `helperSupports(String capability)`
  True when the helper's capability handshake advertises the key.
  `boolean`
  `isClassicSupported()`
  `boolean`
  `isL2capSupported()`
  `boolean`
  `isLeSupported()`
  `boolean`
  `isPeripheralModeSupported()`
  `static AdapterState`
  `mapAdapterState(String state)`
  `static BluetoothError`
  `mapErrorCode(String code)`
  `AsyncResource<GattServer>`
  `openGattServer(GattServerListener listener)`
  `AsyncResource<L2capServer>`
  `openL2capServer(boolean secure)`
  `void`
  `setAdapterStateSink(BleBackend.AdapterStateSink sink)`
  Registers the single adapter-state observer (the port owner).
  `void`
  `shutdown()`
  Releases backend resources when it is switched away.
  `AsyncResource<BleAdvertisement>`
  `startAdvertising(AdvertiseSettings settings, AdvertiseData data, AdvertiseData scanResponse)`
  `void`
  `startScan(BleBackend.ScanSink sink)`
  Starts the single platform scan; sightings flow into the sink.
  `void`
  `stopScan()`
  Stops the platform scan.

  ### Methods inherited from class Object

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

- ## Field Details

  - ### NAME

    public static final String NAME
    The backend name reported by `getName()`.
    See Also:
      - Constant Field Values

  - ### PROTOCOL_VERSION

    public static final long PROTOCOL_VERSION
    The wire protocol version this backend speaks.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### HelperBleBackend

    public HelperBleBackend(HelperTransportFactory transportFactory)
    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

    public static AdapterState mapAdapterState(String state)

  - ### mapErrorCode

    public static BluetoothError mapErrorCode(String code)

  - ### helperSupports

    public boolean helperSupports(String capability)
    True when the helper's capability handshake advertises the key.

  - ### getName

    public String getName()
    Description copied from interface: `BleBackend`
    A stable identifier, e.g. `"simulator"` or `"native"`.
    Specified by:
      `getName` in interface `BleBackend`

  - ### isLeSupported

    public boolean isLeSupported()
    Specified by:
      `isLeSupported` in interface `BleBackend`

  - ### isPeripheralModeSupported

    public boolean isPeripheralModeSupported()
    Specified by:
      `isPeripheralModeSupported` in interface `BleBackend`

  - ### isClassicSupported

    public boolean isClassicSupported()
    Specified by:
      `isClassicSupported` in interface `BleBackend`

  - ### isL2capSupported

    public boolean isL2capSupported()
    Specified by:
      `isL2capSupported` in interface `BleBackend`

  - ### getAdapterState

    public AdapterState getAdapterState()
    Specified by:
      `getAdapterState` in interface `BleBackend`

  - ### setAdapterStateSink

    public void setAdapterStateSink(BleBackend.AdapterStateSink sink)
    Description copied from interface: `BleBackend`
    Registers the single adapter-state observer (the port owner).
    Specified by:
      `setAdapterStateSink` in interface `BleBackend`

  - ### startScan

    public void startScan(BleBackend.ScanSink sink)
    Description copied from interface: `BleBackend`
    Starts the single platform scan; sightings flow into the sink.
    Specified by:
      `startScan` in interface `BleBackend`

  - ### stopScan

    public void stopScan()
    Description copied from interface: `BleBackend`
    Stops the platform scan.
    Specified by:
      `stopScan` in interface `BleBackend`

  - ### getPeripheral

    public BlePeripheral getPeripheral(String address)
    Description copied from interface: `BleBackend`
    The canonical peripheral at the address, or `null`.
    Specified by:
      `getPeripheral` in interface `BleBackend`

  - ### getConnectedPeripherals

    public List<BlePeripheral> getConnectedPeripherals(BluetoothUuid serviceFilter)
    Specified by:
      `getConnectedPeripherals` in interface `BleBackend`

  - ### getBondedPeripherals

    public List<BlePeripheral> getBondedPeripherals()
    Specified by:
      `getBondedPeripherals` in interface `BleBackend`

  - ### openGattServer

    public AsyncResource<GattServer> openGattServer(GattServerListener listener)
    Specified by:
      `openGattServer` in interface `BleBackend`

  - ### startAdvertising

    public AsyncResource<BleAdvertisement> startAdvertising(AdvertiseSettings settings, AdvertiseData data, AdvertiseData scanResponse)
    Specified by:
      `startAdvertising` in interface `BleBackend`

  - ### openL2capServer

    public AsyncResource<L2capServer> openL2capServer(boolean secure)
    Specified by:
      `openL2capServer` in interface `BleBackend`

  - ### shutdown

    public void shutdown()
    Description copied from interface: `BleBackend`
    Releases backend resources when it is switched away.
    Specified by:
      `shutdown` in interface `BleBackend`