From 74df6d267880c1b01c06b3b86c89589960509af4 Mon Sep 17 00:00:00 2001 From: Dina Benamar Date: Tue, 28 Nov 2023 14:29:51 +0100 Subject: [PATCH] [COMMON] Remove circular dependency with application code in platform file * Github issue #30599 : [NXP] Layering inversion in ConfigurationmanagerImpl.cpp https://github.com/project-chip/connectedhomeip/issues/30599 --- examples/all-clusters-app/nxp/common/main/AppTask.cpp | 4 +++- src/platform/nxp/common/ConfigurationManagerImpl.cpp | 8 +------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/examples/all-clusters-app/nxp/common/main/AppTask.cpp b/examples/all-clusters-app/nxp/common/main/AppTask.cpp index a0304c78648e01..aba4c7f4922b52 100644 --- a/examples/all-clusters-app/nxp/common/main/AppTask.cpp +++ b/examples/all-clusters-app/nxp/common/main/AppTask.cpp @@ -492,5 +492,7 @@ void AppTask::SwitchCommissioningStateHandler(void) void AppTask::FactoryResetHandler(void) { - ConfigurationMgr().InitiateFactoryReset(); + /* Emit the ShutDown event before factory reset */ + chip::Server::GetInstance().GenerateShutDownEvent(); + chip::Server::GetInstance().ScheduleFactoryReset(); } diff --git a/src/platform/nxp/common/ConfigurationManagerImpl.cpp b/src/platform/nxp/common/ConfigurationManagerImpl.cpp index b14f551df63654..e99f913369eda8 100644 --- a/src/platform/nxp/common/ConfigurationManagerImpl.cpp +++ b/src/platform/nxp/common/ConfigurationManagerImpl.cpp @@ -27,7 +27,6 @@ #include #include "NXPConfig.h" -#include #include #include #include @@ -148,12 +147,7 @@ bool ConfigurationManagerImpl::CanFactoryReset() void ConfigurationManagerImpl::InitiateFactoryReset() { - PlatformMgr().ScheduleWork([](intptr_t) { - // Emit ShutDown event and delete all fabrics. - PlatformMgr().HandleServerShuttingDown(); - Server::GetInstance().GetFabricTable().DeleteAllFabrics(); - DoFactoryReset(0); - }); + PlatformMgr().ScheduleWork(DoFactoryReset); } CHIP_ERROR ConfigurationManagerImpl::ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key persistedStorageKey,