Skip to content

Commit

Permalink
[Silabs] Refactor Silabs Test Event Trigger impl to be compliant with…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
mkardous-silabs authored Apr 11, 2024
1 parent 981de99 commit b6c47f6
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 247 deletions.
2 changes: 1 addition & 1 deletion examples/light-switch-app/silabs/openthread.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/lit-icd-app/silabs/build_for_wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/lit-icd-app/silabs/openthread.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/silabs/build_for_wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/silabs/openthread.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 7 additions & 25 deletions examples/platform/silabs/MatterConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ static chip::DeviceLayer::Internal::Efr32PsaOperationalKeystore gOperationalKeys
#endif

#include "SilabsDeviceDataProvider.h"
#include "SilabsTestEventTriggerDelegate.h"
#include <app/InteractionModelEngine.h>
#include <app/TimerDelegates.h>

#ifdef SL_MATTER_TEST_EVENT_TRIGGER_ENABLED
#include "SilabsTestEventTriggerDelegate.h" // nogncheck
#endif

#if CHIP_CONFIG_SYNCHRONOUS_REPORTS_ENABLED
#include <app/reporting/SynchronizedReportSchedulerImpl.h>
#else
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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();

Expand Down
51 changes: 35 additions & 16 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,18 @@ 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 = ""

#default Wifi Password
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
Expand Down Expand Up @@ -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" ]
Expand Down Expand Up @@ -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") {
Expand All @@ -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" ]
}

Expand Down Expand Up @@ -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 ]
}
Expand Down
Loading

0 comments on commit b6c47f6

Please sign in to comment.