Perform firmware upgrades with FirmwareUpgradeManager
mainThe FirmwareUpgradeManager is the primary class for performing firmware updates on a device. It requires an McuMgrTransport (which defines the transport scheme and the device) to be initialized.
Lifecycle and Control:
- Start: Use
start(package: McuMgrPackage)to begin an upgrade. - Control: You can
pause(),resume(), orcancel()an ongoing upgrade. - Recommendation: While you can reuse a
FirmwareUpgradeManagerandMcuMgrTransportpair for multiple operations, it is recommended to create a new pair for each DFU attempt to avoid issues.
Supported Package Formats:
.binfiles (Single-Core nRF52xxx MCUboot or Bare Metal nRF54Lxx MCUboot).suitfiles (SUIT Update).zipfiles (DirectXIP, Multi-Image MCUboot, or Multi-Image SUIT)
import iOSMcuManagerLibrary
do {
// Initialize the BLE transport using a scanned peripheral
let bleTransport = McuMgrBleTransport(cbPeripheral)
// Initialize the FirmwareUpgradeManager using the transport and a delegate
let dfuManager = FirmwareUpgradeManager(bleTransport, delegate)
let packageURL = /* Obtain URL to the file user wants to Upload */
let package = try McuMgrPackage(from: packageURL)
// Start the firmware upgrade with the given package
dfuManager.start(package: package)
} catch {
// Package initialisation errors here.
}