From 24753622c124d301ed892a23987dbbfc7690b7d4 Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk <66371704+kkasperczyk-no@users.noreply.github.com> Date: Thu, 13 Jul 2023 17:07:59 +0200 Subject: [PATCH] [ota-requestor] Added update cancelling in case of apply failure (#27591) The Ota Requestor's Apply API returns CHIP_ERROR, however it is not handled by the DefaultOTARequestorDriver. Added cancelling update in case of Apply failure to reset the OTA Requestor state and prevent stucking in kApplying state. --- .../clusters/ota-requestor/DefaultOTARequestorDriver.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp index 1a8fda8f322c24..60cc54277c36cd 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp +++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp @@ -192,7 +192,11 @@ void DefaultOTARequestorDriver::ApplyTimerHandler(System::Layer * systemLayer, v DefaultOTARequestorDriver * driver = ToDriver(appState); VerifyOrDie(driver->mImageProcessor != nullptr); - driver->mImageProcessor->Apply(); + + if (driver->mImageProcessor->Apply() != CHIP_NO_ERROR) + { + driver->mRequestor->CancelImageUpdate(); + } } void DefaultOTARequestorDriver::UpdateAvailable(const UpdateDescription & update, System::Clock::Seconds32 delay)