Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions android/src/main/java/com/pilloxa/dfu/RNNordicDfuModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ public void startDFU(String address, String name, String filePath, int packetRec
int mtu = options.getInt("maxMtu");
starter.setMtu(mtu);
}

if(options.hasKey("disableResume")) {
boolean disableResume = options.getBoolean("disableResume");
if(disableResume){
starter.disableResume();
}
}

if (name != null) {
starter.setDeviceName(name);
}
Expand Down
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ declare module "react-native-nordic-dfu" {
filePath,
alternativeAdvertisingNameEnabled,
packetReceiptNotificationParameter,
disableDfuResume,
retries,
maxMtu,
}: {
Expand All @@ -14,6 +15,7 @@ declare module "react-native-nordic-dfu" {
filePath: string | null;
alternativeAdvertisingNameEnabled?: boolean;
packetReceiptNotificationParameter?: number;
disableDfuResume?: boolean;
retries?: number;
maxMtu?: number;
}): Promise<string>;
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function rejectPromise(message) {
* @param {string} obj.filePath The file system path to the zip-file used for updating
* @param {Boolean} obj.alternativeAdvertisingNameEnabled Send unique name to device before it is switched into bootloader mode (iOS only)
* @param {number} obj.packetReceiptNotificationParameter set number of packets of firmware data to be received by the DFU target before sending a new Packet Receipt Notification
* @param {boolean} obj.disableDfuResume Disable resuming of an interrupted DFU process
* @returns {Promise} A promise that resolves or rejects with the `deviceAddress` in the return value
*
* @example
Expand All @@ -45,6 +46,7 @@ function startDFU({
filePath,
alternativeAdvertisingNameEnabled = true, //iOS only
packetReceiptNotificationParameter = 12,
disableDfuResume = true,
retries = 3, // Android only
maxMtu = 23, // Android only
}) {
Expand All @@ -61,6 +63,7 @@ function startDFU({
deviceName,
filePath,
packetReceiptNotificationParameter,
disableDfuResume,
alternativeAdvertisingNameEnabled
);
} else if (Platform.OS === "android") {
Expand Down
3 changes: 3 additions & 0 deletions ios/RNNordicDfu.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ - (void)logWith:(enum LogLevel)level message:(NSString * _Nonnull)message
filePath:(NSString *)filePath
packetReceiptNotificationParameter:(NSInteger *)packetReceiptNotificationParameter
alternativeAdvertisingNameEnabled:(BOOL *)alternativeAdvertisingNameEnabled
disableDfuResume:(BOOL *)disableDfuResume
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
Expand Down Expand Up @@ -243,6 +244,8 @@ - (void)logWith:(enum LogLevel)level message:(NSString * _Nonnull)message
initiator.packetReceiptNotificationParameter = packetReceiptNotificationParameter;
initiator.alternativeAdvertisingNameEnabled = alternativeAdvertisingNameEnabled;

initiator.disableResume = disableDfuResume;

// Change for iOS 13
initiator.packetReceiptNotificationParameter = 1; //Rate limit the DFU using PRN.
[NSThread sleepForTimeInterval: 2]; //Work around for being stuck in iOS 13
Expand Down