Clean up log messages, match code convention

Use single space after commas and between assignments.
This commit is contained in:
Dan Walkes 2017-02-04 18:24:56 -07:00
parent 18bdda9a37
commit 671ef3f000
1 changed files with 8 additions and 6 deletions

View File

@ -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;
}