Skip to content

Commit

Permalink
Update the Ameba platform's ConfigurationManager. (#10906)
Browse files Browse the repository at this point in the history
  • Loading branch information
harimau-qirex authored and pull[bot] committed Feb 1, 2022
1 parent 442ea3f commit 1063461
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
22 changes: 11 additions & 11 deletions src/platform/Ameba/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,54 +39,54 @@ using namespace ::chip::DeviceLayer::Internal;
*/
ConfigurationManagerImpl ConfigurationManagerImpl::sInstance;

CHIP_ERROR ConfigurationManagerImpl::_Init()
CHIP_ERROR ConfigurationManagerImpl::Init()
{
CHIP_ERROR err;
bool failSafeArmed;

// Initialize the generic implementation base class.
err = Internal::GenericConfigurationManagerImpl<ConfigurationManagerImpl>::_Init();
err = Internal::GenericConfigurationManagerImpl<ConfigurationManagerImpl>::Init();
SuccessOrExit(err);

// TODO: initialize NVM component

// If the fail-safe was armed when the device last shutdown, initiate a factory reset.
if (_GetFailSafeArmed(failSafeArmed) == CHIP_NO_ERROR && failSafeArmed)
if (GetFailSafeArmed(failSafeArmed) == CHIP_NO_ERROR && failSafeArmed)
{
ChipLogProgress(DeviceLayer, "Detected fail-safe armed on reboot; initiating factory reset");
_InitiateFactoryReset();
InitiateFactoryReset();
}
err = CHIP_NO_ERROR;

exit:
return err;
}

CHIP_ERROR ConfigurationManagerImpl::_GetPrimaryWiFiMACAddress(uint8_t * buf)
CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

bool ConfigurationManagerImpl::_CanFactoryReset()
bool ConfigurationManagerImpl::CanFactoryReset()
{
// TODO: query the application to determine if factory reset is allowed.
return true;
}

void ConfigurationManagerImpl::_InitiateFactoryReset()
void ConfigurationManagerImpl::InitiateFactoryReset()
{
PlatformMgr().ScheduleWork(DoFactoryReset);
}

CHIP_ERROR ConfigurationManagerImpl::_ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key persistedStorageKey,
uint32_t & value)
CHIP_ERROR ConfigurationManagerImpl::ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key persistedStorageKey,
uint32_t & value)
{
// TODO
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

CHIP_ERROR ConfigurationManagerImpl::_WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key persistedStorageKey,
uint32_t value)
CHIP_ERROR ConfigurationManagerImpl::WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key persistedStorageKey,
uint32_t value)
{
// TODO
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
Expand Down
19 changes: 7 additions & 12 deletions src/platform/Ameba/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,9 @@ class NetworkProvisioningServerImpl;
/**
* Concrete implementation of the ConfigurationManager singleton object for the Ameba platform.
*/
class ConfigurationManagerImpl final : public ConfigurationManager,
public Internal::GenericConfigurationManagerImpl<ConfigurationManagerImpl>,
class ConfigurationManagerImpl final : public Internal::GenericConfigurationManagerImpl<ConfigurationManagerImpl>,
private Internal::AmebaConfig
{
// Allow the ConfigurationManager interface class to delegate method calls to
// the implementation methods provided by this class.
friend class ConfigurationManager;

// Allow the GenericConfigurationManagerImpl base class to access helper methods and types
// defined on this class.
#ifndef DOXYGEN_SHOULD_SKIP_THIS
Expand All @@ -55,12 +50,12 @@ class ConfigurationManagerImpl final : public ConfigurationManager,
private:
// ===== Members that implement the ConfigurationManager public interface.

CHIP_ERROR _Init(void);
CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t * buf);
bool _CanFactoryReset(void);
void _InitiateFactoryReset(void);
CHIP_ERROR _ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value);
CHIP_ERROR _WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value);
CHIP_ERROR Init(void) override;
CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override;
bool CanFactoryReset(void) override;
void InitiateFactoryReset(void) override;
CHIP_ERROR ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) override;
CHIP_ERROR WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value) override;

// NOTE: Other public interface methods are implemented by GenericConfigurationManagerImpl<>.

Expand Down

0 comments on commit 1063461

Please sign in to comment.