Skip to content

Commit

Permalink
[nrf noup] Shedule factory reset in Server using Matter Shell command
Browse files Browse the repository at this point in the history
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 <arkadiusz.balys@nordicsemi.no>
  • Loading branch information
ArekBalysNordic committed Oct 9, 2024
1 parent 5a55d60 commit c945987
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/shell/commands/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

#include <app/server/Server.h>
#include <lib/core/CHIPCore.h>
#include <lib/shell/Commands.h>
#if CONFIG_DEVICE_LAYER
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c945987

Please sign in to comment.