Skip to content

Commit 82fa8cf

Browse files
authored
Merge pull request NordicSemiconductor#253 from NordicSemiconductor/bugfix/252
Ignoring OPERATION NOT PERMITTED error when re-executing data object
2 parents fe212b5 + 4d4410d commit 82fa8cf

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

dfu/src/main/java/no/nordicsemi/android/dfu/SecureDfuImpl.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,18 @@ private void sendFirmware(final BluetoothGatt gatt) throws RemoteDfuException,
554554
// If the whole page was sent and CRC match, we have to make sure it was executed
555555
if (bytesSentNotExecuted == info.maxSize && info.offset < mImageSizeInBytes) {
556556
logi("Executing data object (Op Code = 4)");
557-
writeExecute();
558-
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_APPLICATION, "Data object executed");
557+
try {
558+
writeExecute();
559+
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_APPLICATION, "Data object executed");
560+
} catch (final RemoteDfuException e) {
561+
// In DFU bootloader from SDK 15.x, 16 and 17 there's a bug, which
562+
// prevents executing an object that has already been executed.
563+
// See: https://github.com/NordicSemiconductor/Android-DFU-Library/issues/252
564+
if (e.getErrorNumber() != SecureDfuError.OPERATION_NOT_PERMITTED) {
565+
throw e;
566+
}
567+
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_APPLICATION, "Data object already executed");
568+
}
559569
} else {
560570
resumeSendingData = true;
561571
}

0 commit comments

Comments
 (0)