KableBleConnection
BleConnection implementation using Kable for cross-platform BLE communication.
Manages peripheral lifecycle, connection state tracking, and GATT service profile access.
Connection attempts follow Kable's recommended pattern from the SensorTag sample: use a direct connect when a fresh advertisement is available, then fall back to autoConnect = true on failure. Advertisement-less devices start on the autoConnect path. At most two attempts are made per connect call — the caller owns the macro-level retry/backoff loop.
Constructors
Properties
A flow of BleConnectionState changes. StateFlow semantics ensure the latest state is always observable and distinct-equals deduplication avoids spurious re-emissions.
The latest failure this connection absorbed instead of throwing since the last connect began: a rejected connect inside connectAndAwait, or a notification subscription the platform reported out of band.
Functions
Disconnects from the current device.
The GATT services discovered on the connected device, for a peripheral whose service UUID is not known ahead of time. Empty where the platform does not list them.
Clears the platform's cached GATT service table for the connected peripheral, so the next discovery re-reads the device instead of replaying the cache. Necessary when a device reboots into a different GATT profile (e.g., ESP32 OTA loader) on the same BLE MAC, and as recovery when a bonded device that was out of range for a long time reconnects against a cache the platform never refreshed.
Returns the maximum write value length for the given write type, or null if unknown.
Executes setup after the requested BLE profile is available. This is shared by radio, OTA, and DFU flows, so implementations should keep profile-entry setup bounded and avoid transfer-hot-path work here when a caller can reuse an already discovered BleService.
Asks the platform to switch to a high-throughput / low-latency BLE connection priority for the duration of the connection. Used by latency-sensitive flows like firmware updates. Returns true if the request was issued. Default implementation returns false for platforms that don't support it.