nordic_dfu
Fork from flutter_nordic_dfu and updated with latest dependencies, now with macOS support from version 6.0.0.
This library allows you to do a Device Firmware Update (DFU) of your nrf51 or nrf52 chip from Nordic Semiconductor. It works for Android, iOS, and MacOS.
This is the implementation of the reference "react-native-nordic-dfu"
For more info about the DFU process, see: Resources
Run example
-
Add your dfu zip file to
example/assets/file.zip -
Run example project
-
Scan device
-
Start dfu
Usage
You can pass an absolute file path or asset file to NordicDfu
Use absolute file path
await NordicDfu().startDfu(
'EB:75:AD:E3:CA:CF', '/file/to/zip/path/file.zip'
);
// With callback
await NordicDfu().startDfu(
'EB:75:AD:E3:CA:CF',
'assets/file.zip',
fileInAsset: true,
onProgressChanged: (
deviceAddress,
percent,
speed,
avgSpeed,
currentPart,
partsTotal,
) {
print('deviceAddress: $deviceAddress, percent: $percent');
},
);
Use asset file path
/// just set [fileInAsset] true
await NordicDfu().startDfu(
'EB:75:AD:E3:CA:CF', 'assets/file.zip',
fileInAsset: true,
);
Parallel DFU
Available from version 7.0.0
Concurrent DFU Processes
- DFU operations can run simultaneously on multiple devices.
- Callbacks are triggered correctly and independently for each device.
Interface change
- Updated
abortDfumethod to include an optionaladdressparameter:- If an address is provided: The DFU process for the specified device will be aborted. (iOS only)
- If no address is provided: All active DFU processes will be aborted.
- Added error handling for
abortDfu:FlutterError("INVALID_ADDRESS")is thrown if the provided address does not match any active DFU process.FlutterError("NO_ACTIVE_DFU")is thrown if no address is provided and there are no active DFU processes.
iOS
- ✅ Devices update in parallel.
- ✅ Callbacks set in
startDfuare called independently for each device. - ✅ All active DFU processes can be aborted using the
abortDfumethod without anaddress. - ✅ DFU processes can be individually aborted using the
abortDfumethod with anaddress.
Android
- ✅ Devices update in parallel (set limit of 8).
- ✅ Callbacks set in
startDfuare called independently for each device. - ✅ All active DFU processes can be aborted using the
abortDfumethod without anaddress. - ❌ DFU processes cannot be individually aborted using the
abortDfumethod with anaddressdue to current limitations in the underlying Android-DFU-Library. - ⚠️ Devices with adjacent addresses (
…:46and…:47) should be updated one after another. A device in bootloader mode advertises with its address incremented by one, so the Android-DFU-Library cannot tell such a pair apart and may report their events against the wrong device. A warning is logged when this is detected.
Address Mapping
A device performing a buttonless update reboots into its bootloader, which commonly advertises with a
different BLE address (usually the original one, last byte incremented). The plugin handles this: every
event is reported with the address you passed to startDfu, on every platform, for the whole update.
setAddressMapping, getTranslatedAddress, removeAddressMapping and clearAddressMappings are
therefore deprecated and will be removed in a future release. Delete your calls to them, along with any
bootloader scanning that existed only to feed them — no replacement is needed.
Resources
- DFU Introduction
- Secure DFU Introduction
- How to create init packet
- nRF51 Development Kit (DK) (compatible with Arduino Uno Revision 3)
- nRF52 Development Kit (DK) (compatible with Arduino Uno Revision 3)