From b6c47f67d91a5900dd37f6c5f5de0a3cd8b02ad0 Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:54:41 -0400 Subject: [PATCH] [Silabs] Refactor Silabs Test Event Trigger impl to be compliant with its requirements (#32927) * refactor test event trigger for efr32 hardware * remove 917 specific code * port test event trigger changes to 917 build.gn * clean up * Fix build and remove test key when not in debug build * add missing dependency * fix syncing typo --- .../light-switch-app/silabs/openthread.gni | 2 +- .../silabs/build_for_wifi_args.gni | 2 +- examples/lit-icd-app/silabs/openthread.gni | 2 +- .../lock-app/silabs/build_for_wifi_args.gni | 2 +- examples/lock-app/silabs/openthread.gni | 2 +- examples/platform/silabs/MatterConfig.cpp | 32 +--- examples/platform/silabs/SiWx917/BUILD.gn | 51 +++-- .../silabs/SilabsDeviceDataProvider.cpp | 180 ++++-------------- .../silabs/SilabsDeviceDataProvider.h | 9 +- .../silabs/SilabsTestEventTriggerDelegate.cpp | 10 +- .../silabs/SilabsTestEventTriggerDelegate.h | 8 +- examples/platform/silabs/efr32/BUILD.gn | 49 +++-- examples/smoke-co-alarm-app/silabs/README.md | 6 +- .../silabs/build_for_wifi_args.gni | 14 ++ .../smoke-co-alarm-app/silabs/openthread.gni | 19 ++ examples/window-app/silabs/openthread.gni | 2 +- src/platform/silabs/SilabsConfig.h | 57 +++--- 17 files changed, 200 insertions(+), 247 deletions(-) diff --git a/examples/light-switch-app/silabs/openthread.gni b/examples/light-switch-app/silabs/openthread.gni index 17cc5885460379..30c7efbde3d623 100644 --- a/examples/light-switch-app/silabs/openthread.gni +++ b/examples/light-switch-app/silabs/openthread.gni @@ -28,7 +28,7 @@ openthread_external_platform = # ICD Default configurations chip_enable_icd_server = true chip_subscription_timeout_resumption = false -sl_use_subscription_synching = true +sl_use_subscription_syncing = true # Openthread Configuration flags sl_ot_idle_interval_ms = 15000 # 15s Idle Intervals diff --git a/examples/lit-icd-app/silabs/build_for_wifi_args.gni b/examples/lit-icd-app/silabs/build_for_wifi_args.gni index 3531a31ffde406..cdc711cdc1c252 100644 --- a/examples/lit-icd-app/silabs/build_for_wifi_args.gni +++ b/examples/lit-icd-app/silabs/build_for_wifi_args.gni @@ -26,7 +26,7 @@ app_data_model = "${chip_root}/examples/lit-icd-app/lit-icd-common" # ICD Default configurations chip_enable_icd_server = true chip_subscription_timeout_resumption = false -sl_use_subscription_synching = true +sl_use_subscription_syncing = true icd_enforce_sit_slow_poll_limit = true chip_enable_icd_lit = true diff --git a/examples/lit-icd-app/silabs/openthread.gni b/examples/lit-icd-app/silabs/openthread.gni index 9d06737d622a2d..4b49740513c555 100644 --- a/examples/lit-icd-app/silabs/openthread.gni +++ b/examples/lit-icd-app/silabs/openthread.gni @@ -29,7 +29,7 @@ openthread_external_platform = # ICD Default configurations chip_enable_icd_server = true chip_subscription_timeout_resumption = false -sl_use_subscription_synching = true +sl_use_subscription_syncing = true icd_enforce_sit_slow_poll_limit = true chip_icd_report_on_active_mode = true chip_enable_icd_lit = true diff --git a/examples/lock-app/silabs/build_for_wifi_args.gni b/examples/lock-app/silabs/build_for_wifi_args.gni index 25c5a2435d332f..84596e9258fbcc 100644 --- a/examples/lock-app/silabs/build_for_wifi_args.gni +++ b/examples/lock-app/silabs/build_for_wifi_args.gni @@ -24,7 +24,7 @@ app_data_model = "${chip_root}/examples/lock-app/lock-common" # ICD Default configurations chip_enable_icd_server = true chip_subscription_timeout_resumption = false -sl_use_subscription_synching = true +sl_use_subscription_syncing = true # ICD Matter Configuration flags sl_idle_mode_duration_s = 600 # 10min Idle Mode Duration diff --git a/examples/lock-app/silabs/openthread.gni b/examples/lock-app/silabs/openthread.gni index 3bfa566596aeaf..8d1c75d267238c 100644 --- a/examples/lock-app/silabs/openthread.gni +++ b/examples/lock-app/silabs/openthread.gni @@ -28,7 +28,7 @@ openthread_external_platform = # ICD Default configurations chip_enable_icd_server = true chip_subscription_timeout_resumption = false -sl_use_subscription_synching = true +sl_use_subscription_syncing = true # Openthread Configuration flags sl_ot_idle_interval_ms = 5000 # 5s Idle Intervals diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 9be9f07fe3c759..d85f10d0612ea1 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -54,10 +54,13 @@ static chip::DeviceLayer::Internal::Efr32PsaOperationalKeystore gOperationalKeys #endif #include "SilabsDeviceDataProvider.h" -#include "SilabsTestEventTriggerDelegate.h" #include #include +#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED +#include "SilabsTestEventTriggerDelegate.h" // nogncheck +#endif + #if CHIP_CONFIG_SYNCHRONOUS_REPORTS_ENABLED #include #else @@ -219,12 +222,6 @@ void SilabsMatterConfig::ConnectivityEventCallback(const ChipDeviceEvent * event } } -#if SILABS_TEST_EVENT_TRIGGER_ENABLED -static uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, - 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, - 0xcc, 0xdd, 0xee, 0xff }; -#endif // SILABS_TEST_EVENT_TRIGGER_ENABLED - CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) { CHIP_ERROR err; @@ -283,18 +280,10 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) initParams.reportScheduler = &sReportScheduler; -#if SILABS_TEST_EVENT_TRIGGER_ENABLED - if (Encoding::HexToBytes(SILABS_TEST_EVENT_TRIGGER_ENABLE_KEY, strlen(SILABS_TEST_EVENT_TRIGGER_ENABLE_KEY), - sTestEventTriggerEnableKey, - TestEventTriggerDelegate::kEnableKeyLength) != TestEventTriggerDelegate::kEnableKeyLength) - { - SILABS_LOG("Failed to convert the EnableKey string to octstr type value"); - memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); - } - // TODO(#31723): Show to customers that they can do `Server::GetInstance().GetTestEventTriggerDelegate().AddHandler()` - static SilabsTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; +#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED + static SilabsTestEventTriggerDelegate sTestEventTriggerDelegate; initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; -#endif // SILABS_TEST_EVENT_TRIGGER_ENABLED +#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED #if CHIP_CRYPTO_PLATFORM && !(defined(SLI_SI91X_MCU_INTERFACE)) // When building with EFR32 crypto, use the opaque key store @@ -303,13 +292,6 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) initParams.operationalKeystore = &gOperationalKeystore; #endif -#ifdef PERFORMANCE_TEST_ENABLED - // Set up Test Event Trigger command of the General Diagnostics cluster. Used only in performance testing - // TODO(#31723): Show to customers that they can do `Server::GetInstance().GetTestEventTriggerDelegate().AddHandler()` - static SilabsTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(kTestEventTriggerEnableKey) }; - initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate; -#endif - // Initialize the remaining (not overridden) providers to the SDK example defaults (void) initParams.InitializeStaticResourcesBeforeServerInit(); diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 73e70c18e1d7f8..87df30d1a186c9 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -34,9 +34,6 @@ declare_args() { # Argument to force enable WPA3 security on rs91x rs91x_wpa3_transition = true - # use commissionable data for SiWx917 - siwx917_commissionable_data = false - #default WiFi SSID chip_default_wifi_ssid = "" @@ -44,11 +41,11 @@ declare_args() { chip_default_wifi_psk = "" # Enable TestEventTrigger in GeneralDiagnostics cluster - silabs_test_event_trigger_enabled = false + sl_enable_test_event_trigger = false # The EnableKey in hex string format used by TestEventTrigger command in - # GeneralDiagnostics cluster. The length of the string should be 32. - silabs_test_event_trigger_enable_key = "00112233445566778899aabbccddeeff" + # GeneralDiagnostics cluster. The length of the string should be 16 bytes. + sl_test_event_trigger_enable_key = "00112233445566778899AABBCCDDEEFF" } # Sanity check @@ -80,6 +77,30 @@ config("chip_examples_project_config") { ] } +config("test-event-trigger-config") { + defines = [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLED" ] + + if (is_debug) { + defines += [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY=\"${sl_test_event_trigger_enable_key}\"" ] + } +} + +source_set("test-event-trigger") { + sources = [ + "${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.cpp", + "${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.h", + ] + + public_configs = [ ":test-event-trigger-config" ] + + public_deps = [ + ":silabs-factory-data-provider", + "${chip_root}/src/app:test-event-trigger", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + ] +} + source_set("siwx917-matter-shell") { if (chip_build_libshell) { defines = [ "ENABLE_CHIP_SHELL" ] @@ -129,6 +150,10 @@ source_set("silabs-factory-data-provider") { ] public_configs = [ ":siwx917-common-config" ] + + if (sl_enable_test_event_trigger) { + public_configs += [ ":test-event-trigger-config" ] + } } config("siwx917-common-config") { @@ -152,10 +177,6 @@ config("siwx917-common-config") { defines += [ "HEAP_MONITORING" ] } - if (siwx917_commissionable_data) { - defines += [ "SIWX917_USE_COMISSIONABLE_DATA=1" ] - } - ldflags = [ "-Wl,--no-warn-rwx-segment" ] } @@ -274,18 +295,16 @@ source_set("siwx917-common") { public_deps += [ ":silabs-factory-data-provider" ] } - if (silabs_test_event_trigger_enabled) { - sources += - [ "${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.cpp" ] - defines += [ "SILABS_TEST_EVENT_TRIGGER_ENABLE_KEY=\"${silabs_test_event_trigger_enable_key}\"" ] - } - public_deps += [ "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/lib", "${chip_root}/src/setup_payload", ] + if (sl_enable_test_event_trigger) { + public_deps += [ ":test-event-trigger" ] + } + if (app_data_model != "") { public_deps += [ app_data_model ] } diff --git a/examples/platform/silabs/SilabsDeviceDataProvider.cpp b/examples/platform/silabs/SilabsDeviceDataProvider.cpp index c487c334819dd5..0bf11cde951ab4 100644 --- a/examples/platform/silabs/SilabsDeviceDataProvider.cpp +++ b/examples/platform/silabs/SilabsDeviceDataProvider.cpp @@ -23,13 +23,6 @@ #include #include -#ifdef SIWX917_USE_COMISSIONABLE_DATA -#include "DeviceConfig.h" -#include "silabs_utils.h" -#include -#include -#endif // SIWX917_USE_COMISSIONABLE_DATA - #include namespace chip { @@ -39,142 +32,6 @@ namespace Silabs { // using namespace chip::Credentials; using namespace chip::DeviceLayer::Internal; -// TODO Remove once Commander supports (doesn't erase) NVM3 for 917 -#ifdef SIWX917_USE_COMISSIONABLE_DATA -void SilabsDeviceDataProvider::setupPayload(uint8_t * outBuf) -{ - SetupPayload payload; - std::string result; - ChipError err = CHIP_NO_ERROR; - payload.version = 0; - payload.discriminator.SetLongValue(discriminatorValue); - payload.setUpPINCode = passcode; - payload.rendezvousInformation.SetValue(static_cast(rendezvousFlag)); - payload.commissioningFlow = static_cast(commissionableFlow); - payload.vendorID = vendorId; - payload.productID = productId; - - QRCodeSetupPayloadGenerator generator(payload); - err = generator.payloadBase38Representation(result); - if (err != CHIP_NO_ERROR) - { - SILABS_LOG("Failed to get the payload: %d", err); - } - SILABS_LOG("Payload value in string format : %s", result.c_str()); - std::vector result1; - // skipping the MT: from the payload during decoding - err = base38Decode(result.substr(3), result1); - if (err == CHIP_NO_ERROR) - { - for (uint8_t i = 0; i < result1.size(); i++) - { - outBuf[i] = result1.at(i); - } - } -} - -// writing to the flash based on the value given in the DeviceConfig.h -CHIP_ERROR SilabsDeviceDataProvider::FlashFactoryData() -{ - // flashing the value to the nvm3 section of the flash - // TODO: remove this once it is removed SiWx917 have the nvm3 simiplicity commander support - CHIP_ERROR err; - // Checking for the value of CM and flag - if ((commissionableFlow > 3) || (rendezvousFlag > 7)) - { - return CHIP_ERROR_INTERNAL; - } - if (discriminatorValue != 0) - { - err = SilabsConfig::WriteConfigValue(SilabsConfig::kConfigKey_SetupDiscriminator, discriminatorValue); - if (err != CHIP_NO_ERROR) - { - return err; - } - } - uint8_t payload[kTotalPayloadDataSizeInBytes]; - setupPayload(payload); - err = SilabsConfig::WriteConfigValueBin(SilabsConfig::kConfigKey_SetupPayloadBitSet, payload, kTotalPayloadDataSizeInBytes); - if (err != CHIP_NO_ERROR) - { - return err; - } - if (spake2Interation != 0) - { - err = SilabsConfig::WriteConfigValue(SilabsConfig::kConfigKey_Spake2pIterationCount, spake2Interation); - if (err != CHIP_NO_ERROR) - { - return err; - } - } - if (spake2Salt != NULL) - { - err = SilabsConfig::WriteConfigValueStr(SilabsConfig::kConfigKey_Spake2pSalt, spake2Salt); - if (err != CHIP_NO_ERROR) - { - return err; - } - } - if (spake2Verifier != NULL) - { - err = SilabsConfig::WriteConfigValueStr(SilabsConfig::kConfigKey_Spake2pVerifier, spake2Verifier); - if (err != CHIP_NO_ERROR) - { - return err; - } - } - if (productId != 0) - { - err = SilabsConfig::WriteConfigValue(SilabsConfig::kConfigKey_ProductId, productId); - if (err != CHIP_NO_ERROR) - { - return err; - } - } - if (vendorId != 0) - { - err = SilabsConfig::WriteConfigValue(SilabsConfig::kConfigKey_VendorId, vendorId); - if (err != CHIP_NO_ERROR) - { - return err; - } - } - if (strlen(productName) != 0) - { - err = SilabsConfig::WriteConfigValueStr(SilabsConfig::kConfigKey_ProductName, productName); - if (err != CHIP_NO_ERROR) - { - return err; - } - } - if (strlen(vendorName) != 0) - { - err = SilabsConfig::WriteConfigValueStr(SilabsConfig::kConfigKey_VendorName, vendorName); - if (err != CHIP_NO_ERROR) - { - return err; - } - } - if (strlen(hwVersionString) != 0) - { - err = SilabsConfig::WriteConfigValueStr(SilabsConfig::kConfigKey_HardwareVersionString, hwVersionString); - if (err != CHIP_NO_ERROR) - { - return err; - } - } - if (rotatingId != 0) - { - err = SilabsConfig::WriteConfigValue(SilabsConfig::kConfigKey_UniqueId, rotatingId); - if (err != CHIP_NO_ERROR) - { - return err; - } - } - return CHIP_NO_ERROR; -} -#endif - CHIP_ERROR SilabsDeviceDataProvider::GetSetupDiscriminator(uint16_t & setupDiscriminator) { CHIP_ERROR err; @@ -510,6 +367,43 @@ CHIP_ERROR SilabsDeviceDataProvider::GetProductLabel(char * buf, size_t bufSize) return SilabsConfig::ReadConfigValueStr(SilabsConfig::KConfigKey_ProductLabel, buf, bufSize, productLabelLen); } +#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED +/** + * @brief Reads the test event trigger key from NVM. If the key isn't present, returns default value if defined. + * + * @param[out] keySpan output buffer. Must be at least large enough for 16 bytes (ken length) + * @return CHIP_ERROR + */ +CHIP_ERROR SilabsDeviceDataProvider::GetTestEventTriggerKey(MutableByteSpan & keySpan) +{ + constexpr size_t kEnableKeyLength = 16; // Expected byte size of the EnableKey + CHIP_ERROR err = CHIP_NO_ERROR; + size_t keyLength = 0; + + VerifyOrReturnError(keySpan.size() >= kEnableKeyLength, CHIP_ERROR_BUFFER_TOO_SMALL); + + err = SilabsConfig::ReadConfigValueBin(SilabsConfig::kConfigKey_Test_Event_Trigger_Key, keySpan.data(), kEnableKeyLength, + keyLength); +#ifndef NDEBUG + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + + constexpr char enableKey[] = SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY; + if (Encoding::HexToBytes(enableKey, strlen(enableKey), keySpan.data(), kEnableKeyLength) != kEnableKeyLength) + { + // enableKey Hex String doesn't have the correct length + memset(keySpan.data(), 0, keySpan.size()); + return CHIP_ERROR_INTERNAL; + } + err = CHIP_NO_ERROR; + } +#endif // NDEBUG + + keySpan.reduce_size(kEnableKeyLength); + return err; +} +#endif // SL_MATTER_TEST_EVENT_TRIGGER_ENABLED + SilabsDeviceDataProvider & SilabsDeviceDataProvider::GetDeviceDataProvider() { static SilabsDeviceDataProvider sDataProvider; diff --git a/examples/platform/silabs/SilabsDeviceDataProvider.h b/examples/platform/silabs/SilabsDeviceDataProvider.h index f29e6be24d9d72..76caac04bd60b8 100644 --- a/examples/platform/silabs/SilabsDeviceDataProvider.h +++ b/examples/platform/silabs/SilabsDeviceDataProvider.h @@ -37,12 +37,6 @@ class SilabsDeviceDataProvider : public CommissionableDataProvider, Internal::GenericDeviceInstanceInfoProvider(ConfigurationManagerImpl::GetDefaultInstance()) {} -// TODO Remove once Commander supports (doesn't erase) NVM3 for 917 -#ifdef SIWX917_USE_COMISSIONABLE_DATA - void setupPayload(uint8_t * outBuf); - CHIP_ERROR FlashFactoryData(); -#endif /* SIWX917_USE_COMISSIONABLE_DATA */ - static SilabsDeviceDataProvider & GetDeviceDataProvider(); CHIP_ERROR GetSetupPayload(MutableCharSpan & payloadBuf); // ===== Members functions that implement the CommissionableDataProvider @@ -68,6 +62,9 @@ class SilabsDeviceDataProvider : public CommissionableDataProvider, CHIP_ERROR GetPartNumber(char * buf, size_t bufSize) override; CHIP_ERROR GetProductURL(char * buf, size_t bufSzie) override; CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override; + + // ===== Member functions that are Silabs Specific + CHIP_ERROR GetTestEventTriggerKey(MutableByteSpan & keySpan); }; } // namespace Silabs diff --git a/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp b/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp index f9a11df74d7ae9..ef42c0d3a9dfd2 100644 --- a/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp +++ b/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp @@ -17,6 +17,7 @@ */ #include "SilabsTestEventTriggerDelegate.h" +#include "SilabsDeviceDataProvider.h" using namespace ::chip::DeviceLayer; @@ -24,7 +25,14 @@ namespace chip { bool SilabsTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const { - return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); + uint8_t storedEnableKey[TestEventTriggerDelegate::kEnableKeyLength]; + MutableByteSpan enableKeySpan(storedEnableKey); + + // Return false if we were not able to get the enableKey + VerifyOrReturnValue( + Silabs::SilabsDeviceDataProvider::GetDeviceDataProvider().GetTestEventTriggerKey(enableKeySpan) == CHIP_NO_ERROR, false); + + return (!enableKeySpan.empty() && enableKeySpan.data_equal(enableKey)); } } // namespace chip diff --git a/examples/platform/silabs/SilabsTestEventTriggerDelegate.h b/examples/platform/silabs/SilabsTestEventTriggerDelegate.h index 03ceabd69a7898..8359e489a16029 100644 --- a/examples/platform/silabs/SilabsTestEventTriggerDelegate.h +++ b/examples/platform/silabs/SilabsTestEventTriggerDelegate.h @@ -46,10 +46,7 @@ namespace chip { class SilabsTestEventTriggerDelegate : public TestEventTriggerDelegate, TestEventTriggerHandler { public: - explicit SilabsTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) - { - VerifyOrDie(AddHandler(this) == CHIP_NO_ERROR); - } + explicit SilabsTestEventTriggerDelegate() { VerifyOrDie(AddHandler(this) == CHIP_NO_ERROR); } /** * @brief Checks to see if `enableKey` provided matches value chosen by the manufacturer. @@ -69,9 +66,6 @@ class SilabsTestEventTriggerDelegate : public TestEventTriggerDelegate, TestEven // WARNING: LEGACY SUPPORT ONLY, DO NOT EXTEND FOR STANDARD CLUSTERS return (emberAfHandleEventTrigger(eventTrigger)) ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT; } - -private: - ByteSpan mEnableKey; }; } // namespace chip diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index 8b7b1ebf86e264..ee0b891a2565f8 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -41,11 +41,11 @@ declare_args() { chip_default_wifi_psk = "" # Enable TestEventTrigger in GeneralDiagnostics cluster - silabs_test_event_trigger_enabled = false + sl_enable_test_event_trigger = false # The EnableKey in hex string format used by TestEventTrigger command in - # GeneralDiagnostics cluster. The length of the string should be 32. - silabs_test_event_trigger_enable_key = "00112233445566778899aabbccddeeff" + # GeneralDiagnostics cluster. The length of the string should be 16 bytes. + sl_test_event_trigger_enable_key = "00112233445566778899AABBCCDDEEFF" } silabs_common_plat_dir = "${chip_root}/examples/platform/silabs" @@ -94,6 +94,30 @@ config("chip_examples_project_config") { ] } +config("test-event-trigger-config") { + defines = [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLED" ] + + if (is_debug) { + defines += [ "SL_MATTER_TEST_EVENT_TRIGGER_ENABLE_KEY=\"${sl_test_event_trigger_enable_key}\"" ] + } +} + +source_set("test-event-trigger") { + sources = [ + "${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.cpp", + "${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.h", + ] + + public_configs = [ ":test-event-trigger-config" ] + + public_deps = [ + ":silabs-factory-data-provider", + "${chip_root}/src/app:test-event-trigger", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + ] +} + source_set("openthread_core_config_efr32_chip_examples") { if (chip_enable_openthread) { sources = [ "project_include/OpenThreadConfig.h" ] @@ -157,6 +181,10 @@ source_set("silabs-factory-data-provider") { "${chip_root}/src/platform:platform_base", "${chip_root}/src/setup_payload", ] + + if (sl_enable_test_event_trigger) { + public_configs = [ ":test-event-trigger-config" ] + } } config("efr32-common-config") { @@ -206,6 +234,7 @@ config("silabs-wifi-config") { if (sl_wfx_config_softap) { defines += [ "SL_WFX_CONFIG_SOFTAP" ] } + if (sl_wfx_config_scan) { defines += [ "SL_WFX_CONFIG_SCAN" ] } @@ -213,6 +242,7 @@ config("silabs-wifi-config") { if (chip_enable_wifi_ipv4) { defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] } + if (rs91x_wpa3_transition) { # TODO: Change this macro once WF200 support is provided defines += [ "WIFI_ENABLE_SECURITY_WPA3_TRANSITION=1" ] @@ -322,15 +352,6 @@ source_set("efr32-common") { public_deps += [ ":silabs-factory-data-provider" ] } - if (silabs_test_event_trigger_enabled) { - sources += - [ "${silabs_common_plat_dir}/SilabsTestEventTriggerDelegate.cpp" ] - defines += [ - "SILABS_TEST_EVENT_TRIGGER_ENABLED=true", - "SILABS_TEST_EVENT_TRIGGER_ENABLE_KEY=\"${silabs_test_event_trigger_enable_key}\"", - ] - } - public_deps += [ "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/app/server", @@ -338,6 +359,10 @@ source_set("efr32-common") { "${chip_root}/src/setup_payload", ] + if (sl_enable_test_event_trigger) { + public_deps += [ ":test-event-trigger" ] + } + if (app_data_model != "") { public_deps += [ app_data_model ] } diff --git a/examples/smoke-co-alarm-app/silabs/README.md b/examples/smoke-co-alarm-app/silabs/README.md index b5548b69f24f54..03ff976deca183 100644 --- a/examples/smoke-co-alarm-app/silabs/README.md +++ b/examples/smoke-co-alarm-app/silabs/README.md @@ -384,10 +384,10 @@ features can easily be toggled on or off. Here is a short list of options : ### Enabling test event trigger -`silabs_test_event_trigger_enabled, silabs_test_event_trigger_enable_key` +`sl_enable_test_event_trigger` ``` - The value of silabs_test_event_trigger_enable_key is specific to each device manufacturer + The enable the test event trigger, `sl_enable_test_event_trigger` must be true. - $ ./scripts/examples/gn_silabs_example.sh ./examples/smoke-co-alarm-app/silabs ./out/smoke-co-alarm-app BRD4164A silabs_test_event_trigger_enabled=true silabs_test_event_trigger_enable_key=\"00112233445566778899aabbccddeeff\" + $ ./scripts/examples/gn_silabs_example.sh ./examples/smoke-co-alarm-app/silabs ./out/smoke-co-alarm-app BRD4164A sl_enable_test_event_trigger=true ``` diff --git a/examples/smoke-co-alarm-app/silabs/build_for_wifi_args.gni b/examples/smoke-co-alarm-app/silabs/build_for_wifi_args.gni index 047de7f34492df..0619082413530d 100644 --- a/examples/smoke-co-alarm-app/silabs/build_for_wifi_args.gni +++ b/examples/smoke-co-alarm-app/silabs/build_for_wifi_args.gni @@ -21,3 +21,17 @@ import("${chip_root}/src/platform/silabs/wifi_args.gni") chip_enable_ota_requestor = true app_data_model = "${chip_root}/examples/smoke-co-alarm-app/smoke-co-alarm-common" + +sl_enable_test_event_trigger = true + +# ICD Default configurations +chip_enable_icd_server = true +chip_subscription_timeout_resumption = false +sl_use_subscription_syncing = true +icd_enforce_sit_slow_poll_limit = true +chip_enable_icd_lit = true + +# ICD Matter Configuration flags +sl_idle_mode_duration_s = 3600 # 60min Idle Mode Duration +sl_active_mode_duration_ms = 0 # 0 Active Mode Duration +sl_active_mode_threshold_ms = 30000 # 30s Active Mode Threshold diff --git a/examples/smoke-co-alarm-app/silabs/openthread.gni b/examples/smoke-co-alarm-app/silabs/openthread.gni index 650b338de86f93..845b2220b4570a 100644 --- a/examples/smoke-co-alarm-app/silabs/openthread.gni +++ b/examples/smoke-co-alarm-app/silabs/openthread.gni @@ -25,3 +25,22 @@ chip_enable_openthread = true openthread_external_platform = "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" + +sl_enable_test_event_trigger = true + +# ICD Default configurations +chip_enable_icd_server = true +chip_subscription_timeout_resumption = false +sl_use_subscription_syncing = true +icd_enforce_sit_slow_poll_limit = true +chip_icd_report_on_active_mode = true +chip_enable_icd_lit = true + +# Openthread Configuration flags +sl_ot_idle_interval_ms = 3600000 # 60mins Idle Polling Interval +sl_ot_active_interval_ms = 1000 # 1000ms Active Polling Interval + +# ICD Matter Configuration flags +sl_idle_mode_duration_s = 3600 # 60min Idle Mode Duration +sl_active_mode_duration_ms = 0 # 0 Active Mode Duration +sl_active_mode_threshold_ms = 5000 # 5s Active Mode Threshold diff --git a/examples/window-app/silabs/openthread.gni b/examples/window-app/silabs/openthread.gni index d3d50ab878b211..9fd09bd510a840 100644 --- a/examples/window-app/silabs/openthread.gni +++ b/examples/window-app/silabs/openthread.gni @@ -29,7 +29,7 @@ openthread_external_platform = chip_enable_icd_server = true enable_synchronized_sed = true chip_subscription_timeout_resumption = false -sl_use_subscription_synching = true +sl_use_subscription_syncing = true # Openthread Configuration flags sl_ot_idle_interval_ms = 1000 # 1s Idle Intervals diff --git a/src/platform/silabs/SilabsConfig.h b/src/platform/silabs/SilabsConfig.h index 0f820f6fb8268e..3bd5abfba1b8f3 100644 --- a/src/platform/silabs/SilabsConfig.h +++ b/src/platform/silabs/SilabsConfig.h @@ -93,34 +93,35 @@ class SilabsConfig // Key definitions for well-known configuration values. // Factory config keys - static constexpr Key kConfigKey_SerialNum = SilabsConfigKey(kMatterFactory_KeyBase, 0x00); - static constexpr Key kConfigKey_MfrDeviceId = SilabsConfigKey(kMatterFactory_KeyBase, 0x01); - static constexpr Key kConfigKey_MfrDeviceCert = SilabsConfigKey(kMatterFactory_KeyBase, 0x02); - static constexpr Key kConfigKey_MfrDevicePrivateKey = SilabsConfigKey(kMatterFactory_KeyBase, 0x03); - static constexpr Key kConfigKey_ManufacturingDate = SilabsConfigKey(kMatterFactory_KeyBase, 0x04); - static constexpr Key kConfigKey_SetupPayloadBitSet = SilabsConfigKey(kMatterFactory_KeyBase, 0x05); - static constexpr Key kConfigKey_MfrDeviceICACerts = SilabsConfigKey(kMatterFactory_KeyBase, 0x06); - static constexpr Key kConfigKey_SetupDiscriminator = SilabsConfigKey(kMatterFactory_KeyBase, 0x07); - static constexpr Key kConfigKey_Spake2pIterationCount = SilabsConfigKey(kMatterFactory_KeyBase, 0x08); - static constexpr Key kConfigKey_Spake2pSalt = SilabsConfigKey(kMatterFactory_KeyBase, 0x09); - static constexpr Key kConfigKey_Spake2pVerifier = SilabsConfigKey(kMatterFactory_KeyBase, 0x0A); - static constexpr Key kConfigKey_ProductId = SilabsConfigKey(kMatterFactory_KeyBase, 0x0B); - static constexpr Key kConfigKey_VendorId = SilabsConfigKey(kMatterFactory_KeyBase, 0x0C); - static constexpr Key kConfigKey_VendorName = SilabsConfigKey(kMatterFactory_KeyBase, 0x0D); - static constexpr Key kConfigKey_ProductName = SilabsConfigKey(kMatterFactory_KeyBase, 0x0E); - static constexpr Key kConfigKey_HardwareVersionString = SilabsConfigKey(kMatterFactory_KeyBase, 0x0F); - static constexpr Key KConfigKey_ProductLabel = SilabsConfigKey(kMatterFactory_KeyBase, 0x10); - static constexpr Key kConfigKey_ProductURL = SilabsConfigKey(kMatterFactory_KeyBase, 0x11); - static constexpr Key kConfigKey_PartNumber = SilabsConfigKey(kMatterFactory_KeyBase, 0x12); - static constexpr Key kConfigKey_UniqueId = SilabsConfigKey(kMatterFactory_KeyBase, 0x1F); - static constexpr Key kConfigKey_Creds_KeyId = SilabsConfigKey(kMatterFactory_KeyBase, 0x20); - static constexpr Key kConfigKey_Creds_Base_Addr = SilabsConfigKey(kMatterFactory_KeyBase, 0x21); - static constexpr Key kConfigKey_Creds_DAC_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x22); - static constexpr Key kConfigKey_Creds_DAC_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x23); - static constexpr Key kConfigKey_Creds_PAI_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x24); - static constexpr Key kConfigKey_Creds_PAI_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x25); - static constexpr Key kConfigKey_Creds_CD_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x26); - static constexpr Key kConfigKey_Creds_CD_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x27); + static constexpr Key kConfigKey_SerialNum = SilabsConfigKey(kMatterFactory_KeyBase, 0x00); + static constexpr Key kConfigKey_MfrDeviceId = SilabsConfigKey(kMatterFactory_KeyBase, 0x01); + static constexpr Key kConfigKey_MfrDeviceCert = SilabsConfigKey(kMatterFactory_KeyBase, 0x02); + static constexpr Key kConfigKey_MfrDevicePrivateKey = SilabsConfigKey(kMatterFactory_KeyBase, 0x03); + static constexpr Key kConfigKey_ManufacturingDate = SilabsConfigKey(kMatterFactory_KeyBase, 0x04); + static constexpr Key kConfigKey_SetupPayloadBitSet = SilabsConfigKey(kMatterFactory_KeyBase, 0x05); + static constexpr Key kConfigKey_MfrDeviceICACerts = SilabsConfigKey(kMatterFactory_KeyBase, 0x06); + static constexpr Key kConfigKey_SetupDiscriminator = SilabsConfigKey(kMatterFactory_KeyBase, 0x07); + static constexpr Key kConfigKey_Spake2pIterationCount = SilabsConfigKey(kMatterFactory_KeyBase, 0x08); + static constexpr Key kConfigKey_Spake2pSalt = SilabsConfigKey(kMatterFactory_KeyBase, 0x09); + static constexpr Key kConfigKey_Spake2pVerifier = SilabsConfigKey(kMatterFactory_KeyBase, 0x0A); + static constexpr Key kConfigKey_ProductId = SilabsConfigKey(kMatterFactory_KeyBase, 0x0B); + static constexpr Key kConfigKey_VendorId = SilabsConfigKey(kMatterFactory_KeyBase, 0x0C); + static constexpr Key kConfigKey_VendorName = SilabsConfigKey(kMatterFactory_KeyBase, 0x0D); + static constexpr Key kConfigKey_ProductName = SilabsConfigKey(kMatterFactory_KeyBase, 0x0E); + static constexpr Key kConfigKey_HardwareVersionString = SilabsConfigKey(kMatterFactory_KeyBase, 0x0F); + static constexpr Key KConfigKey_ProductLabel = SilabsConfigKey(kMatterFactory_KeyBase, 0x10); + static constexpr Key kConfigKey_ProductURL = SilabsConfigKey(kMatterFactory_KeyBase, 0x11); + static constexpr Key kConfigKey_PartNumber = SilabsConfigKey(kMatterFactory_KeyBase, 0x12); + static constexpr Key kConfigKey_UniqueId = SilabsConfigKey(kMatterFactory_KeyBase, 0x1F); + static constexpr Key kConfigKey_Creds_KeyId = SilabsConfigKey(kMatterFactory_KeyBase, 0x20); + static constexpr Key kConfigKey_Creds_Base_Addr = SilabsConfigKey(kMatterFactory_KeyBase, 0x21); + static constexpr Key kConfigKey_Creds_DAC_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x22); + static constexpr Key kConfigKey_Creds_DAC_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x23); + static constexpr Key kConfigKey_Creds_PAI_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x24); + static constexpr Key kConfigKey_Creds_PAI_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x25); + static constexpr Key kConfigKey_Creds_CD_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x26); + static constexpr Key kConfigKey_Creds_CD_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x27); + static constexpr Key kConfigKey_Test_Event_Trigger_Key = SilabsConfigKey(kMatterFactory_KeyBase, 0x28); // Matter Config Keys static constexpr Key kConfigKey_ServiceConfig = SilabsConfigKey(kMatterConfig_KeyBase, 0x01); static constexpr Key kConfigKey_PairedAccountId = SilabsConfigKey(kMatterConfig_KeyBase, 0x02);