diff options
| author | JF <jf@codingfield.com> | 2021-07-23 09:59:08 (GMT) |
|---|---|---|
| committer | Gitea <gitea@fake.local> | 2021-07-23 09:59:08 (GMT) |
| commit | db6a701644116932f11c54ee0f619464de9faeb7 (patch) | |
| tree | f2fb7999d6db212e416557ed12831d8ab38cc3c0 /src/components/ble/DfuService.cpp | |
| parent | d96395c81021778af35b8b4bf965bfe8663eb081 (diff) | |
| parent | d6cccc2dcd95a7d332ee657d1357ae060389f6e6 (diff) | |
Merge branch 'develop' of JF/PineTime into master
Diffstat (limited to 'src/components/ble/DfuService.cpp')
| -rw-r--r-- | src/components/ble/DfuService.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/components/ble/DfuService.cpp b/src/components/ble/DfuService.cpp index cec194c..4179994 100644 --- a/src/components/ble/DfuService.cpp +++ b/src/components/ble/DfuService.cpp @@ -121,6 +121,11 @@ int DfuService::WritePacketHandler(uint16_t connectionHandle, os_mbuf* om) { NRF_LOG_INFO( "[DFU] -> Start data received : SD size : %d, BT size : %d, app size : %d", softdeviceSize, bootloaderSize, applicationSize); + // wait until SystemTask has finished waking up all devices + while (systemTask.IsSleeping()) { + vTaskDelay(50); // 50ms + } + dfuImage.Erase(); uint8_t data[] {16, 1, 1}; @@ -261,13 +266,14 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) { static_cast<uint8_t>(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<uint8_t>(Opcodes::Response), static_cast<uint8_t>(Opcodes::ValidateFirmware), static_cast<uint8_t>(ErrorCodes::CrcError)}; notificationManager.AsyncSend(connectionHandle, controlPointCharacteristicHandle, data, 3); + bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); + Reset(); } return 0; @@ -278,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; @@ -289,6 +293,7 @@ int DfuService::ControlPointHandler(uint16_t connectionHandle, os_mbuf* om) { } void DfuService::OnTimeout() { + bleController.State(Pinetime::Controllers::Ble::FirmwareUpdateStates::Error); Reset(); } @@ -302,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); } |
