Skip to content

Commit

Permalink
Added ClearThreadStack Helper
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs committed Jul 18, 2024
1 parent a82a2bb commit bc000ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 2 additions & 5 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#if CHIP_ENABLE_OPENTHREAD
#include <platform/OpenThread/OpenThreadUtils.h>
#include <platform/ThreadStackManager.h>
#include <platform/silabs/ConfigurationManagerImpl.h>
#include <platform/silabs/ThreadStackManagerImpl.h>
#endif // CHIP_ENABLE_OPENTHREAD

Expand Down Expand Up @@ -801,11 +802,7 @@ void BaseApplication::DoProvisioningReset()
{
PlatformMgr().ScheduleWork([](intptr_t) {
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
ThreadStackMgr().ClearAllSrpHostAndServices();
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
ChipLogProgress(DeviceLayer, "Clearing Thread provision");
chip::DeviceLayer::ConnectivityMgr().ErasePersistentInfo();
ConfigurationManagerImpl::GetDefaultInstance().ClearThreadStack();
ThreadStackMgrImpl().FactoryResetThreadStack();
ThreadStackMgr().InitThreadStack();
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
Expand Down
16 changes: 11 additions & 5 deletions src/platform/silabs/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,16 @@ void ConfigurationManagerImpl::RunConfigUnitTest(void)
#endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST
}

/// @brief Helper to erase Thread info from device
void ConfigurationManagerImpl::ClearThreadStack()
{
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
ThreadStackMgr().ClearAllSrpHostAndServices();
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
ChipLogProgress(DeviceLayer, "Clearing Thread provision");
ThreadStackMgr().ErasePersistentInfo();
}

void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
{
CHIP_ERROR err;
Expand All @@ -273,11 +283,7 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
}

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
ThreadStackMgr().ClearAllSrpHostAndServices();
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT
ChipLogProgress(DeviceLayer, "Clearing Thread provision");
ThreadStackMgr().ErasePersistentInfo();
GetDefaultInstance().ClearThreadStack();
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD

PersistedStorage::KeyValueStoreMgrImpl().ErasePartition();
Expand Down
2 changes: 2 additions & 0 deletions src/platform/silabs/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours);
CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours);

void ClearThreadStack();

private:
// ===== Members that implement the ConfigurationManager public interface.

Expand Down

0 comments on commit bc000ac

Please sign in to comment.