DfuUploadTransport

Common upload-time surface implemented by both SecureDfuTransport (Nordic Secure DFU, service FE59) and LegacyDfuTransport (Nordic Legacy DFU / Adafruit BLEDfu, service 1530).

The choice of which implementation to use is made by the handler after the device reboots into bootloader mode, based on which DFU service is exposed.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun abort()

Best-effort abort of any in-flight transfer (for cancellation / error recovery). Never throws.

Link copied to clipboard
abstract suspend fun close()

Disconnect and release resources.

Link copied to clipboard
abstract suspend fun connectToDfuMode(): Result<Unit>

Establish the GATT session with the device in DFU mode.

Link copied to clipboard
abstract suspend fun transferFirmware(firmware: ByteArray, onProgress: suspend (Float) -> Unit): Result<Unit>

Upload the firmware binary (.bin). onProgress is invoked with a value in [0.0, 1.0] after each protocol checkpoint (PRN window or end-of-image).

Link copied to clipboard
abstract suspend fun transferInitPacket(initPacket: ByteArray): Result<Unit>

Upload the init packet (.dat) and have the device validate it.