diff --git a/examples/all-clusters-app/nxp/common/main/AppTask.cpp b/examples/all-clusters-app/nxp/common/main/AppTask.cpp index 3ca3af76b96349..9dc60db217cf9a 100644 --- a/examples/all-clusters-app/nxp/common/main/AppTask.cpp +++ b/examples/all-clusters-app/nxp/common/main/AppTask.cpp @@ -473,5 +473,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,