From 6aaaeeefa6bf6d3d54b90d66812a22e5653dcff0 Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Wed, 20 Apr 2022 17:46:34 +0530 Subject: [PATCH] Resolved merge conflicts and addressed review comment --- .../esp32/main/CMakeLists.txt | 2 + .../esp32/main/DeviceCallbacks.cpp | 17 ++++++- examples/all-clusters-app/esp32/main/main.cpp | 31 +----------- .../lighting-app/esp32/main/CMakeLists.txt | 2 + .../esp32/main/DeviceCallbacks.cpp | 17 ++++++- examples/lighting-app/esp32/main/main.cpp | 29 +---------- .../esp32/main/CMakeLists.txt | 6 ++- .../esp32/main/DeviceCallbacks.cpp | 16 ++++++- .../ota-requestor-app/esp32/main/main.cpp | 23 +-------- examples/platform/esp32/ota/InitOTAR.cpp | 31 ++++++++++++ examples/platform/esp32/ota/InitOTAR.h | 48 +++++++++++++++++++ .../DefaultOTARequestorDriver.cpp | 35 +++++--------- .../ota-requestor/DefaultOTARequestorDriver.h | 1 - 13 files changed, 150 insertions(+), 108 deletions(-) create mode 100644 examples/platform/esp32/ota/InitOTAR.cpp create mode 100644 examples/platform/esp32/ota/InitOTAR.h diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 0d6e9b0007c1b9..99600c5d19fb60 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -21,6 +21,7 @@ set(PRIV_INCLUDE_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/all-clusters-app" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/include" "${CMAKE_CURRENT_LIST_DIR}/include" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip" ) set(SRC_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}" @@ -28,6 +29,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/route_hook" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" diff --git a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp index 44f242971a8a6b..499be4c2f0c6a7 100644 --- a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -55,7 +56,8 @@ using namespace ::chip::System; using namespace ::chip::DeviceLayer; using namespace chip::app; -constexpr uint32_t kIdentifyTimerDelayMS = 250; +constexpr uint32_t kIdentifyTimerDelayMS = 250; +constexpr uint32_t mInitOTARequestorDelaySec = 3; void OnIdentifyTriggerEffect(Identify * identify) { @@ -200,13 +202,26 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster ESP_LOGI(TAG, "Current free heap: %zu\n", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } +void InitOTARequestorHandler(System::Layer * systemLayer, void * appState) +{ + InitOTA::Instance().InitOTARequestor(); +} + void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event) { + static bool IsOTAInitialized = false; if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); wifiLED.Set(true); chip::app::DnssdServer::Instance().StartServer(); + + if (!IsOTAInitialized) + { + chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(mInitOTARequestorDelaySec), + InitOTARequestorHandler, nullptr); + IsOTAInitialized = true; + } } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) { diff --git a/examples/all-clusters-app/esp32/main/main.cpp b/examples/all-clusters-app/esp32/main/main.cpp index 4d5d923a5ca2b3..0638b838d77e9d 100644 --- a/examples/all-clusters-app/esp32/main/main.cpp +++ b/examples/all-clusters-app/esp32/main/main.cpp @@ -37,17 +37,12 @@ #include "shell_extension/launch.h" #include -#include -#include -#include -#include #include #include #include #include #include #include -#include #if CONFIG_HAVE_DISPLAY #include "DeviceWithDisplay.h" @@ -70,21 +65,12 @@ using namespace ::chip::DeviceLayer; // Used to indicate that an IP address has been added to the QRCode #define EXAMPLE_VENDOR_TAG_IP 1 -const char * TAG = "all-clusters-app"; -const uint32_t delayConfirmImageSec = 10; +const char * TAG = "all-clusters-app"; static DeviceCallbacks EchoCallbacks; namespace { -#if CONFIG_ENABLE_OTA_REQUESTOR -DefaultOTARequestor gRequestorCore; -DefaultOTARequestorStorage gRequestorStorage; -DefaultOTARequestorDriver gRequestorUser; -BDXDownloader gDownloader; -OTAImageProcessorImpl gImageProcessor; -#endif - app::Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::ESPWiFiDriver::GetInstance())); @@ -107,19 +93,6 @@ constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; } // namespace -static void InitOTARequestor(void) -{ -#if CONFIG_ENABLE_OTA_REQUESTOR - SetRequestorInstance(&gRequestorCore); - gRequestorStorage.Init(Server::GetInstance().GetPersistentStorage()); - gRequestorCore.Init(Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); - gImageProcessor.SetOTADownloader(&gDownloader); - gDownloader.SetImageProcessorDelegate(&gImageProcessor); - gRequestorUser.SetDelayConfirmCurrentImageSec(delayConfirmImageSec); - gRequestorUser.Init(&gRequestorCore, &gImageProcessor); -#endif -} - static void InitServer(intptr_t context) { // Init ZCL Data Model and CHIP App Server @@ -138,8 +111,6 @@ static void InitServer(intptr_t context) #if CONFIG_DEVICE_TYPE_M5STACK SetupPretendDevices(); #endif - - InitOTARequestor(); } extern "C" void app_main() diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index 3a81faaf0f0394..ff6715bd8e8b29 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -20,12 +20,14 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/lighting-app" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lighting-app/lighting-common/color_format" "${CMAKE_CURRENT_LIST_DIR}/include" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip" SRC_DIRS "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/lighting-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/route_hook" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lighting-app/lighting-common/color_format" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" diff --git a/examples/lighting-app/esp32/main/DeviceCallbacks.cpp b/examples/lighting-app/esp32/main/DeviceCallbacks.cpp index 6a77f7d80342c9..75e04bf1a44c54 100644 --- a/examples/lighting-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/esp32/main/DeviceCallbacks.cpp @@ -37,9 +37,11 @@ #include #include #include +#include #include -static const char * TAG = "light-app-callbacks"; +static const char * TAG = "light-app-callbacks"; +constexpr uint32_t mInitOTARequestorDelaySec = 3; extern LEDWidget AppLED; @@ -149,12 +151,25 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster ESP_LOGI(TAG, "Current free heap: %zu\n", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } +void InitOTARequestorHandler(System::Layer * systemLayer, void * appState) +{ + InitOTA::Instance().InitOTARequestor(); +} + void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event) { + static bool IsOTAInitialized = false; if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); chip::app::DnssdServer::Instance().StartServer(); + + if (!IsOTAInitialized) + { + chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(mInitOTARequestorDelaySec), + InitOTARequestorHandler, nullptr); + IsOTAInitialized = true; + } } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) { diff --git a/examples/lighting-app/esp32/main/main.cpp b/examples/lighting-app/esp32/main/main.cpp index 533772c1c5400e..838b77a1234d09 100644 --- a/examples/lighting-app/esp32/main/main.cpp +++ b/examples/lighting-app/esp32/main/main.cpp @@ -27,17 +27,12 @@ #include "nvs_flash.h" #include "shell_extension/launch.h" #include -#include -#include -#include -#include #include #include #include #include #include #include -#include #if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER #include @@ -48,18 +43,9 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; -#if CONFIG_ENABLE_OTA_REQUESTOR -DefaultOTARequestor gRequestorCore; -DefaultOTARequestorStorage gRequestorStorage; -DefaultOTARequestorDriver gRequestorUser; -BDXDownloader gDownloader; -OTAImageProcessorImpl gImageProcessor; -#endif - LEDWidget AppLED; -static const char * TAG = "light-app"; -const uint32_t delayConfirmImageSec = 10; +static const char * TAG = "light-app"; static DeviceCallbacks EchoCallbacks; namespace { @@ -73,19 +59,6 @@ ESP32FactoryDataProvider sFactoryDataProvider; #endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER } // namespace -static void InitOTARequestor(void) -{ -#if CONFIG_ENABLE_OTA_REQUESTOR - SetRequestorInstance(&gRequestorCore); - gRequestorStorage.Init(Server::GetInstance().GetPersistentStorage()); - gRequestorCore.Init(Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); - gImageProcessor.SetOTADownloader(&gDownloader); - gDownloader.SetImageProcessorDelegate(&gImageProcessor); - gRequestorUser.SetDelayConfirmCurrentImageSec(delayConfirmImageSec); - gRequestorUser.Init(&gRequestorCore, &gImageProcessor); -#endif -} - static void InitServer(intptr_t context) { // Print QR Code URL diff --git a/examples/ota-requestor-app/esp32/main/CMakeLists.txt b/examples/ota-requestor-app/esp32/main/CMakeLists.txt index 08f878c56b683f..e9623612bb6a58 100644 --- a/examples/ota-requestor-app/esp32/main/CMakeLists.txt +++ b/examples/ota-requestor-app/esp32/main/CMakeLists.txt @@ -20,7 +20,8 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/ota-requestor-app/" - SRC_DIRS + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip" + SRC_DIRS "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/ota-requestor-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" @@ -49,7 +50,8 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" - PRIV_REQUIRES chip QRCode bt console app_update) + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota" + PRIV_REQUIRES chip QRCode bt console app_update) set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 14) target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H") diff --git a/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp b/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp index 043d452011e7a4..c7fdb12b64b26f 100644 --- a/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp @@ -29,9 +29,11 @@ #include #include #include +#include #include -static const char * TAG = "echo-devicecallbacks"; +static const char * TAG = "echo-devicecallbacks"; +constexpr uint32_t mInitOTARequestorDelaySec = 3; using namespace ::chip; using namespace ::chip::Inet; @@ -78,12 +80,24 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster ESP_LOGI(TAG, "Current free heap: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } +void InitOTARequestorHandler(System::Layer * systemLayer, void * appState) +{ + InitOTA::Instance().InitOTARequestor(); +} + void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event) { + static bool IsOTAInitialized = false; if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT); chip::app::DnssdServer::Instance().StartServer(); + if (!IsOTAInitialized) + { + chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(mInitOTARequestorDelaySec), + InitOTARequestorHandler, nullptr); + IsOTAInitialized = true; + } } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) { diff --git a/examples/ota-requestor-app/esp32/main/main.cpp b/examples/ota-requestor-app/esp32/main/main.cpp index dd129a00022d31..02adf0680655ae 100644 --- a/examples/ota-requestor-app/esp32/main/main.cpp +++ b/examples/ota-requestor-app/esp32/main/main.cpp @@ -29,10 +29,6 @@ #include "freertos/task.h" #include "nvs_flash.h" #include -#include -#include -#include -#include #include #include @@ -41,8 +37,6 @@ #include -#include "OTAImageProcessorImpl.h" - using namespace ::chip; using namespace ::chip::System; using namespace ::chip::Credentials; @@ -50,16 +44,9 @@ using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; namespace { -const char * TAG = "ota-requester-app"; -const uint32_t delayConfirmImageSec = 10; +const char * TAG = "ota-requester-app"; static DeviceCallbacks EchoCallbacks; -DefaultOTARequestor gRequestorCore; -DefaultOTARequestorStorage gRequestorStorage; -DefaultOTARequestorDriver gRequestorUser; -BDXDownloader gDownloader; -OTAImageProcessorImpl gImageProcessor; - app::Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::ESPWiFiDriver::GetInstance())); @@ -73,14 +60,6 @@ static void InitServer(intptr_t context) SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); sWiFiNetworkCommissioningInstance.Init(); - - SetRequestorInstance(&gRequestorCore); - gRequestorStorage.Init(Server::GetInstance().GetPersistentStorage()); - gRequestorCore.Init(Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); - gImageProcessor.SetOTADownloader(&gDownloader); - gDownloader.SetImageProcessorDelegate(&gImageProcessor); - gRequestorUser.SetDelayConfirmCurrentImageSec(delayConfirmImageSec); - gRequestorUser.Init(&gRequestorCore, &gImageProcessor); } } // namespace diff --git a/examples/platform/esp32/ota/InitOTAR.cpp b/examples/platform/esp32/ota/InitOTAR.cpp new file mode 100644 index 00000000000000..abc759a6b87fa8 --- /dev/null +++ b/examples/platform/esp32/ota/InitOTAR.cpp @@ -0,0 +1,31 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "InitOTAR.h" + +void InitOTA::InitOTARequestor() +{ + +#if CONFIG_ENABLE_OTA_REQUESTOR + SetRequestorInstance(&gRequestorCore); + gRequestorStorage.Init(Server::GetInstance().GetPersistentStorage()); + gRequestorCore.Init(Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); + gImageProcessor.SetOTADownloader(&gDownloader); + gDownloader.SetImageProcessorDelegate(&gImageProcessor); + gRequestorUser.Init(&gRequestorCore, &gImageProcessor); +#endif +} diff --git a/examples/platform/esp32/ota/InitOTAR.h b/examples/platform/esp32/ota/InitOTAR.h new file mode 100644 index 00000000000000..682d526a6c641f --- /dev/null +++ b/examples/platform/esp32/ota/InitOTAR.h @@ -0,0 +1,48 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include +#include +#include +#include +#include + +using namespace chip::DeviceLayer; +using namespace chip; + +namespace { + +#if CONFIG_ENABLE_OTA_REQUESTOR +DefaultOTARequestor gRequestorCore; +DefaultOTARequestorStorage gRequestorStorage; +DefaultOTARequestorDriver gRequestorUser; +BDXDownloader gDownloader; +OTAImageProcessorImpl gImageProcessor; +#endif +} // namespace + +class InitOTA +{ +public: + static InitOTA & Instance(void) + { + static InitOTA sInitOTA; + return sInitOTA; + } + void InitOTARequestor(void); +}; diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp index ded8bceef2fe44..7e710f7c2bd5cb 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp +++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.cpp @@ -48,8 +48,6 @@ using namespace app::Clusters::OtaSoftwareUpdateRequestor::Structs; constexpr uint32_t kDelayQueryUponCommissioningSec = 30; // Delay before sending the initial image query after commissioning constexpr uint32_t kImmediateStartDelaySec = 1; // Delay before sending a query in response to UrgentUpdateAvailable constexpr System::Clock::Seconds32 kDefaultDelayedActionTime = System::Clock::Seconds32(120); -System::Clock::Seconds32 mDelayConfirmCurrentImageSec = - System::Clock::Seconds32(0); // Delay before confirming current image (in seconds) DefaultOTARequestorDriver * ToDriver(void * context) { @@ -58,12 +56,7 @@ DefaultOTARequestorDriver * ToDriver(void * context) } // namespace -void GenericOTARequestorDriver::SetDelayConfirmCurrentImageSec(uint32_t seconds) -{ - mDelayConfirmCurrentImageSec = System::Clock::Seconds32(seconds); -} - -void GenericOTARequestorDriver::Init(OTARequestorInterface * requestor, OTAImageProcessorInterface * processor) +void DefaultOTARequestorDriver::Init(OTARequestorInterface * requestor, OTAImageProcessorInterface * processor) { mRequestor = requestor; mImageProcessor = processor; @@ -71,20 +64,18 @@ void GenericOTARequestorDriver::Init(OTARequestorInterface * requestor, OTAImage if (mImageProcessor->IsFirstImageRun()) { - ScheduleDelayedAction( - mDelayConfirmCurrentImageSec, - [](System::Layer *, void * context) { - CHIP_ERROR error = ToDriver(context)->mImageProcessor->ConfirmCurrentImage(); - if (error != CHIP_NO_ERROR) - { - ChipLogError(SoftwareUpdate, "Failed to confirm image: %" CHIP_ERROR_FORMAT, error.Format()); - ToDriver(context)->mRequestor->Reset(); - return; - } - - ToDriver(context)->mRequestor->NotifyUpdateApplied(); - }, - this); + SystemLayer().ScheduleLambda([this] { + CHIP_ERROR error = mImageProcessor->ConfirmCurrentImage(); + + if (error != CHIP_NO_ERROR) + { + ChipLogError(SoftwareUpdate, "Failed to confirm image: %" CHIP_ERROR_FORMAT, error.Format()); + mRequestor->Reset(); + return; + } + + mRequestor->NotifyUpdateApplied(); + }); } else if ((mRequestor->GetCurrentUpdateState() != OTAUpdateStateEnum::kIdle)) { diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h index 21f2ef8ac0a036..24df0922156433 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h +++ b/src/app/clusters/ota-requestor/DefaultOTARequestorDriver.h @@ -80,7 +80,6 @@ class DefaultOTARequestorDriver : public OTARequestorDriver app::Clusters::OtaSoftwareUpdateRequestor::OTAAnnouncementReason announcementReason) override; void SendQueryImage() override; bool GetNextProviderLocation(ProviderLocationType & providerLocation, bool & listExhausted) override; - void SetDelayConfirmCurrentImageSec(uint32_t seconds); protected: void StartPeriodicQueryTimer();