1.5.0 • Published 2 months ago

capacitor-community-nordic-dfu v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Table of Contents

Maintainers

MaintainerGitHubActive
robsonosrobsonosyes

Installation

npm install capacitor-community-nordic-dfu
npx cap sync

Permissions

Please check the sample permissions in Android and iOS folders.

API

Defines the plugin for handling Nordic DFU processes. Includes methods to start the DFU process, check permissions, and manage event listeners.

startDFU(...)

startDFU(dfuUpdateOptions: DfuUpdateOptions) => Promise<void | PluginResultError>

Initiates the DFU process with the specified options.

ParamTypeDescription
dfuUpdateOptionsDfuUpdateOptionsOptions for the DFU process.

Returns: Promise<void | PluginResultError>

Since: 1.0.0


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Check status of permissions needed by the plugin

Returns: Promise<PermissionStatus>

Since: 1.0.0


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

Request permissions needed by the plugin

Returns: Promise<PermissionStatus>

Since: 1.0.0


addListener('DFUStateChanged', ...)

addListener(eventName: 'DFUStateChanged', handler: (update: DfuUpdate) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Listen for when the DFU state changes

ParamTypeDescription
eventName'DFUStateChanged'The name of the event to listen for
handler(update: DfuUpdate) => voidThe handler function that will be called when the event is fired

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


removeAllListeners()

removeAllListeners() => Promise<void>

Removes all listeners for the DFUStateChanged event

Since: 1.0.0


Interfaces

PluginResultError

PropType
messagestring

DfuUpdateOptions

Specifies the options required for initiating the DFU process.

PropTypeDescriptionSince
deviceAddressstringThe target device address. On Android this is the BLE MAC address. On iOS and web it is a randomly generated UUID identifier.1.0.0
deviceNamestringThe name of the device1.0.0
filePathstringThe path to the firmware file1.0.0
dfuOptionsDfuOptionsThe additional options for the DFU process1.0.0

DfuOptions

Outlines additional options for configuring the DFU process.

PropTypeDescriptionDefaultSince
disableNotificationbooleanSets whether the progress notification in the status bar should be disabled.false1.0.0
startAsForegroundServicebooleanSets whether the progress notification in the status bar should be disabled.false1.0.0
keepBondbooleanSets whether the bond information should be preserver after flashing new application.false1.0.0
restoreBondbooleanSets whether a new bond should be created after the DFU is complete. The old bond information will be removed before.false1.0.0
dataObjectDelaynumberSets the initial delay (in milliseconds) that the service will wait before sending each data object.01.0.0
packetReceiptNotificationsEnabledbooleanEnables or disables the Packet Receipt Notification (PRN) procedure. By default the PRNs are disabled on devices with Android Marshmallow or newer and enabled on older ones.1.0.0
packetsReceiptNotificationsValuenumberIf Packet Receipt Notification procedure is enabled, this method sets the number of packets to be sent before receiving a PRN.121.0.0
forceDfubooleanSetting force DFU to true will prevent from jumping to the DFU Bootloader mode in case there is no DFU Version characteristic (Legacy DFU only!). Use this if the DFU operation can be handled by your device running in the application mode. This method is ignored in Secure DFU.false1.0.0
rebootTimenumberSets the time (in milliseconds) required by the device to reboot. The library will wait for this time before scanning for the device in bootloader mode.01.0.0
scanTimeoutnumberSets the scan duration (in milliseconds) when scanning for DFU Bootloader.50001.0.0
forceScanningForNewAddressInLegacyDfubooleanWhen 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.false1.0.0
disableResumebooleanThis options allows to disable the resume feature in Secure DFU. When the extra value is set to true, the DFU will send Init Packet and Data again, despite the firmware might have been send partially before. By default, without setting this extra, or by setting it to false, the DFU will resume the previously cancelled upload if CRC values match.false1.4.0
numberOfRetriesnumberSets the number of retries that the DFU service will use to complete DFU.01.0.0
mtunumberSets the Maximum Transfer Unit (MTU) value that the Secure DFU service will try to request before performing DFU. Available for Android only. By default, value 517 will be used, which is the highest supported y Android. However, as the highest supported MTU by the Secure DFU from SDK 15 (first which supports higher MTU) is 247, the sides will agree on using MTU = 247 instead if the phone supports it (Lollipop or newer device).1.0.0
currentMtunumberSets the current MTU value. This method should be used only if the device is already connected and MTU has been requested before DFU service is started. Available for Android only.231.0.0
disableMtuRequestbooleanDisables MTU request. Available for Android only.false1.4.0
scopenumberThis 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. System components scope include the Softdevice and/or the Bootloader (they can't be separated as they are packed in a single bin file and the library does not know whether it contains only the softdevice, the bootloader or both) Application scope includes the application only.1.0.0
mbrSizenumberThis method sets the size of an MBR (Master Boot Record). It should be used only when updating a file from a HEX file. If you use BIN or ZIP, value set here will be ignored.40961.0.0
unsafeExperimentalButtonlessServiceInSecureDfuEnabledbooleanSet this flag to true to enable experimental buttonless feature in Secure DFU. When the experimental Buttonless DFU Service is found on a device, the service will use it to switch the device to the bootloader mode, connect to it in that mode and proceed with DFU.false1.0.0

PermissionStatus

Represents the current status of permissions in the plugin.

PropTypeDescriptionSince
notificationsPermissionStateIndicates the permission state of notifications.1.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

DfuUpdate

The DFU update object that is passed to the DFUStateChanged event

PropTypeDescriptionSince
stateDfuStateDefines the structure for the DFU update object passed to the DFUStateChanged event.1.0.0
dataDfuUpdateDataThe DFU data that is passed to the DfuUpdate object1.0.0

DfuUpdateData

Contains data related to the DFU update process, such as progress and speed.

PropTypeDescriptionSince
percentnumberThe current status of upload (0-99).1.0.0
speednumberThe current speed in bytes per millisecond.1.0.0
avgSpeednumberThe average speed in bytes per millisecond.1.0.0
currentPartnumberThe number of parts being sent. In case the ZIP file contains a Soft Device and/or a Bootloader together with the application the SD+BL are sent as part 1, then the service starts again and send the application as part 2.1.0.0
partsTotalnumberThe total number of parts.1.0.0
durationnumberThe total time elapsed since the start of the DFU process in milliseconds1.1.0
remainingTimenumberThe estimated remaining time to the end of the DFU process in milliseconds1.1.0

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

Enums

DfuState

MembersValueDescriptionSince
DEVICE_CONNECTING'DEVICE_CONNECTING'The device is currently connecting.1.0.0
DEVICE_CONNECTED'DEVICE_CONNECTED'The device has successfully connected. Available for Android only.1.0.0
DFU_PROCESS_STARTING'DFU_PROCESS_STARTING'The DFU process is about to start.1.0.0
DFU_PROCESS_STARTED'DFU_PROCESS_STARTED'The DFU process has started. Available for Android only.1.0.0
ENABLING_DFU_MODE'ENABLING_DFU_MODE'The device is enabling DFU mode.1.0.0
DFU_PROGRESS'DFU_PROGRESS'The DFU process is in progress.1.0.0
VALIDATING_FIRMWARE'VALIDATING_FIRMWARE'The firmware is currently being validated.1.0.0
DEVICE_DISCONNECTING'DEVICE_DISCONNECTING'The device is disconnecting.1.0.0
DEVICE_DISCONNECTED'DEVICE_DISCONNECTED'The device has disconnected. Available for Android only.1.0.0
DFU_COMPLETED'DFU_COMPLETED'The DFU process has completed successfully.1.0.0
DFU_ABORTED'DFU_ABORTED'The DFU process has been aborted.1.0.0
DFU_FAILED'DFU_FAILED'The DFU process has failed.1.0.0

Contributors

1.5.0

2 months ago

1.4.0

4 months ago

1.3.0

4 months ago

1.2.0

5 months ago

1.1.0

5 months ago

1.2.1

5 months ago

1.0.0

6 months ago