Skip to content

Commit

Permalink
[Infineon] Pre-SVE week01 fixes for CYW30739 (#19525)
Browse files Browse the repository at this point in the history
* Increase lwip packet buffer size to 10.

* Implement DGGEN.S.E03(BootReason) for TC-DGGEN-2.2

* Implement LCFG.C.A0000(ActiveLocale) and LCFG.C.A0001(SupportedLocales) for TC-LO-2.1

Co-authored-by: alvin hsiao <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jun 15, 2022
1 parent 000ef81 commit 1033230
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/lighting-app/cyw30739/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
4 changes: 4 additions & 0 deletions examples/lighting-app/cyw30739/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <AppShellCommands.h>
#include <ButtonHandler.h>
#include <ChipShellCollection.h>
#include <DeviceInfoProviderImpl.h>
#include <LightingManager.h>
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
#include <OTAConfig.h>
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/cyw30739/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
4 changes: 4 additions & 0 deletions examples/lock-app/cyw30739/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <AppShellCommands.h>
#include <ButtonHandler.h>
#include <ChipShellCollection.h>
#include <DeviceInfoProviderImpl.h>
#include <LockManager.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/cluster-objects.h>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<chip::app::Clusters::DoorLock::DlLockState> state;
Expand Down
2 changes: 1 addition & 1 deletion src/lwip/cyw30739/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
#define PBUF_POOL_BUFSIZE 1356

/* Network Interfaces options */
#define PBUF_POOL_SIZE 8
#define PBUF_POOL_SIZE 10

/* LOOPIF options */

Expand Down
3 changes: 2 additions & 1 deletion src/platform/CYW30739/CYW30739Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
20 changes: 18 additions & 2 deletions src/platform/CYW30739/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

#include <platform/internal/GenericConfigurationManagerImpl.ipp>

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

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

namespace chip {
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 1033230

Please sign in to comment.