0.0.9 • Published 2 years ago

capacitor-nordic-dfu v0.0.9

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

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
ParamType
optionsStartDFUOptions

Returns: any


abortDFU()

abortDFU() => any

Returns: any


addListener('dfuStateDidChange', ...)

addListener(eventName: 'dfuStateDidChange', listenerFunc: (params: { state: string; deviceAddress?: string; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
ParamType
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
ParamType
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

PropTypeDescription
filePathstringSupported Platforms: Android \ iOS
deviceAddressstringSupported Platforms: Android \ iOS
forceDfubooleanSupported Platforms: Android \ iOS
enableUnsafeExperimentalButtonlessServiceInSecureDfubooleanSupported Platforms: Android \ iOS
forceScanningForNewAddressInLegacyDfubooleanSupported Platforms: Android
disableResumebooleanSupported Platforms: Android \ iOS
foregroundbooleanSupported Platforms: Android
disableNotificationbooleanSupported Platforms: Android
dataObjectPreparationDelaynumberSupported Platforms: Android

PluginListenerHandle

PropType
remove() => any

Thanks

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago