Capacitor Plugin is a Wrapper to use Nordic Semiconductor's Device Firmware Update (DFU) service to update a Bluetooth LE device.
npm install capacitor-nordic-dfu
npx cap sync
After installation, the following additions should be made to the app's Info.plist
- Set NSBluetoothAlwaysUsageDescription to a descriptive text, to be shown to the user on first access to the Bluetooth adapter. If this is not defined the app will crash.
After installation, the following permissions be added to your AndroidManifest.xml
:
<!-- required for API 18 - 30 -->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<!-- required for API 23 - 30 -->
<uses-permission-sdk-23
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="30" />
<uses-permission-sdk-23
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="30" />
<!-- API 31+ -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- add android:usesPermissionFlags="neverForLocation" when you can strongly assert that
your app never derives physical location from Bluetooth scan results. -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
startDFU(...)
abortDFU()
addListener('dfuStateDidChange', ...)
addListener('dfuProgressDidChange', ...)
removeAllListeners()
- Interfaces
startDFU(options: StartDFUOptions) => any
Param | Type |
---|---|
options |
StartDFUOptions |
Returns: any
abortDFU() => any
Returns: any
addListener(eventName: 'dfuStateDidChange', listenerFunc: (params: { state: string; deviceAddress?: string; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'dfuStateDidChange' |
listenerFunc |
(params: { state: string; deviceAddress?: string; }) => void |
Returns: any
addListener(eventName: 'dfuProgressDidChange', listenerFunc: (params: { percent: number; speed: number; avgSpeed: number; currentPart: number; partsTotal: number; deviceAddress?: string; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'dfuProgressDidChange' |
listenerFunc |
(params: { percent: number; speed: number; avgSpeed: number; currentPart: number; partsTotal: number; deviceAddress?: string; }) => void |
Returns: any
removeAllListeners() => any
Returns: any
Prop | Type | Description |
---|---|---|
filePath |
string |
Supported Platforms: Android \ iOS |
deviceAddress |
string |
Supported Platforms: Android \ iOS |
forceDfu |
boolean |
Supported Platforms: Android \ iOS |
enableUnsafeExperimentalButtonlessServiceInSecureDfu |
boolean |
Supported Platforms: Android \ iOS |
forceScanningForNewAddressInLegacyDfu |
boolean |
Supported Platforms: Android |
disableResume |
boolean |
Supported Platforms: Android \ iOS |
foreground |
boolean |
Supported Platforms: Android |
disableNotification |
boolean |
Supported Platforms: Android |
dataObjectPreparationDelay |
number |
Supported Platforms: Android |
Prop | Type |
---|---|
remove |
() => any |