From 9f5d5802ed0fb82fefd39229399e6ca331dff636 Mon Sep 17 00:00:00 2001 From: Martin Williams Date: Sun, 26 Aug 2018 18:10:41 +0100 Subject: [PATCH] Fix MicroBitPartialFlashingService blockPacketCount increment. If the 5th packet goes missing, the recovery code would have set packetCount based on the wrong blockPacketCount, expecting the same packet numbers again. --- source/bluetooth/MicroBitPartialFlashingService.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/bluetooth/MicroBitPartialFlashingService.cpp b/source/bluetooth/MicroBitPartialFlashingService.cpp index f0d1b3f..b0f1c42 100644 --- a/source/bluetooth/MicroBitPartialFlashingService.cpp +++ b/source/bluetooth/MicroBitPartialFlashingService.cpp @@ -192,7 +192,8 @@ void MicroBitPartialFlashingService::flashData(uint8_t *data) uint8_t flashNotificationBuffer[] = {FLASH_DATA, 0xAA}; ble.gattServer().notify(partialFlashCharacteristicHandle, (const uint8_t *)flashNotificationBuffer, sizeof(flashNotificationBuffer)); - packetCount = blockPacketCount + 4; + blockPacketCount += 4; + packetCount = blockPacketCount; blockNum = 0; return; } @@ -208,7 +209,6 @@ void MicroBitPartialFlashingService::flashData(uint8_t *data) case 0: { offset = ((data[1] << 8) | data[2] << 0); - blockPacketCount = packetNum; blockNum++; break; } @@ -226,6 +226,7 @@ void MicroBitPartialFlashingService::flashData(uint8_t *data) MicroBitEvent evt(MICROBIT_ID_PARTIAL_FLASHING, FLASH_DATA ); // Reset blockNum blockNum = 0; + blockPacketCount += 4; break; } default: