LegacyDfuTransport

class LegacyDfuTransport(scanner: BleScanner, connectionFactory: BleConnectionFactory, address: String, dispatcher: CoroutineDispatcher) : DfuUploadTransport(source)

Kable-based transport for the Nordic Legacy DFU protocol (Nordic SDK 11/12 / Adafruit BLEDfu).

Most nRF52 boards in the field — including the RAK4631 with the recommended Adafruit/oltaco "OTAFIX" bootloader — speak Legacy DFU rather than Secure DFU. The two protocols share nothing at the upload layer:

  • Different service & characteristic UUIDs (1530/1531/1532 vs FE59/8EC9…).

  • Different opcodes; init packet is sent on the Packet char between two control-point writes (vs Secure's CREATE/PACKET/EXECUTE object flow).

  • PRN payload is bytes-received uint32 (vs Secure's offset+CRC32).

  • No CRC32 in the protocol — image integrity relies on the device's CRC16 in the init packet.

Phase-1 buttonless trigger is shared with SecureDfuTransport (see triggerButtonlessDfu there).

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 abort()

Send RESET to the device, instructing it to discard any in-progress transfer and reboot. Best-effort — the device may disconnect before the write ACK lands; that's expected.

Link copied to clipboard
open suspend override fun close()

Disconnect and release resources.

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

Scans for the device in DFU mode (address or address+1) and establishes the GATT connection, enabling notifications on the Control Point.

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

Drives the full upload sequence (START, init-packet brackets, PRN setup, firmware stream, validate, activate).

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

Sends the legacy DFU init packet using the SDK 7+ extended-init flow: