DfuBaseService
The DFU Service provides full support for Over-the-Air (OTA) Device Firmware Update (DFU) by Nordic Semiconductor. With the Soft Device 7.0.0+ it allows to upload a new Soft Device, new Bootloader and a new Application. For older soft devices only the Application update is supported.
To run the service to your application extend it in your project and overwrite the missing method. Remember to add your service class to the AndroidManifest.xml file.
The DfuServiceInitiator object should be used to start the DFU Service.
final DfuServiceInitiator starter = new DfuServiceInitiator(mSelectedDevice.getAddress())
.setDeviceName(mSelectedDevice.getName())
.setKeepBond(keepBond)
.setZip(mFileStreamUri, mFilePath) // where one, URI or path, should be null
.start(this, DfuService.class);
You may register the progress and log listeners using the DfuServiceListenerHelper helper class. See DfuProgressListener and DfuLogListener for more information.
The service will show its progress on the notification bar and will send local broadcasts to the application.
Properties
- EXTRA_DATA - the error number. Use parse to get String representation.
- EXTRA_DEVICE_ADDRESS - the target device address
- EXTRA_DATA - the progress value (percentage 0-100) or:
- EXTRA_DEVICE_ADDRESS - the target device address
- EXTRA_PART_CURRENT - the number of currently transmitted part
- EXTRA_PARTS_TOTAL - total number of parts that are being sent, e.g. if a ZIP file contains a Soft Device, a Bootloader and an Application, the SoftDevice and Bootloader will be send together as one part. Then the service will disconnect and reconnect to the new Bootloader and send the application as part number two.
- EXTRA_SPEED_B_PER_MS - current speed in bytes/millisecond as float
- EXTRA_AVG_SPEED_B_PER_MS - the average transmission speed in bytes/millisecond as float
gatt.discoverServices();
returns false.