diff --git a/examples/lighting-app/cyw30739/BUILD.gn b/examples/lighting-app/cyw30739/BUILD.gn index 9ebf17650960d3..86d7342430b378 100644 --- a/examples/lighting-app/cyw30739/BUILD.gn +++ b/examples/lighting-app/cyw30739/BUILD.gn @@ -55,6 +55,7 @@ cyw30739_executable("lighting_app") { deps = [ ":sdk", "${chip_root}/examples/lighting-app/lighting-common", + "${chip_root}/examples/providers:device_info_provider", "${chip_root}/examples/shell/shell_common:shell_common", "${chip_root}/src/lib", ] diff --git a/examples/lighting-app/cyw30739/src/main.cpp b/examples/lighting-app/cyw30739/src/main.cpp index e3ec9dc3d49345..6c606e5c9dc1f2 100644 --- a/examples/lighting-app/cyw30739/src/main.cpp +++ b/examples/lighting-app/cyw30739/src/main.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include @@ -42,6 +43,7 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; using namespace ::chip::Shell; +static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; static void InitApp(intptr_t args); static void EventHandler(const ChipDeviceEvent * event, intptr_t arg); static void HandleThreadStateChangeEvent(const ChipDeviceEvent * event); @@ -153,6 +155,8 @@ void InitApp(intptr_t args) chip::Server::GetInstance().Init(initParams); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); + gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage()); + chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); LightMgr().Init(); LightMgr().SetCallbacks(LightManagerCallback, NULL); diff --git a/examples/lock-app/cyw30739/BUILD.gn b/examples/lock-app/cyw30739/BUILD.gn index 3a2b458a3a9e07..87f0e15e92bff3 100644 --- a/examples/lock-app/cyw30739/BUILD.gn +++ b/examples/lock-app/cyw30739/BUILD.gn @@ -55,6 +55,7 @@ cyw30739_executable("lock_app") { deps = [ ":sdk", "${chip_root}/examples/lock-app/lock-common", + "${chip_root}/examples/providers:device_info_provider", "${chip_root}/examples/shell/shell_common:shell_common", "${chip_root}/src/lib", ] diff --git a/examples/lock-app/cyw30739/src/main.cpp b/examples/lock-app/cyw30739/src/main.cpp index 47abd1b802bc3e..61ec55e3ef35a3 100644 --- a/examples/lock-app/cyw30739/src/main.cpp +++ b/examples/lock-app/cyw30739/src/main.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,7 @@ using namespace ::chip::Shell; wiced_bool_t syncClusterToButtonAction = false; +static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; static void InitApp(intptr_t args); static void EventHandler(const ChipDeviceEvent * event, intptr_t arg); static void HandleThreadStateChangeEvent(const ChipDeviceEvent * event); @@ -169,6 +171,8 @@ void InitApp(intptr_t args) chip::Server::GetInstance().Init(initParams); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); + gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage()); + chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); // Initial lock state chip::app::DataModel::Nullable state; diff --git a/src/lwip/cyw30739/lwipopts.h b/src/lwip/cyw30739/lwipopts.h index 40d3c1c6e1586a..36ed6df98e5cc3 100644 --- a/src/lwip/cyw30739/lwipopts.h +++ b/src/lwip/cyw30739/lwipopts.h @@ -77,7 +77,7 @@ #define PBUF_POOL_BUFSIZE 1356 /* Network Interfaces options */ -#define PBUF_POOL_SIZE 8 +#define PBUF_POOL_SIZE 10 /* LOOPIF options */ diff --git a/src/platform/CYW30739/CYW30739Config.h b/src/platform/CYW30739/CYW30739Config.h index ef192d83dc32cb..8f8aad9f5bdde6 100644 --- a/src/platform/CYW30739/CYW30739Config.h +++ b/src/platform/CYW30739/CYW30739Config.h @@ -78,12 +78,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); diff --git a/src/platform/CYW30739/ConfigurationManagerImpl.cpp b/src/platform/CYW30739/ConfigurationManagerImpl.cpp index 80942ea58b6705..71d32970f10881 100644 --- a/src/platform/CYW30739/ConfigurationManagerImpl.cpp +++ b/src/platform/CYW30739/ConfigurationManagerImpl.cpp @@ -26,10 +26,10 @@ #include +#include #include #include - -#include +#include #include namespace chip { @@ -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::Init(); SuccessOrExit(err); @@ -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; diff --git a/src/platform/CYW30739/ConfigurationManagerImpl.h b/src/platform/CYW30739/ConfigurationManagerImpl.h index 238425f7e28f52..284f4d37e94551 100644 --- a/src/platform/CYW30739/ConfigurationManagerImpl.h +++ b/src/platform/CYW30739/ConfigurationManagerImpl.h @@ -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. diff --git a/src/platform/CYW30739/DiagnosticDataProviderImpl.cpp b/src/platform/CYW30739/DiagnosticDataProviderImpl.cpp index c39fda18dd545f..a6a53bf45b8f93 100755 --- a/src/platform/CYW30739/DiagnosticDataProviderImpl.cpp +++ b/src/platform/CYW30739/DiagnosticDataProviderImpl.cpp @@ -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(reason); + } + + return err; +} + CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** netifpp) { NetworkInterface * ifp = Platform::New(); diff --git a/src/platform/CYW30739/DiagnosticDataProviderImpl.h b/src/platform/CYW30739/DiagnosticDataProviderImpl.h index dbaa6f15c975da..ff8739a2b05e73 100644 --- a/src/platform/CYW30739/DiagnosticDataProviderImpl.h +++ b/src/platform/CYW30739/DiagnosticDataProviderImpl.h @@ -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; };