Skip to content

Commit

Permalink
BTSDK-8115 [Matter][pre-SVE][TC-DGGEN-2.2] Implement DGGEN.S.E03(Boot…
Browse files Browse the repository at this point in the history
…Reason)
  • Loading branch information
AlvinHsiao authored and hsusid committed Jun 6, 2022
1 parent f212d7d commit 48b7e02
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/platform/CYW30739/CYW30739Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ class CYW30739Config
static constexpr Key kConfigKey_LockUserName = CYW30739ConfigKey(kChipConfig_KeyBase, 0x0d);
static constexpr Key kConfigKey_CredentialData = CYW30739ConfigKey(kChipConfig_KeyBase, 0x0e);
static constexpr Key kConfigKey_UserCredentials = CYW30739ConfigKey(kChipConfig_KeyBase, 0x0f);
static constexpr Key kConfigKey_BootReason = CYW30739ConfigKey(kChipConfig_KeyBase, 0x10);

// Set key id limits for each group.
static constexpr Key kMinConfigKey_ChipFactory = CYW30739ConfigKey(kChipFactory_KeyBase, 0x00);
static constexpr Key kMaxConfigKey_ChipFactory = CYW30739ConfigKey(kChipFactory_KeyBase, 0x0a);
static constexpr Key kMinConfigKey_ChipConfig = CYW30739ConfigKey(kChipConfig_KeyBase, 0x00);
static constexpr Key kMaxConfigKey_ChipConfig = CYW30739ConfigKey(kChipConfig_KeyBase, 0x0f);
static constexpr Key kMaxConfigKey_ChipConfig = CYW30739ConfigKey(kChipConfig_KeyBase, 0x10);

static CHIP_ERROR Init(void);

Expand Down
18 changes: 17 additions & 1 deletion src/platform/CYW30739/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <platform/CYW30739/CYW30739Config.h>
#include <platform/ConfigurationManager.h>

#include <platform/DiagnosticDataProvider.h>
#include <hal/wiced_hal_wdog.h>
#include <platform/KeyValueStoreManager.h>

Expand Down Expand Up @@ -62,6 +62,12 @@ CHIP_ERROR ConfigurationManagerImpl::Init()
SuccessOrExit(err);
}

if (!CYW30739Config::ConfigValueExists(CYW30739Config::kConfigKey_BootReason))
{
err = StoreBootReason(to_underlying(BootReasonType::kUnspecified));
SuccessOrExit(err);
}

// Initialize the generic implementation base class.
err = Internal::GenericConfigurationManagerImpl<CYW30739Config>::Init();
SuccessOrExit(err);
Expand All @@ -80,6 +86,16 @@ CHIP_ERROR ConfigurationManagerImpl::StoreRebootCount(uint32_t rebootCount)
return WriteConfigValue(CYW30739Config::kConfigKey_RebootCount, rebootCount);
}

CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason)
{
return ReadConfigValue(CYW30739Config::kConfigKey_BootReason, bootReason);
}

CHIP_ERROR ConfigurationManagerImpl::StoreBootReason(uint32_t bootReason)
{
return WriteConfigValue(CYW30739Config::kConfigKey_BootReason, bootReason);
}

bool ConfigurationManagerImpl::CanFactoryReset(void)
{
return true;
Expand Down
2 changes: 2 additions & 0 deletions src/platform/CYW30739/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
static ConfigurationManagerImpl & GetDefaultInstance();
CHIP_ERROR GetRebootCount(uint32_t & rebootCount) override;
CHIP_ERROR StoreRebootCount(uint32_t rebootCount) override;
CHIP_ERROR GetBootReason(uint32_t & bootReason) override;
CHIP_ERROR StoreBootReason(uint32_t bootReason) override;

private:
// ===== Members that implement the ConfigurationManager public interface.
Expand Down
14 changes: 14 additions & 0 deletions src/platform/CYW30739/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetRebootCount(uint16_t & rebootCount)
return err;
}

CHIP_ERROR DiagnosticDataProviderImpl::GetBootReason(BootReasonType & bootReason)
{
uint32_t reason = 0;
CHIP_ERROR err = ConfigurationMgr().GetBootReason(reason);

if (err == CHIP_NO_ERROR)
{
VerifyOrReturnError(reason <= UINT8_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE);
bootReason = static_cast<BootReasonType>(reason);
}

return err;
}

CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** netifpp)
{
NetworkInterface * ifp = Platform::New<NetworkInterface>();
Expand Down
1 change: 1 addition & 0 deletions src/platform/CYW30739/DiagnosticDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider
CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed) override;
CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) override;
CHIP_ERROR GetRebootCount(uint16_t & rebootCount) override;
CHIP_ERROR GetBootReason(BootReasonType & bootReason) override;
CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override;
void ReleaseNetworkInterfaces(NetworkInterface * netifp) override;
};
Expand Down

0 comments on commit 48b7e02

Please sign in to comment.