DfuServiceInitiator
class DfuServiceInitiator
A helper class for starting a DFU process on a remote device supporting Legacy or Secure DFU services from nRF5 SDK.
Starting a DFU Service service requires a knowledge of some EXTRA_*
constants used to pass parameters to the service. The DfuServiceInitiator
class may be used to make this process easier. It provides simple API that covers all low lever operations.
How to use it
final DfuServiceController controller = new DfuServiceInitiator(mSelectedDevice.getAddress())
.setDeviceName(mSelectedDevice.getName())
.setKeepBond(true)
.setZip(mFileStreamUri)
.start(this, DfuService.class);
Content copied to clipboard
To upgrade devices with an old versions of DFU Bootloader it may be necessary to enable package receipt notifications (PRNs) using setPacketsReceiptNotificationsEnabled and set the value to 6 or lower using setPacketsReceiptNotificationsValue. This will slow down the upload, but will make it more reliable.
Properties
Link copied to clipboard
The default maximum size of the data block.
Link copied to clipboard
The default packet receipt notification value.
Link copied to clipboard
The default scan timeout in milliseconds.
Link copied to clipboard
Constant used to narrow the scope of the update to application only.
Link copied to clipboard
Constant used to narrow the scope of the update to system components (SD+BL) only.
Functions
Link copied to clipboard
Creates a notification channel for the DFU service with default name and description.
open fun createDfuNotificationChannel(@NonNull context: Context, @NonNull dfu_channel_name: String, @NonNull dfu_channel_description: String, showBadge: Boolean)
Creates a notification channel for the DFU service.
Link copied to clipboard
Disables MTU request.
Link copied to clipboard
This options allows to disable the resume feature in Secure DFU.
Link copied to clipboard
Sets the URI of the BIN or HEX file containing the new firmware.
Sets the resource ID pointing the BIN or HEX file containing the new firmware.
open fun setBinOrHex(fileType: Int, @Nullable uri: Uri, @Nullable path: String): DfuServiceInitiator
Sets the URI or path to the BIN or HEX file containing the new firmware.
Link copied to clipboard
Sets the current MTU value.
Link copied to clipboard
open fun setCustomUuidsForButtonlessDfuWithBondSharing(@Nullable buttonlessDfuServiceUuid: UUID, @Nullable buttonlessDfuControlPointUuid: UUID): DfuServiceInitiator
Sets custom UUIDs for the Buttonless DFU Service from SDK 14 (or later).
Link copied to clipboard
open fun setCustomUuidsForButtonlessDfuWithoutBondSharing(@Nullable buttonlessDfuServiceUuid: UUID, @Nullable buttonlessDfuControlPointUuid: UUID): DfuServiceInitiator
Sets custom UUIDs for the Buttonless DFU Service from SDK 13.
Link copied to clipboard
open fun setCustomUuidsForExperimentalButtonlessDfu(@Nullable buttonlessDfuServiceUuid: UUID, @Nullable buttonlessDfuControlPointUuid: UUID): DfuServiceInitiator
Sets custom UUIDs for the experimental Buttonless DFU Service from SDK 12.x.
Link copied to clipboard
open fun setCustomUuidsForLegacyDfu(@Nullable dfuServiceUuid: UUID, @Nullable dfuControlPointUuid: UUID, @Nullable dfuPacketUuid: UUID, @Nullable dfuVersionUuid: UUID): DfuServiceInitiator
Sets custom UUIDs for Legacy DFU and Legacy Buttonless DFU.
Link copied to clipboard
open fun setCustomUuidsForSecureDfu(@Nullable dfuServiceUuid: UUID, @Nullable dfuControlPointUuid: UUID, @Nullable dfuPacketUuid: UUID): DfuServiceInitiator
Sets custom UUIDs for Secure DFU.
Link copied to clipboard
Sets the device name.
Link copied to clipboard
Sets whether the progress notification in the status bar should be disabled.
Link copied to clipboard
Setting force DFU to true will prevent from jumping to the DFU Bootloader mode in case there is no DFU Version characteristic (Legacy DFU only!).
Link copied to clipboard
When this is set to true, the Legacy Buttonless Service will scan for the device advertising with an incremented MAC address, instead of trying to reconnect to the same device.
Link copied to clipboard
Sets whether the DFU service should be started as a foreground service.
Link copied to clipboard
Sets the URI of the Init file.
Sets the resource ID of the Init file.
Sets the path to the Init file.
open fun setInitFile(@Nullable initFileUri: Uri, @Nullable initFilePath: String): DfuServiceInitiator
Sets the URI or path to the Init file.
Link copied to clipboard
Sets whether the bond information should be preserver after flashing new application.
Link copied to clipboard
This method sets the size of an MBR (Master Boot Record).
Link copied to clipboard
Sets the Maximum Transfer Unit (MTU) value that the Secure DFU service will try to request before performing DFU.
Link copied to clipboard
Sets the number of retries that the DFU service will use to complete DFU.
Link copied to clipboard
Enables or disables the Packet Receipt Notification (PRN) procedure.
Link copied to clipboard
If Packet Receipt Notification procedure is enabled, this method sets number of packets to be sent before receiving a PRN.
Link copied to clipboard
This method sets the duration of a delay, that the service will wait before sending each data object in Secure DFU.
Link copied to clipboard
Sets the time required by the device to reboot.
Link copied to clipboard
Sets whether a new bond should be created after the DFU is complete.
Link copied to clipboard
Sets the scan duration (in milliseconds) when scanning for DFU Bootloader.
Link copied to clipboard
This method allows to narrow the update to selected parts from the ZIP, for example to allow only application update from a ZIP file that has SD+BL+App.
Link copied to clipboard
open fun setUnsafeExperimentalButtonlessServiceInSecureDfuEnabled(enable: Boolean): DfuServiceInitiator
Set this flag to true to enable experimental buttonless feature in Secure DFU.
Link copied to clipboard
Sets the URI to the Distribution packet (ZIP) or to a ZIP file matching the deprecated naming convention.
Sets the resource ID of the Distribution packet (ZIP) or the a ZIP file matching the deprecated naming convention.
Sets the path to the Distribution packet (ZIP) or the a ZIP file matching the deprecated naming convention.
Sets the URI or path of the ZIP file.
Link copied to clipboard
open fun start(@NonNull context: Context, @NonNull service: Class<out DfuBaseService>): DfuServiceController
Starts the DFU service.