SecureDfuHandler

class SecureDfuHandler(firmwareRetriever: FirmwareRetriever, firmwareFileHandler: FirmwareFileHandler, radioController: RadioController, bleScanner: BleScanner, bleConnectionFactory: BleConnectionFactory, dispatchers: CoroutineDispatchers) : FirmwareUpdateHandler(source)

KMP FirmwareUpdateHandler for nRF52 devices.

Despite its historical name, this handler now drives both Nordic Secure DFU (service FE59) and Nordic Legacy DFU / Adafruit BLEDfu (service 1530). After triggering the buttonless reboot it sniffs which DFU service the bootloader exposes and dispatches to the matching DfuUploadTransport implementation.

All platform I/O (zip extraction, file reading) is delegated to FirmwareFileHandler.

Constructors

Link copied to clipboard
constructor(firmwareRetriever: FirmwareRetriever, firmwareFileHandler: FirmwareFileHandler, radioController: RadioController, bleScanner: BleScanner, bleConnectionFactory: BleConnectionFactory, dispatchers: CoroutineDispatchers)

Functions

Link copied to clipboard
open suspend override fun startUpdate(release: FirmwareRelease, hardware: DeviceHardware, target: String, updateState: (FirmwareUpdateState) -> Unit, firmwareUri: CommonUri? = null): FirmwareArtifact?

Start the firmware update process.

Link copied to clipboard
suspend fun upgradeBootloader(release: FirmwareRelease, hardware: DeviceHardware, target: String, asset: BootloaderDfuZip, updateState: (FirmwareUpdateState) -> Unit): FirmwareArtifact?

Installs asset's SoftDevice and bootloader over Legacy DFU, waits out the bootloader's own swap, then reinstalls release's application, which staging the new images erased. Both packages are downloaded and checked before the device leaves its application, and nothing is written unless the bootloader's DIS reports the board and SoftDevice asset was built for.