@microbit/capacitor-community-nordic-dfu 7.0.0-microbit.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,435 @@
1
+ import type { PluginListenerHandle, PluginResultError, PermissionState } from '@capacitor/core';
2
+ /**
3
+ * Represents the current status of permissions in the plugin.
4
+ *
5
+ * @since 1.0.0
6
+ */
7
+ export interface PermissionStatus {
8
+ /**
9
+ * Indicates the permission state of notifications.
10
+ *
11
+ * @since 1.0.0
12
+ */
13
+ notifications: PermissionState;
14
+ }
15
+ /**
16
+ * Enumerates the various states in the DFU process. This helps in tracking the progress and status of the
17
+ * firmware update.
18
+ *
19
+ * @since 1.0.0
20
+ */
21
+ export declare enum DfuState {
22
+ /**
23
+ * The device is currently connecting.
24
+ *
25
+ * @since 1.0.0
26
+ */
27
+ DEVICE_CONNECTING = "DEVICE_CONNECTING",
28
+ /**
29
+ * The device has successfully connected. **Available for Android only.**
30
+ *
31
+ * @since 1.0.0
32
+ */
33
+ DEVICE_CONNECTED = "DEVICE_CONNECTED",
34
+ /**
35
+ * The DFU process is about to start.
36
+ *
37
+ * @since 1.0.0
38
+ */
39
+ DFU_PROCESS_STARTING = "DFU_PROCESS_STARTING",
40
+ /**
41
+ * The DFU process has started. **Available for Android only.**
42
+ *
43
+ * @since 1.0.0
44
+ */
45
+ DFU_PROCESS_STARTED = "DFU_PROCESS_STARTED",
46
+ /**
47
+ * The device is enabling DFU mode.
48
+ *
49
+ * @since 1.0.0
50
+ */
51
+ ENABLING_DFU_MODE = "ENABLING_DFU_MODE",
52
+ /**
53
+ * The DFU process is in progress.
54
+ *
55
+ * @since 1.0.0
56
+ */
57
+ DFU_PROGRESS = "DFU_PROGRESS",
58
+ /**
59
+ * The firmware is currently being validated.
60
+ *
61
+ * @since 1.0.0
62
+ */
63
+ VALIDATING_FIRMWARE = "VALIDATING_FIRMWARE",
64
+ /**
65
+ * The device is disconnecting.
66
+ *
67
+ * @since 1.0.0
68
+ */
69
+ DEVICE_DISCONNECTING = "DEVICE_DISCONNECTING",
70
+ /**
71
+ * The device has disconnected. **Available for Android only.**
72
+ *
73
+ * @since 1.0.0
74
+ */
75
+ DEVICE_DISCONNECTED = "DEVICE_DISCONNECTED",
76
+ /**
77
+ * The DFU process has completed successfully.
78
+ *
79
+ * @since 1.0.0
80
+ */
81
+ DFU_COMPLETED = "DFU_COMPLETED",
82
+ /**
83
+ * The DFU process has been aborted.
84
+ *
85
+ * @since 1.0.0
86
+ */
87
+ DFU_ABORTED = "DFU_ABORTED",
88
+ /**
89
+ * The DFU process has failed.
90
+ *
91
+ * @since 1.0.0
92
+ */
93
+ DFU_FAILED = "DFU_FAILED"
94
+ }
95
+ /**
96
+ * Contains data related to the DFU update process, such as progress and speed.
97
+ *
98
+ * @since 1.0.0
99
+ */
100
+ export interface DfuUpdateData {
101
+ /**
102
+ * The current status of upload (0-99).
103
+ *
104
+ * @since 1.0.0
105
+ */
106
+ percent?: number;
107
+ /**
108
+ * The current speed in bytes per millisecond.
109
+ *
110
+ * @since 1.0.0
111
+ */
112
+ speed?: number;
113
+ /**
114
+ * The average speed in bytes per millisecond.
115
+ *
116
+ * @since 1.0.0
117
+ */
118
+ avgSpeed?: number;
119
+ /**
120
+ * The number of parts being sent. In case the ZIP file contains a Soft Device and/or a Bootloader together
121
+ * with the application the SD+BL are sent as part 1, then the service starts again and send the application
122
+ * as part 2.
123
+ *
124
+ * @since 1.0.0
125
+ */
126
+ currentPart?: number;
127
+ /**
128
+ * The total number of parts.
129
+ *
130
+ * @since 1.0.0
131
+ */
132
+ partsTotal?: number;
133
+ /**
134
+ * The total time elapsed since the start of the DFU process in milliseconds
135
+ *
136
+ * @since 1.1.0
137
+ */
138
+ duration?: number;
139
+ /**
140
+ * The estimated remaining time to the end of the DFU process in milliseconds
141
+ *
142
+ * @since 1.1.0
143
+ */
144
+ remainingTime?: number;
145
+ }
146
+ /**
147
+ * The DFU update object that is passed to the DFUStateChanged event
148
+ *
149
+ * @since 1.0.0
150
+ */
151
+ export interface DfuUpdate {
152
+ /**
153
+ * Defines the structure for the DFU update object passed to the DFUStateChanged event.
154
+ *
155
+ * @since 1.0.0
156
+ */
157
+ state: DfuState;
158
+ /**
159
+ * The DFU data that is passed to the DfuUpdate object
160
+ *
161
+ * @since 1.0.0
162
+ */
163
+ data: DfuUpdateData;
164
+ }
165
+ /**
166
+ * Outlines additional options for configuring the DFU process.
167
+ *
168
+ * @since 1.0.0
169
+ */
170
+ export interface DfuOptions {
171
+ /**
172
+ * Sets whether the progress notification in the status bar should be disabled.
173
+ *
174
+ * @default false
175
+ * @since 1.0.0
176
+ */
177
+ disableNotification?: boolean;
178
+ /**
179
+ * Sets whether the progress notification in the status bar should be disabled.
180
+ *
181
+ * @default false
182
+ * @since 1.0.0
183
+ */
184
+ startAsForegroundService?: boolean;
185
+ /**
186
+ * Sets whether the bond information should be preserver after flashing new application.
187
+ *
188
+ * @default false
189
+ * @since 1.0.0
190
+ */
191
+ keepBond?: boolean;
192
+ /**
193
+ * Sets whether a new bond should be created after the DFU is complete. The old bond
194
+ * information will be removed before.
195
+ *
196
+ * @default false
197
+ * @since 1.0.0
198
+ */
199
+ restoreBond?: boolean;
200
+ /**
201
+ * Sets the initial delay (in milliseconds) that the service will wait before sending each data object.
202
+ *
203
+ * @default 0
204
+ * @since 1.0.0
205
+ */
206
+ dataObjectDelay?: number;
207
+ /**
208
+ * Enables or disables the Packet Receipt Notification (PRN) procedure.
209
+ *
210
+ * By default the PRNs are disabled on devices with Android Marshmallow or newer and enabled on
211
+ * older ones.
212
+ *
213
+ * @since 1.0.0
214
+ */
215
+ packetReceiptNotificationsEnabled?: boolean;
216
+ /**
217
+ * If Packet Receipt Notification procedure is enabled, this method sets the number of packets to be sent before
218
+ * receiving a PRN.
219
+ *
220
+ * @default 12
221
+ * @since 1.0.0
222
+ */
223
+ packetsReceiptNotificationsValue?: number;
224
+ /**
225
+ * Setting force DFU to true will prevent from jumping to the DFU Bootloader
226
+ * mode in case there is no DFU Version characteristic (Legacy DFU only!).
227
+ * Use this if the DFU operation can be handled by your device running in the application mode.
228
+ * This method is ignored in Secure DFU.
229
+ *
230
+ * @default false
231
+ * @since 1.0.0
232
+ */
233
+ forceDfu?: boolean;
234
+ /**
235
+ * Sets the time (in milliseconds) required by the device to reboot. The library will wait for this time before
236
+ * scanning for the device in bootloader mode.
237
+ *
238
+ * @default 0
239
+ * @since 1.0.0
240
+ */
241
+ rebootTime?: number;
242
+ /**
243
+ * Sets the scan duration (in milliseconds) when scanning for DFU Bootloader.
244
+ *
245
+ * @default 5000
246
+ * @since 1.0.0
247
+ */
248
+ scanTimeout?: number;
249
+ /**
250
+ * When this is set to true, the Legacy Buttonless Service will scan for the device advertising
251
+ * with an incremented MAC address, instead of trying to reconnect to the same device.
252
+ *
253
+ * @default false
254
+ * @since 1.0.0
255
+ */
256
+ forceScanningForNewAddressInLegacyDfu?: boolean;
257
+ /**
258
+ * This options allows to disable the resume feature in Secure DFU. When the extra value is set to true, the DFU will
259
+ * send Init Packet and Data again, despite the firmware might have been send partially before. By default, without
260
+ * setting this extra, or by setting it to false, the DFU will resume the previously cancelled upload if CRC values
261
+ * match.
262
+ *
263
+ * @default false
264
+ * @since 1.4.0
265
+ */
266
+ disableResume?: boolean;
267
+ /**
268
+ * Sets the number of retries that the DFU service will use to complete DFU.
269
+ *
270
+ * @default 0
271
+ * @since 1.0.0
272
+ */
273
+ numberOfRetries?: number;
274
+ /**
275
+ * Sets the Maximum Transfer Unit (MTU) value that the Secure DFU service will try to request
276
+ * before performing DFU. **Available for Android only.**
277
+ *
278
+ * By default, value 517 will be used, which is the highest supported y Android. However, as the
279
+ * highest supported MTU by the Secure DFU from SDK 15 (first which supports higher MTU) is 247,
280
+ * the sides will agree on using MTU = 247 instead if the phone supports it (Lollipop or newer device).
281
+ *
282
+ * @since 1.0.0
283
+ */
284
+ mtu?: number;
285
+ /**
286
+ * Sets the current MTU value. This method should be used only if the device is already
287
+ * connected and MTU has been requested before DFU service is started. **Available for Android only.**
288
+ *
289
+ * @default 23
290
+ * @since 1.0.0
291
+ */
292
+ currentMtu?: number;
293
+ /**
294
+ * Disables MTU request. **Available for Android only.**
295
+ *
296
+ * @default false
297
+ * @since 1.4.0
298
+ */
299
+ disableMtuRequest?: boolean;
300
+ /**
301
+ * This method allows to narrow the update to selected parts from the ZIP, for example
302
+ * to allow only application update from a ZIP file that has SD+BL+App. System components scope
303
+ * include the Softdevice and/or the Bootloader (they can't be separated as they are packed in
304
+ * a single bin file and the library does not know whether it contains only the softdevice,
305
+ * the bootloader or both) Application scope includes the application only.
306
+ *
307
+ * @since 1.0.0
308
+ */
309
+ scope?: number;
310
+ /**
311
+ * This method sets the size of an MBR (Master Boot Record). It should be used only
312
+ * when updating a file from a HEX file. If you use BIN or ZIP, value set here will
313
+ * be ignored.
314
+ *
315
+ * @default 4096
316
+ * @since 1.0.0
317
+ */
318
+ mbrSize?: number;
319
+ /**
320
+ * Set this flag to true to enable experimental buttonless feature in Secure DFU. When the
321
+ * experimental Buttonless DFU Service is found on a device, the service will use it to
322
+ * switch the device to the bootloader mode, connect to it in that mode and proceed with DFU.
323
+ *
324
+ * @default false
325
+ * @since 1.0.0
326
+ */
327
+ unsafeExperimentalButtonlessServiceInSecureDfuEnabled?: boolean;
328
+ }
329
+ /**
330
+ * Specifies the options required for initiating the DFU process.
331
+ *
332
+ * @since 1.0.0
333
+ */
334
+ export interface DfuUpdateOptions {
335
+ /**
336
+ * The target device address.
337
+ * On **Android** this is the BLE MAC address.
338
+ * On **iOS** and **web** it is a randomly generated UUID identifier.
339
+ *
340
+ * @since 1.0.0
341
+ */
342
+ deviceAddress: string;
343
+ /**
344
+ * The name of the device
345
+ *
346
+ * @since 1.0.0
347
+ */
348
+ deviceName?: string;
349
+ /**
350
+ * The path to the firmware file
351
+ *
352
+ * @since 1.0.0
353
+ */
354
+ filePath: string;
355
+ /**
356
+ * The additional options for the DFU process
357
+ *
358
+ * @since 1.0.0
359
+ */
360
+ dfuOptions?: DfuOptions;
361
+ }
362
+ /**
363
+ * Defines the plugin for handling Nordic DFU processes.
364
+ * Includes methods to start the DFU process, check permissions, and manage event listeners.
365
+ *
366
+ * @since 1.0.0
367
+ */
368
+ export interface NordicDfuPlugin {
369
+ /**
370
+ * Initiates the DFU process with the specified options.
371
+ *
372
+ * @param dfuUpdateOptions Options for the DFU process.
373
+ * @returns A promise that resolves on successful completion of the DFU process or rejects with a PluginResultError.
374
+ * @example
375
+ * const dfuOptions: DfuOptions = {
376
+ * mtu: 23,
377
+ * currentMtu: 23,
378
+ * packetReceiptNotificationsEnabled: false,
379
+ * };
380
+ *
381
+ * const dfuUpdateOptions: DfuUpdateOptions = {
382
+ * deviceAddress: this.device.deviceId,
383
+ * deviceName: this.device.name,
384
+ * filePath: this.file.path,
385
+ * dfuOptions: dfuOptions,
386
+ * };
387
+ *
388
+ * NordicDfu.startDFU(dfuUpdateOptions).then(
389
+ * () => console.log,
390
+ * (error: PluginResultError) => console.error
391
+ * );
392
+ * @since 1.0.0
393
+ */
394
+ startDFU(dfuUpdateOptions: DfuUpdateOptions): Promise<void | PluginResultError>;
395
+ /**
396
+ * Check status of permissions needed by the plugin
397
+ *
398
+ * @example
399
+ * const request = await NordicDfu.checkPermissions();
400
+ * console.log(request)
401
+ * @since 1.0.0
402
+ */
403
+ checkPermissions(): Promise<PermissionStatus>;
404
+ /**
405
+ * Request permissions needed by the plugin
406
+ *
407
+ * @example
408
+ * const request = await NordicDfu.requestPermissions();
409
+ * console.log(request)
410
+ * @since 1.0.0
411
+ */
412
+ requestPermissions(): Promise<PermissionStatus>;
413
+ /**
414
+ * Listen for when the DFU state changes
415
+ *
416
+ * @param eventName The name of the event to listen for
417
+ * @param handler The handler function that will be called when the event is fired
418
+ * @returns A promise that resolves with a PluginListenerHandle that can be used to remove the listener
419
+ * @example
420
+ * NordicDfu.addListener('DFUStateChanged', async (update: DfuUpdate) => {
421
+ * console.log(`DFU: state: ${update.state}, data: ${JSON.stringify(update.data)}`);
422
+ * }
423
+ * @since 1.0.0
424
+ */
425
+ addListener(eventName: 'DFUStateChanged', handler: (update: DfuUpdate) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
426
+ /**
427
+ * Removes all listeners for the DFUStateChanged event
428
+ *
429
+ * @returns A promise that resolves when all listeners are removed
430
+ * @example
431
+ * NordicDfu.removeAllListeners();
432
+ * @since 1.0.0
433
+ */
434
+ removeAllListeners(): Promise<void>;
435
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Enumerates the various states in the DFU process. This helps in tracking the progress and status of the
3
+ * firmware update.
4
+ *
5
+ * @since 1.0.0
6
+ */
7
+ export var DfuState;
8
+ (function (DfuState) {
9
+ /**
10
+ * The device is currently connecting.
11
+ *
12
+ * @since 1.0.0
13
+ */
14
+ DfuState["DEVICE_CONNECTING"] = "DEVICE_CONNECTING";
15
+ /**
16
+ * The device has successfully connected. **Available for Android only.**
17
+ *
18
+ * @since 1.0.0
19
+ */
20
+ DfuState["DEVICE_CONNECTED"] = "DEVICE_CONNECTED";
21
+ /**
22
+ * The DFU process is about to start.
23
+ *
24
+ * @since 1.0.0
25
+ */
26
+ DfuState["DFU_PROCESS_STARTING"] = "DFU_PROCESS_STARTING";
27
+ /**
28
+ * The DFU process has started. **Available for Android only.**
29
+ *
30
+ * @since 1.0.0
31
+ */
32
+ DfuState["DFU_PROCESS_STARTED"] = "DFU_PROCESS_STARTED";
33
+ /**
34
+ * The device is enabling DFU mode.
35
+ *
36
+ * @since 1.0.0
37
+ */
38
+ DfuState["ENABLING_DFU_MODE"] = "ENABLING_DFU_MODE";
39
+ /**
40
+ * The DFU process is in progress.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ DfuState["DFU_PROGRESS"] = "DFU_PROGRESS";
45
+ /**
46
+ * The firmware is currently being validated.
47
+ *
48
+ * @since 1.0.0
49
+ */
50
+ DfuState["VALIDATING_FIRMWARE"] = "VALIDATING_FIRMWARE";
51
+ /**
52
+ * The device is disconnecting.
53
+ *
54
+ * @since 1.0.0
55
+ */
56
+ DfuState["DEVICE_DISCONNECTING"] = "DEVICE_DISCONNECTING";
57
+ /**
58
+ * The device has disconnected. **Available for Android only.**
59
+ *
60
+ * @since 1.0.0
61
+ */
62
+ DfuState["DEVICE_DISCONNECTED"] = "DEVICE_DISCONNECTED";
63
+ /**
64
+ * The DFU process has completed successfully.
65
+ *
66
+ * @since 1.0.0
67
+ */
68
+ DfuState["DFU_COMPLETED"] = "DFU_COMPLETED";
69
+ /**
70
+ * The DFU process has been aborted.
71
+ *
72
+ * @since 1.0.0
73
+ */
74
+ DfuState["DFU_ABORTED"] = "DFU_ABORTED";
75
+ /**
76
+ * The DFU process has failed.
77
+ *
78
+ * @since 1.0.0
79
+ */
80
+ DfuState["DFU_FAILED"] = "DFU_FAILED";
81
+ })(DfuState || (DfuState = {}));
82
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,QAoFX;AApFD,WAAY,QAAQ;IAClB;;;;OAIG;IACH,mDAAuC,CAAA;IAEvC;;;;OAIG;IACH,iDAAqC,CAAA;IAErC;;;;OAIG;IACH,yDAA6C,CAAA;IAE7C;;;;OAIG;IACH,uDAA2C,CAAA;IAE3C;;;;OAIG;IACH,mDAAuC,CAAA;IAEvC;;;;OAIG;IACH,yCAA6B,CAAA;IAE7B;;;;OAIG;IACH,uDAA2C,CAAA;IAE3C;;;;OAIG;IACH,yDAA6C,CAAA;IAE7C;;;;OAIG;IACH,uDAA2C,CAAA;IAE3C;;;;OAIG;IACH,2CAA+B,CAAA;IAE/B;;;;OAIG;IACH,uCAA2B,CAAA;IAE3B;;;;OAIG;IACH,qCAAyB,CAAA;AAC3B,CAAC,EApFW,QAAQ,KAAR,QAAQ,QAoFnB","sourcesContent":["import type { PluginListenerHandle, PluginResultError, PermissionState } from '@capacitor/core';\n\n/**\n * Represents the current status of permissions in the plugin.\n *\n * @since 1.0.0\n */\nexport interface PermissionStatus {\n /**\n * Indicates the permission state of notifications.\n *\n * @since 1.0.0\n */\n notifications: PermissionState;\n}\n\n/**\n * Enumerates the various states in the DFU process. This helps in tracking the progress and status of the\n * firmware update.\n *\n * @since 1.0.0\n */\nexport enum DfuState {\n /**\n * The device is currently connecting.\n *\n * @since 1.0.0\n */\n DEVICE_CONNECTING = 'DEVICE_CONNECTING',\n\n /**\n * The device has successfully connected. **Available for Android only.**\n *\n * @since 1.0.0\n */\n DEVICE_CONNECTED = 'DEVICE_CONNECTED',\n\n /**\n * The DFU process is about to start.\n *\n * @since 1.0.0\n */\n DFU_PROCESS_STARTING = 'DFU_PROCESS_STARTING',\n\n /**\n * The DFU process has started. **Available for Android only.**\n *\n * @since 1.0.0\n */\n DFU_PROCESS_STARTED = 'DFU_PROCESS_STARTED',\n\n /**\n * The device is enabling DFU mode.\n *\n * @since 1.0.0\n */\n ENABLING_DFU_MODE = 'ENABLING_DFU_MODE',\n\n /**\n * The DFU process is in progress.\n *\n * @since 1.0.0\n */\n DFU_PROGRESS = 'DFU_PROGRESS',\n\n /**\n * The firmware is currently being validated.\n *\n * @since 1.0.0\n */\n VALIDATING_FIRMWARE = 'VALIDATING_FIRMWARE',\n\n /**\n * The device is disconnecting.\n *\n * @since 1.0.0\n */\n DEVICE_DISCONNECTING = 'DEVICE_DISCONNECTING',\n\n /**\n * The device has disconnected. **Available for Android only.**\n *\n * @since 1.0.0\n */\n DEVICE_DISCONNECTED = 'DEVICE_DISCONNECTED',\n\n /**\n * The DFU process has completed successfully.\n *\n * @since 1.0.0\n */\n DFU_COMPLETED = 'DFU_COMPLETED',\n\n /**\n * The DFU process has been aborted.\n *\n * @since 1.0.0\n */\n DFU_ABORTED = 'DFU_ABORTED',\n\n /**\n * The DFU process has failed.\n *\n * @since 1.0.0\n */\n DFU_FAILED = 'DFU_FAILED',\n}\n\n/**\n * Contains data related to the DFU update process, such as progress and speed.\n *\n * @since 1.0.0\n */\nexport interface DfuUpdateData {\n /**\n * The current status of upload (0-99).\n *\n * @since 1.0.0\n */\n percent?: number;\n\n /**\n * The current speed in bytes per millisecond.\n *\n * @since 1.0.0\n */\n speed?: number;\n\n /**\n * The average speed in bytes per millisecond.\n *\n * @since 1.0.0\n */\n avgSpeed?: number;\n\n /**\n * The number of parts being sent. In case the ZIP file contains a Soft Device and/or a Bootloader together\n * with the application the SD+BL are sent as part 1, then the service starts again and send the application\n * as part 2.\n *\n * @since 1.0.0\n */\n currentPart?: number;\n\n /**\n * The total number of parts.\n *\n * @since 1.0.0\n */\n partsTotal?: number;\n\n /**\n * The total time elapsed since the start of the DFU process in milliseconds\n *\n * @since 1.1.0\n */\n duration?: number;\n\n /**\n * The estimated remaining time to the end of the DFU process in milliseconds\n *\n * @since 1.1.0\n */\n remainingTime?: number;\n}\n\n/**\n * The DFU update object that is passed to the DFUStateChanged event\n *\n * @since 1.0.0\n */\nexport interface DfuUpdate {\n /**\n * Defines the structure for the DFU update object passed to the DFUStateChanged event.\n *\n * @since 1.0.0\n */\n state: DfuState;\n\n /**\n * The DFU data that is passed to the DfuUpdate object\n *\n * @since 1.0.0\n */\n data: DfuUpdateData;\n}\n\n/**\n * Outlines additional options for configuring the DFU process.\n *\n * @since 1.0.0\n */\nexport interface DfuOptions {\n /**\n * Sets whether the progress notification in the status bar should be disabled.\n *\n * @default false\n * @since 1.0.0\n */\n disableNotification?: boolean;\n\n /**\n * Sets whether the progress notification in the status bar should be disabled.\n *\n * @default false\n * @since 1.0.0\n */\n startAsForegroundService?: boolean;\n\n /**\n * Sets whether the bond information should be preserver after flashing new application.\n *\n * @default false\n * @since 1.0.0\n */\n keepBond?: boolean;\n\n /**\n * Sets whether a new bond should be created after the DFU is complete. The old bond\n * information will be removed before.\n *\n * @default false\n * @since 1.0.0\n */\n restoreBond?: boolean;\n\n /**\n * Sets the initial delay (in milliseconds) that the service will wait before sending each data object.\n *\n * @default 0\n * @since 1.0.0\n */\n dataObjectDelay?: number;\n\n /**\n * Enables or disables the Packet Receipt Notification (PRN) procedure.\n *\n * By default the PRNs are disabled on devices with Android Marshmallow or newer and enabled on\n * older ones.\n *\n * @since 1.0.0\n */\n packetReceiptNotificationsEnabled?: boolean;\n\n /**\n * If Packet Receipt Notification procedure is enabled, this method sets the number of packets to be sent before\n * receiving a PRN.\n *\n * @default 12\n * @since 1.0.0\n */\n packetsReceiptNotificationsValue?: number;\n\n /**\n * Setting force DFU to true will prevent from jumping to the DFU Bootloader\n * mode in case there is no DFU Version characteristic (Legacy DFU only!).\n * Use this if the DFU operation can be handled by your device running in the application mode.\n * This method is ignored in Secure DFU.\n *\n * @default false\n * @since 1.0.0\n */\n forceDfu?: boolean;\n\n /**\n * Sets the time (in milliseconds) required by the device to reboot. The library will wait for this time before\n * scanning for the device in bootloader mode.\n *\n * @default 0\n * @since 1.0.0\n */\n rebootTime?: number;\n\n /**\n * Sets the scan duration (in milliseconds) when scanning for DFU Bootloader.\n *\n * @default 5000\n * @since 1.0.0\n */\n scanTimeout?: number;\n\n /**\n * When this is set to true, the Legacy Buttonless Service will scan for the device advertising\n * with an incremented MAC address, instead of trying to reconnect to the same device.\n *\n * @default false\n * @since 1.0.0\n */\n forceScanningForNewAddressInLegacyDfu?: boolean;\n\n /**\n * This options allows to disable the resume feature in Secure DFU. When the extra value is set to true, the DFU will\n * send Init Packet and Data again, despite the firmware might have been send partially before. By default, without\n * setting this extra, or by setting it to false, the DFU will resume the previously cancelled upload if CRC values\n * match.\n *\n * @default false\n * @since 1.4.0\n */\n disableResume?: boolean;\n\n /**\n * Sets the number of retries that the DFU service will use to complete DFU.\n *\n * @default 0\n * @since 1.0.0\n */\n numberOfRetries?: number;\n\n /**\n * Sets the Maximum Transfer Unit (MTU) value that the Secure DFU service will try to request\n * before performing DFU. **Available for Android only.**\n *\n * By default, value 517 will be used, which is the highest supported y Android. However, as the\n * highest supported MTU by the Secure DFU from SDK 15 (first which supports higher MTU) is 247,\n * the sides will agree on using MTU = 247 instead if the phone supports it (Lollipop or newer device).\n *\n * @since 1.0.0\n */\n mtu?: number;\n\n /**\n * Sets the current MTU value. This method should be used only if the device is already\n * connected and MTU has been requested before DFU service is started. **Available for Android only.**\n *\n * @default 23\n * @since 1.0.0\n */\n currentMtu?: number;\n\n /**\n * Disables MTU request. **Available for Android only.**\n *\n * @default false\n * @since 1.4.0\n */\n disableMtuRequest?: boolean;\n\n /**\n * This method allows to narrow the update to selected parts from the ZIP, for example\n * to allow only application update from a ZIP file that has SD+BL+App. System components scope\n * include the Softdevice and/or the Bootloader (they can't be separated as they are packed in\n * a single bin file and the library does not know whether it contains only the softdevice,\n * the bootloader or both) Application scope includes the application only.\n *\n * @since 1.0.0\n */\n scope?: number;\n\n /**\n * This method sets the size of an MBR (Master Boot Record). It should be used only\n * when updating a file from a HEX file. If you use BIN or ZIP, value set here will\n * be ignored.\n *\n * @default 4096\n * @since 1.0.0\n */\n mbrSize?: number;\n\n /**\n * Set this flag to true to enable experimental buttonless feature in Secure DFU. When the\n * experimental Buttonless DFU Service is found on a device, the service will use it to\n * switch the device to the bootloader mode, connect to it in that mode and proceed with DFU.\n *\n * @default false\n * @since 1.0.0\n */\n unsafeExperimentalButtonlessServiceInSecureDfuEnabled?: boolean;\n}\n\n/**\n * Specifies the options required for initiating the DFU process.\n *\n * @since 1.0.0\n */\nexport interface DfuUpdateOptions {\n /**\n * The target device address.\n * On **Android** this is the BLE MAC address.\n * On **iOS** and **web** it is a randomly generated UUID identifier.\n *\n * @since 1.0.0\n */\n deviceAddress: string;\n\n /**\n * The name of the device\n *\n * @since 1.0.0\n */\n deviceName?: string;\n\n /**\n * The path to the firmware file\n *\n * @since 1.0.0\n */\n filePath: string;\n\n /**\n * The additional options for the DFU process\n *\n * @since 1.0.0\n */\n dfuOptions?: DfuOptions;\n}\n\n/**\n * Defines the plugin for handling Nordic DFU processes.\n * Includes methods to start the DFU process, check permissions, and manage event listeners.\n *\n * @since 1.0.0\n */\nexport interface NordicDfuPlugin {\n /**\n * Initiates the DFU process with the specified options.\n *\n * @param dfuUpdateOptions Options for the DFU process.\n * @returns A promise that resolves on successful completion of the DFU process or rejects with a PluginResultError.\n * @example\n * const dfuOptions: DfuOptions = {\n * mtu: 23,\n * currentMtu: 23,\n * packetReceiptNotificationsEnabled: false,\n * };\n *\n * const dfuUpdateOptions: DfuUpdateOptions = {\n * deviceAddress: this.device.deviceId,\n * deviceName: this.device.name,\n * filePath: this.file.path,\n * dfuOptions: dfuOptions,\n * };\n *\n * NordicDfu.startDFU(dfuUpdateOptions).then(\n * () => console.log,\n * (error: PluginResultError) => console.error\n * );\n * @since 1.0.0\n */\n startDFU(dfuUpdateOptions: DfuUpdateOptions): Promise<void | PluginResultError>;\n\n /**\n * Check status of permissions needed by the plugin\n *\n * @example\n * const request = await NordicDfu.checkPermissions();\n * console.log(request)\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request permissions needed by the plugin\n *\n * @example\n * const request = await NordicDfu.requestPermissions();\n * console.log(request)\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Listen for when the DFU state changes\n *\n * @param eventName The name of the event to listen for\n * @param handler The handler function that will be called when the event is fired\n * @returns A promise that resolves with a PluginListenerHandle that can be used to remove the listener\n * @example\n * NordicDfu.addListener('DFUStateChanged', async (update: DfuUpdate) => {\n * console.log(`DFU: state: ${update.state}, data: ${JSON.stringify(update.data)}`);\n * }\n * @since 1.0.0\n */\n addListener(\n eventName: 'DFUStateChanged',\n handler: (update: DfuUpdate) => void,\n ): Promise<PluginListenerHandle> & PluginListenerHandle;\n\n /**\n * Removes all listeners for the DFUStateChanged event\n *\n * @returns A promise that resolves when all listeners are removed\n * @example\n * NordicDfu.removeAllListeners();\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { NordicDfuPlugin } from './definitions';
2
+ declare const NordicDfu: NordicDfuPlugin;
3
+ export * from './definitions';
4
+ export { NordicDfu };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const NordicDfu = registerPlugin('NordicDfu', {
3
+ web: () => import('./web').then((m) => new m.NordicDfuWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { NordicDfu };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,SAAS,GAAG,cAAc,CAAkB,WAAW,EAAE;IAC7D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,CAAC;CAC7D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { NordicDfuPlugin } from './definitions';\n\nconst NordicDfu = registerPlugin<NordicDfuPlugin>('NordicDfu', {\n web: () => import('./web').then((m) => new m.NordicDfuWeb()),\n});\n\nexport * from './definitions';\nexport { NordicDfu };\n"]}
@@ -0,0 +1,9 @@
1
+ import { WebPlugin, type PluginResultError, type ListenerCallback, type PluginListenerHandle } from '@capacitor/core';
2
+ import type { DfuUpdateOptions, NordicDfuPlugin, PermissionStatus } from './definitions';
3
+ export declare class NordicDfuWeb extends WebPlugin implements NordicDfuPlugin {
4
+ removeAllListeners(): Promise<void>;
5
+ startDFU(_dfuUpdateOptions: DfuUpdateOptions): Promise<void | PluginResultError>;
6
+ checkPermissions(): Promise<PermissionStatus>;
7
+ requestPermissions(): Promise<PermissionStatus>;
8
+ addListener(_eventName: string, _listenerFunc: ListenerCallback): Promise<PluginListenerHandle> & PluginListenerHandle;
9
+ }
@@ -0,0 +1,20 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import { WebPlugin } from '@capacitor/core';
3
+ export class NordicDfuWeb extends WebPlugin {
4
+ removeAllListeners() {
5
+ throw this.unavailable('Method not available in this browser.');
6
+ }
7
+ startDFU(_dfuUpdateOptions) {
8
+ throw this.unavailable('Method not available in this browser.');
9
+ }
10
+ checkPermissions() {
11
+ throw this.unavailable('Method not available in this browser.');
12
+ }
13
+ requestPermissions() {
14
+ throw this.unavailable('Method not available in this browser.');
15
+ }
16
+ addListener(_eventName, _listenerFunc) {
17
+ throw this.unavailable('Method not available in this browser.');
18
+ }
19
+ }
20
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,SAAS,EAA4E,MAAM,iBAAiB,CAAC;AAItH,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,kBAAkB;QAChB,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAClE,CAAC;IACD,QAAQ,CAAC,iBAAmC;QAC1C,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAClE,CAAC;IACD,gBAAgB;QACd,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAClE,CAAC;IACD,kBAAkB;QAChB,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAClE,CAAC;IACD,WAAW,CACT,UAAkB,EAClB,aAA+B;QAE/B,MAAM,IAAI,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAClE,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { WebPlugin, type PluginResultError, type ListenerCallback, type PluginListenerHandle } from '@capacitor/core';\n\nimport type { DfuUpdateOptions, NordicDfuPlugin, PermissionStatus } from './definitions';\n\nexport class NordicDfuWeb extends WebPlugin implements NordicDfuPlugin {\n removeAllListeners(): Promise<void> {\n throw this.unavailable('Method not available in this browser.');\n }\n startDFU(_dfuUpdateOptions: DfuUpdateOptions): Promise<void | PluginResultError> {\n throw this.unavailable('Method not available in this browser.');\n }\n checkPermissions(): Promise<PermissionStatus> {\n throw this.unavailable('Method not available in this browser.');\n }\n requestPermissions(): Promise<PermissionStatus> {\n throw this.unavailable('Method not available in this browser.');\n }\n addListener(\n _eventName: string,\n _listenerFunc: ListenerCallback,\n ): Promise<PluginListenerHandle> & PluginListenerHandle {\n throw this.unavailable('Method not available in this browser.');\n }\n}\n"]}