Skip to content

Commit

Permalink
Merge pull request project-chip#107 from lukgni/power_reset
Browse files Browse the repository at this point in the history
Add system_reset() call to DoFactoryReset() function.
  • Loading branch information
pan- authored Mar 17, 2021
2 parents 063a697 + 2ced795 commit 5cb1b58
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/platform/mbed/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@
* for mbed platforms.
*/
/* this file behaves like a config.h, comes first */

// FIXME: Undefine the `sleep()` function included by the CHIPDeviceLayer.h
// from unistd.h to avoid a conflicting declaration with the `sleep()` provided
// by Mbed-OS in mbed_power_mgmt.h.
#define sleep unistd_sleep
#include <platform/internal/CHIPDeviceLayerInternal.h>
#undef sleep

#include <platform/internal/GenericConfigurationManagerImpl.cpp>

#include <platform/ConfigurationManager.h>

// mbed-os headers
#include "platform/mbed_power_mgmt.h"

namespace chip {
namespace DeviceLayer {

Expand Down Expand Up @@ -70,7 +79,16 @@ CHIP_ERROR ConfigurationManagerImpl::_WritePersistedStorageValue(::chip::Platfor

void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
{
FactoryResetConfig();
ChipLogProgress(DeviceLayer, "Performing factory reset");
const CHIP_ERROR err = FactoryResetConfig();
if (err != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "FactoryResetConfig() failed: %s", ErrorStr(err));
}

// Restart the system.
ChipLogProgress(DeviceLayer, "System restarting");
system_reset();
}

} // namespace DeviceLayer
Expand Down

0 comments on commit 5cb1b58

Please sign in to comment.