diff --git a/examples/all-clusters-app/esp32/main/main.cpp b/examples/all-clusters-app/esp32/main/main.cpp index 9e6693bca9c0c8..fbedc0b0b2e1d4 100644 --- a/examples/all-clusters-app/esp32/main/main.cpp +++ b/examples/all-clusters-app/esp32/main/main.cpp @@ -453,7 +453,7 @@ class SetupListModel : public TouchesMatterStackModel } else if (i == 1) { - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } else if (i == 2) { diff --git a/examples/light-switch-app/efr32/src/AppTask.cpp b/examples/light-switch-app/efr32/src/AppTask.cpp index d7441a6f892ccc..59d04eaefe3553 100644 --- a/examples/light-switch-app/efr32/src/AppTask.cpp +++ b/examples/light-switch-app/efr32/src/AppTask.cpp @@ -411,7 +411,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lighting-app/efr32/src/AppTask.cpp b/examples/lighting-app/efr32/src/AppTask.cpp index 14fc7e0f1de65a..bfdfbfbd7a72d0 100644 --- a/examples/lighting-app/efr32/src/AppTask.cpp +++ b/examples/lighting-app/efr32/src/AppTask.cpp @@ -494,7 +494,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lighting-app/mbed/main/AppTask.cpp b/examples/lighting-app/mbed/main/AppTask.cpp index d34f25d2e58bd5..95499a67efbf1b 100644 --- a/examples/lighting-app/mbed/main/AppTask.cpp +++ b/examples/lighting-app/mbed/main/AppTask.cpp @@ -399,7 +399,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) // Actually trigger Factory Reset ChipLogProgress(NotSpecified, "Factory Reset initiated"); sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index c2418d6b089d75..d2f65991daffd0 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -318,7 +318,8 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp index acf053e0ac2cd2..dc6e355423567d 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -384,7 +384,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) K32W_LOG("Device will factory reset..."); // Actually trigger Factory Reset - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } void AppTask::ResetActionEventHandler(AppEvent * aEvent) diff --git a/examples/lighting-app/p6/src/AppTask.cpp b/examples/lighting-app/p6/src/AppTask.cpp index 8e04f710716515..ab50aefb66f9c3 100644 --- a/examples/lighting-app/p6/src/AppTask.cpp +++ b/examples/lighting-app/p6/src/AppTask.cpp @@ -335,7 +335,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = Function::kNoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lighting-app/qpg/src/AppTask.cpp b/examples/lighting-app/qpg/src/AppTask.cpp index fb8f111c803b9b..9756e8f97cad7a 100644 --- a/examples/lighting-app/qpg/src/AppTask.cpp +++ b/examples/lighting-app/qpg/src/AppTask.cpp @@ -305,7 +305,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index fc2be9cf84ab4a..5602acc36ca53d 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -215,7 +215,7 @@ void AppTask::FactoryResetButtonEventHandler(void) void AppTask::FactoryResetHandler(AppEvent * aEvent) { LOG_INF("Factory Reset triggered."); - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } void AppTask::StartThreadButtonEventHandler(void) diff --git a/examples/lock-app/efr32/src/AppTask.cpp b/examples/lock-app/efr32/src/AppTask.cpp index eb96b266eb755f..8cc4ac24949f31 100644 --- a/examples/lock-app/efr32/src/AppTask.cpp +++ b/examples/lock-app/efr32/src/AppTask.cpp @@ -363,7 +363,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lock-app/esp32/main/AppTask.cpp b/examples/lock-app/esp32/main/AppTask.cpp index df3cd9cf3437c8..7b5a727b4dab54 100644 --- a/examples/lock-app/esp32/main/AppTask.cpp +++ b/examples/lock-app/esp32/main/AppTask.cpp @@ -298,7 +298,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lock-app/mbed/main/AppTask.cpp b/examples/lock-app/mbed/main/AppTask.cpp index 9ddcba2a9d820a..283efadca06fc6 100644 --- a/examples/lock-app/mbed/main/AppTask.cpp +++ b/examples/lock-app/mbed/main/AppTask.cpp @@ -395,7 +395,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) // Actually trigger Factory Reset ChipLogProgress(NotSpecified, "Factory Reset initiated"); sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp index c975c78c2f8f14..794102bf3d1ec8 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -268,7 +268,8 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp index fe96162c112cd9..43ec8f51af9080 100644 --- a/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -357,7 +357,7 @@ void AppTask::FunctionTimerEventHandler(void * aGenericEvent) K32W_LOG("Device will factory reset..."); // Actually trigger Factory Reset - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } void AppTask::ResetActionEventHandler(void * aGenericEvent) diff --git a/examples/lock-app/p6/src/AppTask.cpp b/examples/lock-app/p6/src/AppTask.cpp index 74c40151eefe95..a4e0cbb5e35739 100644 --- a/examples/lock-app/p6/src/AppTask.cpp +++ b/examples/lock-app/p6/src/AppTask.cpp @@ -331,7 +331,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * event) { // Actually trigger Factory Reset sAppTask.mFunction = Function::kNoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/lock-app/qpg/src/AppTask.cpp b/examples/lock-app/qpg/src/AppTask.cpp index 266b96a188dbf7..11e4cc0c067648 100644 --- a/examples/lock-app/qpg/src/AppTask.cpp +++ b/examples/lock-app/qpg/src/AppTask.cpp @@ -315,7 +315,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/ota-requestor-app/efr32/src/AppTask.cpp b/examples/ota-requestor-app/efr32/src/AppTask.cpp index d2acbba1a8850d..32fd097006d56b 100644 --- a/examples/ota-requestor-app/efr32/src/AppTask.cpp +++ b/examples/ota-requestor-app/efr32/src/AppTask.cpp @@ -350,7 +350,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/ota-requestor-app/mbed/main/AppTask.cpp b/examples/ota-requestor-app/mbed/main/AppTask.cpp index 1518bacc8de181..f312c17f5690cd 100644 --- a/examples/ota-requestor-app/mbed/main/AppTask.cpp +++ b/examples/ota-requestor-app/mbed/main/AppTask.cpp @@ -416,7 +416,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) sAppTask.CancelTimer(kFunction_Button_1); sAppTask.mFunction[kFunction_Button_1] = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } break; case kFunction_Button_2: diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index 199b8f593c9dd8..f4ed5ff6ff60f5 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -352,7 +352,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } else if (AppEvent::kAppEventButtonType_LongPressed == aEvent->ButtonEvent.Type) { - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } break; diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index 50dbb5224b5533..832b103a68cac9 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -267,7 +267,8 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp index ee332a4dadbd10..e394f5574f58df 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -335,7 +335,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } else if (AppEvent::kAppEventButtonType_LongPressed == aEvent->ButtonEvent.Type) { - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } break; diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index 267bfaf7fa5926..1d8d85b3955921 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -263,7 +263,8 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { // Actually trigger Factory Reset sAppTask.mFunction = kFunction_NoneSelected; - ConfigurationMgr().InitiateFactoryReset(); + + chip::Server::GetInstance().ScheduleFactoryReset(); } } diff --git a/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp b/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp index 77c6107b63fed1..33eb5e72ccb29e 100644 --- a/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp @@ -286,7 +286,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) K32W_LOG("Device will factory reset..."); // Actually trigger Factory Reset - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); } void AppTask::ResetActionEventHandler(AppEvent * aEvent) diff --git a/examples/window-app/common/src/WindowApp.cpp b/examples/window-app/common/src/WindowApp.cpp index f00b01379da8e4..a553b6692d05d2 100644 --- a/examples/window-app/common/src/WindowApp.cpp +++ b/examples/window-app/common/src/WindowApp.cpp @@ -215,7 +215,7 @@ void WindowApp::DispatchEvent(const WindowApp::Event & event) break; case EventId::Reset: - ConfigurationMgr().InitiateFactoryReset(); + chip::Server::GetInstance().ScheduleFactoryReset(); break; case EventId::UpPressed: diff --git a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp index 9283182c9d9dcf..aad5df69f167ef 100644 --- a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp +++ b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp @@ -195,11 +195,24 @@ class GeneralDiagnosticsDelegate : public DeviceLayer::ConnectivityManagerDelega } // Gets called when the device has been rebooted. - void OnDeviceRebooted() override + void OnDeviceRebooted(uint8_t bootReason) override { ChipLogProgress(Zcl, "GeneralDiagnosticsDelegate: OnDeviceRebooted"); ReportAttributeOnAllEndpoints(GeneralDiagnostics::Attributes::BootReasons::Id); + + for (auto endpoint : EnabledEndpointsWithServerCluster(GeneralDiagnostics::Id)) + { + Events::BootReason::Type event{ static_cast(bootReason) }; + EventNumber eventNumber; + + CHIP_ERROR err = LogEvent(event, endpoint, eventNumber, EventOptions::Type::kUrgent); + if (CHIP_NO_ERROR != err) + { + ChipLogError(Zcl, "GeneralDiagnosticsDelegate: Failed to record BootReason event: %" CHIP_ERROR_FORMAT, + err.Format()); + } + } } // Get called when the Node detects a hardware fault has been raised. diff --git a/src/app/reporting/Engine.h b/src/app/reporting/Engine.h index 9b8c74e1c08ffb..c74cc26d881ad6 100644 --- a/src/app/reporting/Engine.h +++ b/src/app/reporting/Engine.h @@ -120,6 +120,8 @@ class Engine uint32_t GetNumReportsInFlight() { return mNumReportsInFlight; } + void ScheduleUrgentEventDeliverySync(); + private: friend class TestReportingEngine; /** @@ -165,7 +167,6 @@ class Engine CHIP_ERROR ScheduleUrgentEventDelivery(ConcreteEventPath & aPath); CHIP_ERROR ScheduleBufferPressureEventDelivery(uint32_t aBytesWritten); void GetMinEventLogPosition(uint32_t & aMinLogPosition); - void ScheduleUrgentEventDeliverySync(); /** * If the provided path is a superset of our of our existing paths, update that existing path to match the diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 0cd4642f09ec30..541d5de785ec19 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -298,6 +298,25 @@ void Server::DispatchShutDownAndStopEventLoop() chip::DeviceLayer::PlatformMgr().ScheduleWork(StopEventLoop); } +void Server::ScheduleFactoryReset() +{ + chip::DeviceLayer::PlatformMgr().ScheduleWork(FactoryReset); +} + +void Server::FactoryReset(intptr_t arg) +{ + // Delete all fabrics and emit Leave event. + GetInstance().GetFabricTable().DeleteAllFabrics(); + + // Emit Shutdown event, as shutdown will come after factory reset. + DispatchShutDownEvent(0); + + // Flush all dispatched events. + chip::app::InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleUrgentEventDeliverySync(); + + chip::DeviceLayer::ConfigurationMgr().InitiateFactoryReset(); +} + void Server::Shutdown() { chip::Dnssd::ServiceAdvertiser::Instance().Shutdown(); diff --git a/src/app/server/Server.h b/src/app/server/Server.h index 5ea0a2c36a4f1c..f73b54a1d6672e 100644 --- a/src/app/server/Server.h +++ b/src/app/server/Server.h @@ -95,6 +95,10 @@ class Server void Shutdown(); + void ScheduleFactoryReset(); + + static void FactoryReset(intptr_t arg); + static Server & GetInstance() { return sServer; } private: diff --git a/src/include/platform/DiagnosticDataProvider.h b/src/include/platform/DiagnosticDataProvider.h index 4c428d671edfd3..d9bc2ffd615902 100644 --- a/src/include/platform/DiagnosticDataProvider.h +++ b/src/include/platform/DiagnosticDataProvider.h @@ -70,7 +70,7 @@ class GeneralDiagnosticsDelegate * @brief * Called after the current device is rebooted. */ - virtual void OnDeviceRebooted() {} + virtual void OnDeviceRebooted(uint8_t bootReason) {} /** * @brief diff --git a/src/include/platform/internal/GenericPlatformManagerImpl.cpp b/src/include/platform/internal/GenericPlatformManagerImpl.cpp index 1f1f17172e059c..fdd2f3b6dad160 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl.cpp +++ b/src/include/platform/internal/GenericPlatformManagerImpl.cpp @@ -298,7 +298,10 @@ void GenericPlatformManagerImpl::HandleDeviceRebooted(intptr_t arg) if (generalDiagnosticsDelegate != nullptr) { - generalDiagnosticsDelegate->OnDeviceRebooted(); + uint8_t bootReason; + + if (GetDiagnosticDataProvider().GetBootReason(bootReason) == CHIP_NO_ERROR) + generalDiagnosticsDelegate->OnDeviceRebooted(bootReason); } // The StartUp event SHALL be emitted by a Node after completing a boot or reboot process @@ -306,8 +309,8 @@ void GenericPlatformManagerImpl::HandleDeviceRebooted(intptr_t arg) { uint32_t softwareVersion; - ReturnOnFailure(ConfigurationMgr().GetSoftwareVersion(softwareVersion)); - platformManagerDelegate->OnStartUp(softwareVersion); + if (ConfigurationMgr().GetSoftwareVersion(softwareVersion) == CHIP_NO_ERROR) + platformManagerDelegate->OnStartUp(softwareVersion); } } diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.cpp b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.cpp index 6b4d5996d250be..606663face82f4 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.cpp +++ b/src/include/platform/internal/GenericPlatformManagerImpl_Zephyr.cpp @@ -35,6 +35,8 @@ #include #include +#include + #define DEFAULT_MIN_SLEEP_PERIOD (60 * 60 * 24 * 30) // Month [sec] namespace chip { @@ -46,6 +48,7 @@ System::LayerSocketsLoop & SystemLayerSocketsLoop() { return static_cast(DeviceLayer::SystemLayer()); } + } // anonymous namespace // Fully instantiate the generic implementation class in whatever compilation unit includes this file. @@ -106,7 +109,12 @@ CHIP_ERROR GenericPlatformManagerImpl_Zephyr::_StopEventLoopTask(void template CHIP_ERROR GenericPlatformManagerImpl_Zephyr::_Shutdown(void) { +#if CONFIG_REBOOT + sys_reboot(SYS_REBOOT_WARM); + return CHIP_NO_ERROR; +#else return CHIP_ERROR_NOT_IMPLEMENTED; +#endif } template diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.cpp b/src/platform/Zephyr/ConfigurationManagerImpl.cpp index 65f95d9c3c3e40..33add147262079 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.cpp +++ b/src/platform/Zephyr/ConfigurationManagerImpl.cpp @@ -36,8 +36,6 @@ #include #include -#include - namespace chip { namespace DeviceLayer { @@ -204,9 +202,7 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) ThreadStackMgr().ErasePersistentInfo(); #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD -#if CONFIG_REBOOT - sys_reboot(SYS_REBOOT_WARM); -#endif + PlatformMgr().Shutdown(); } } // namespace DeviceLayer diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.h b/src/platform/Zephyr/ConfigurationManagerImpl.h index 44d66d3ab63e15..e678b5a5146868 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.h +++ b/src/platform/Zephyr/ConfigurationManagerImpl.h @@ -81,7 +81,12 @@ inline bool ConfigurationManagerImpl::CanFactoryReset() inline CHIP_ERROR ConfigurationManagerImpl::ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) { - return Internal::ZephyrConfig::ReadConfigValueCounter(key, value); + CHIP_ERROR err = Internal::ZephyrConfig::ReadConfigValueCounter(key, value); + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + return err; } inline CHIP_ERROR ConfigurationManagerImpl::WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value)