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

Properties

Link copied to clipboard

True once connected if the bootloader can only transfer in small (≤20-byte) blocks — i.e. it did not negotiate a larger ATT MTU. Used to surface a "slow bootloader" advisory to the user. Valid after connectToDfuMode.

Functions

Link copied to clipboard
abstract suspend fun abort()

Best-effort abort. Operational transport exceptions are swallowed; structured-concurrency cancellation and Error subtypes propagate.

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).

open suspend fun transferFirmware(firmware: ByteArray, onPhase: suspend (DfuUploadPhase) -> Unit, onProgress: suspend (Float) -> Unit): Result<Unit>

As transferFirmware, additionally reporting coarse DfuUploadPhase transitions so the UI can explain a wait that produces no progress (Legacy DFU erases the whole application region before it accepts a single byte). Transports without a meaningful prepare step keep the default, which never reports a phase.

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

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