From 0a0f28fff4be4c9fd9030d9375459fb7b5fdd004 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Thu, 22 Jul 2021 22:57:45 +0300 Subject: Make firmware updating more foolproof (#469) * Make firmware updating more foolproof and fix bugs * No need to manually handle overflow * Make startTime TickType_t * Don't process TouchEvents::None * Fix sleep getting re-enabled issue more directly --- src/components/ble/DfuService.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/components/ble/DfuService.cpp') diff --git a/src/components/ble/DfuService.cpp b/src/components/ble/DfuService.cpp index e6bcea81..4179994d 100644 --- a/src/components/ble/DfuService.cpp +++ b/src/components/ble/DfuService.cpp @@ -266,13 +266,14 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) { static_cast(ErrorCodes::NoError)}; notificationManager.AsyncSend(connectionHandle, controlPointCharacteristicHandle, data, 3); } else { - bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); NRF_LOG_INFO("Image Error : bad CRC"); uint8_t data[3] {static_cast(Opcodes::Response), static_cast(Opcodes::ValidateFirmware), static_cast(ErrorCodes::CrcError)}; notificationManager.AsyncSend(connectionHandle, controlPointCharacteristicHandle, data, 3); + bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); + Reset(); } return 0; @@ -283,10 +284,8 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) { return 0; } NRF_LOG_INFO("[DFU] -> Activate image and reset!"); - bleController.StopFirmwareUpdate(); - systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateFinished); - Reset(); bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Validated); + Reset(); return 0; default: return 0; @@ -294,6 +293,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) { } void DfuService::OnTimeout() { + bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); Reset(); } @@ -307,7 +307,6 @@ void DfuService::Reset() { applicationSize = 0; expectedCrc = 0; notificationManager.Reset(); - bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); bleController.StopFirmwareUpdate(); systemTask.PushMessage(Pinetime::System::Messages::BleFirmwareUpdateFinished); } -- cgit v1.2.3