From 973259c02f828604d060ada0ea076dbbf42ab087 Mon Sep 17 00:00:00 2001 From: Arkadiusz Balys Date: Fri, 4 Oct 2024 16:00:54 +0200 Subject: [PATCH] [nrf noup] Shedule factory reset in Server using Matter Shell command It is better to call the ScheduleFactoryReset method from the Server, because it also removes all fabrics and emits the Leave event whereas calling InitiateFactoryReset() removes only the persistent storage entries. In this way, the Matter Shell command works in the same way as other factory reset sources. We cannot upmerge it in an easy way because many vendors do not use chip server and there are multiple building issues. Signed-off-by: Arkadiusz Balys --- src/lib/shell/commands/Device.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/shell/commands/Device.cpp b/src/lib/shell/commands/Device.cpp index 7e26a75a5c..5f099ffa56 100644 --- a/src/lib/shell/commands/Device.cpp +++ b/src/lib/shell/commands/Device.cpp @@ -15,6 +15,7 @@ * limitations under the License. */ +#include #include #include #if CONFIG_DEVICE_LAYER @@ -42,7 +43,11 @@ int DeviceHelpHandler(int argc, char ** argv) static CHIP_ERROR FactoryResetHandler(int argc, char ** argv) { streamer_printf(streamer_get(), "Performing factory reset ... \r\n"); +#if CHIP_CONFIG_TEST DeviceLayer::ConfigurationMgr().InitiateFactoryReset(); +#else + chip::Server::GetInstance().ScheduleFactoryReset(); +#endif // CHIP_TEST return CHIP_NO_ERROR; }