Skip to content

πŸš€ Capacitor Plugin is a Wrapper to use Nordic Semiconductor's Device Firmware Update (DFU) service to update a Bluetooth LE device.

License

Notifications You must be signed in to change notification settings

arklnk/capacitor-nordic-dfu

Repository files navigation

capacitor-nordic-dfu

npm

Capacitor Plugin is a Wrapper to use Nordic Semiconductor's Device Firmware Update (DFU) service to update a Bluetooth LE device.

Install

npm install capacitor-nordic-dfu
npx cap sync

iOS

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.

Android

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" />

API

startDFU(...)

startDFU(options: StartDFUOptions) => any
Param Type
options StartDFUOptions

Returns: any


abortDFU()

abortDFU() => any

Returns: any


addListener('dfuStateDidChange', ...)

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('dfuProgressDidChange', ...)

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()

removeAllListeners() => any

Returns: any


Interfaces

StartDFUOptions

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

PluginListenerHandle

Prop Type
remove () => any

Thanks

About

πŸš€ Capacitor Plugin is a Wrapper to use Nordic Semiconductor's Device Firmware Update (DFU) service to update a Bluetooth LE device.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published