From 671ef3f000d21a911700db3f23ccbcc8161e3ea8 Mon Sep 17 00:00:00 2001 From: Dan Walkes Date: Sat, 4 Feb 2017 18:24:56 -0700 Subject: [PATCH] Clean up log messages, match code convention Use single space after commas and between assignments. --- .../no/nordicsemi/android/dfu/SecureDfuImpl.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dfu/src/main/java/no/nordicsemi/android/dfu/SecureDfuImpl.java b/dfu/src/main/java/no/nordicsemi/android/dfu/SecureDfuImpl.java index cf27c69..658c64f 100644 --- a/dfu/src/main/java/no/nordicsemi/android/dfu/SecureDfuImpl.java +++ b/dfu/src/main/java/no/nordicsemi/android/dfu/SecureDfuImpl.java @@ -514,16 +514,18 @@ import no.nordicsemi.android.error.SecureDfuError; // Increment iterator currentChunk++; attempt = 1; + //Mark this location after completion of successful transfer. In the event of a CRC retry on the next packet we will restart from this point. mFirmwareStream.mark(0); } else { + String crcFailMessage = String.format(Locale.US, "CRC does not match! Expected %08X but found %08X.", crc, checksum.CRC32); if (attempt < MAX_ATTEMPTS) { attempt++; - logi(String.format(Locale.US,"CRC does not match! Expected %08X Retrying...(%d/%d)",crc,attempt,MAX_ATTEMPTS)); - mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_WARNING, "CRC does not match! Retrying...(" + attempt + "/" + MAX_ATTEMPTS + ")"); + crcFailMessage += String.format(Locale.US, " Retrying...(%d/%d)", attempt, MAX_ATTEMPTS); + logi(crcFailMessage); + mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_WARNING, crcFailMessage); try { + // Reset the CRC and file pointer back to the previous mark() point after completion of the last successful packet. mFirmwareStream.reset(); - final int crcAfterReset = (int) (((ArchiveInputStream) mFirmwareStream).getCrc32() & 0xFFFFFFFFL); - logi(String.format(Locale.US,"CRC after reset is %08X",crcAfterReset)); mProgressInfo.setBytesSent(checksum.offset - info.maxSize); } catch (final IOException e) { loge("Error while resetting the firmware stream", e); @@ -531,8 +533,8 @@ import no.nordicsemi.android.error.SecureDfuError; return; } } else { - loge(String.format("CRC does not match! Expected %08X",crc)); - mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_ERROR, "CRC does not match!"); + loge(crcFailMessage); + mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_ERROR, crcFailMessage); mService.terminateConnection(gatt, DfuBaseService.ERROR_CRC_ERROR); return; }