BleOtaTransport

class BleOtaTransport(scanner: BleScanner, connectionFactory: BleConnectionFactory, address: String, dispatcher: CoroutineDispatcher) : UnifiedOtaProtocol(source)

BLE transport implementation for ESP32 Unified OTA protocol using Kable.

Constructors

Link copied to clipboard
constructor(scanner: BleScanner, connectionFactory: BleConnectionFactory, address: String, dispatcher: CoroutineDispatcher)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend override fun close()

Close the connection and cleanup resources.

Link copied to clipboard
open suspend override fun connect(): Result<Unit>

Connect to the device and discover OTA service/establish connection.

Link copied to clipboard
open suspend override fun startOta(sizeBytes: Long, sha256Hash: String, onHandshakeStatus: suspend (OtaHandshakeStatus) -> Unit = {}): Result<Unit>

Start OTA update process.

Link copied to clipboard
open suspend override fun streamFirmware(data: ByteArray, chunkSize: Int, onProgress: suspend (Float) -> Unit): Result<Unit>

Streams firmware to the device. The ESP32 OTA loader is an ACK-paced byte stream: it drains its receive buffer and emits exactly ONE response per drain — an ACK while more data is expected, or the terminal OK once the final byte is received and the image verified. To keep a deterministic 1-write → 1-response cadence at any MTU, each chunk is sent as a single GATT write no larger than the negotiated write payload. A chunk that exceeded the payload would fragment into multiple writes that the device coalesces into one response, desyncing our response accounting (the cause of the prior ACK-timeout hang at MTU 512, where a 512-byte chunk split into 509, 3).