Make TestEventTrigger delegate testable and extensible (#31724)
* Make TestEventTrigger delegate testable and extensible
- Make TestEventTriggerDelegate base class manage multiple sub-handlers.
- Add unit tests for TestEventTriggerDelegate
- Introduce an interface for generic TestEventTrigger handlers
- Add Clear() method to Intrusive list to remove everything.
- Document the fact that `emberAfHandleEventTrigger` should NOT be used
- Update all examples as needed.
- Renumber OTA and SmokeCO testevent trigger prefix to match new Matter 1.3
standard (first 16 bits == cluster ID being tested).
- Clean-up dead code
- Register OTA test event handler as intended.
- Add TODOs for platforms to clean-up TestEventTriggerDelegate registration.
- Updated BOOLCFG tests to use `--hex-arg` for PIXIT since `--int-arg` is too
confusing with complex keys.
Issue #31723
Testing done:
- EEVSE Python tests using event triggers pass
- SMOKECO YAML tests using event triggers pass
- BOOLCFG Python tests using event triggers pass
- TC_TestEventTrigger passes
- New unit tests pass
* Fix merge issue
* Restyled by clang-format
* Fix uninitialized variable access
* Fix Ameba/Silabs build
* Fix CopyString bound
* More fixes of Ameba/Silabs build
---------
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp
index 36716ec..fe2ec90 100644
--- a/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp
+++ b/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-#include <app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.h>
+#include <app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.h>
#include <app/clusters/boolean-state-configuration-server/boolean-state-configuration-server.h>
#include <platform/CHIPDeviceLayer.h>
diff --git a/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp
index 4b1e883..88c85f7 100644
--- a/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp
+++ b/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-#include <app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h>
+#include <app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h>
#include <app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h>
#include <platform/CHIPDeviceLayer.h>
diff --git a/examples/all-clusters-app/ameba/main/SmokeCOAlarmManager.cpp b/examples/all-clusters-app/ameba/main/SmokeCOAlarmManager.cpp
index bede2bc..027bb05 100644
--- a/examples/all-clusters-app/ameba/main/SmokeCOAlarmManager.cpp
+++ b/examples/all-clusters-app/ameba/main/SmokeCOAlarmManager.cpp
@@ -16,7 +16,7 @@
*/
#include "SmokeCOAlarmManager.h"
-#include <app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h>
+#include <app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h>
#include <lib/support/TypeTraits.h>
using namespace chip;
diff --git a/examples/all-clusters-app/ameba/main/chipinterface.cpp b/examples/all-clusters-app/ameba/main/chipinterface.cpp
index 21280c6..20de9cd 100644
--- a/examples/all-clusters-app/ameba/main/chipinterface.cpp
+++ b/examples/all-clusters-app/ameba/main/chipinterface.cpp
@@ -140,8 +140,10 @@
static chip::CommonCaseDeviceServerInitParams initParams;
#if CONFIG_ENABLE_AMEBA_TEST_EVENT_TRIGGER
- static AmebaTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ // TODO(#31723): Show to customers that they can do `Server::GetInstance().GetTestEventTriggerDelegate().AddHandler(xxx)`
+ // to add custom handlers during their app init, after InitServer.
+ static AmebaTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
#endif
initParams.InitializeStaticResourcesBeforeServerInit();
diff --git a/examples/all-clusters-app/ameba/main/include/SmokeCOAlarmManager.h b/examples/all-clusters-app/ameba/main/include/SmokeCOAlarmManager.h
index 390ee67..af61772 100644
--- a/examples/all-clusters-app/ameba/main/include/SmokeCOAlarmManager.h
+++ b/examples/all-clusters-app/ameba/main/include/SmokeCOAlarmManager.h
@@ -22,8 +22,6 @@
#include <stdbool.h>
#include <stdint.h>
-bool emberAfHandleEventTrigger(uint64_t eventTrigger);
-
class SmokeCoAlarmManager
{
public:
diff --git a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp
index 9f47194..f8d1177 100644
--- a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp
+++ b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp
@@ -27,8 +27,9 @@
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
+#include <app/TestEventTriggerDelegate.h>
#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/util/attribute-storage.h>
#include <credentials/DeviceAttestationCredsProvider.h>
@@ -204,9 +205,12 @@
#endif
static CommonCaseDeviceServerInitParams initParams;
- static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams));
AppFabricTableDelegate::Init();
diff --git a/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp b/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp
index 70cd63e..0f20467 100644
--- a/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp
+++ b/examples/energy-management-app/energy-management-common/src/EVSEManufacturerImpl.cpp
@@ -18,9 +18,9 @@
#include <EVSEManufacturerImpl.h>
#include <EnergyEvseManager.h>
-#include <app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.h>
+#include <app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h>
#include <app/clusters/electrical-energy-measurement-server/electrical-energy-measurement-server.h>
-#include <app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h>
+#include <app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h>
using namespace chip;
using namespace chip::app;
diff --git a/examples/energy-management-app/linux/README.md b/examples/energy-management-app/linux/README.md
index d316dd8..424ef46 100644
--- a/examples/energy-management-app/linux/README.md
+++ b/examples/energy-management-app/linux/README.md
@@ -366,7 +366,7 @@
then you can use a few of the test event triggers to simulate these scenarios.
The test event triggers values can be found in:
-[EnergyEvseTestEventTriggerDelegate.h](../../../src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h)
+[EnergyEvseTestEventTriggerHandler.h](../../../src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h)
- 0x0099000000000000 - Simulates the EVSE being installed on a 32A supply
- 0x0099000000000002 - Simulates the EVSE being plugged in (this should
diff --git a/examples/light-switch-app/infineon/cyw30739/src/main.cpp b/examples/light-switch-app/infineon/cyw30739/src/main.cpp
index dbfdb81..483a475 100644
--- a/examples/light-switch-app/infineon/cyw30739/src/main.cpp
+++ b/examples/light-switch-app/infineon/cyw30739/src/main.cpp
@@ -26,8 +26,9 @@
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
#include <OTAConfig.h>
#endif
+#include <app/TestEventTriggerDelegate.h>
#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
@@ -192,10 +193,13 @@
// Print QR Code URL
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
/* Start CHIP datamodel server */
- static chip::OTATestEventTriggerDelegate testEventTriggerDelegate{ chip::ByteSpan(sTestEventTriggerEnableKey) };
+ static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);
chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
diff --git a/examples/light-switch-app/nrfconnect/main/AppTask.cpp b/examples/light-switch-app/nrfconnect/main/AppTask.cpp
index a4b5ac5..06ac797 100644
--- a/examples/light-switch-app/nrfconnect/main/AppTask.cpp
+++ b/examples/light-switch-app/nrfconnect/main/AppTask.cpp
@@ -24,8 +24,9 @@
#include "LightSwitch.h"
#include <DeviceInfoProviderImpl.h>
+#include <app/TestEventTriggerDelegate.h>
#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <credentials/DeviceAttestationCredsProvider.h>
@@ -215,9 +216,12 @@
#endif
static CommonCaseDeviceServerInitParams initParams;
- static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams));
AppFabricTableDelegate::Init();
diff --git a/examples/light-switch-app/qpg/BUILD.gn b/examples/light-switch-app/qpg/BUILD.gn
index 659f2d4..055cfd4 100644
--- a/examples/light-switch-app/qpg/BUILD.gn
+++ b/examples/light-switch-app/qpg/BUILD.gn
@@ -51,7 +51,7 @@
output_name = "chip-${qpg_target_ic}-light-switch-example.out"
sources = [
- "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp",
+ "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp",
"${examples_plat_dir}/app/main.cpp",
"${examples_plat_dir}/ota/ota.cpp",
"src/AppTask.cpp",
diff --git a/examples/light-switch-app/qpg/src/AppTask.cpp b/examples/light-switch-app/qpg/src/AppTask.cpp
index 9f66622..f02823b 100644
--- a/examples/light-switch-app/qpg/src/AppTask.cpp
+++ b/examples/light-switch-app/qpg/src/AppTask.cpp
@@ -31,7 +31,8 @@
#include <app/server/OnboardingCodesUtil.h>
-#include <app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h>
+#include <app/TestEventTriggerDelegate.h>
+#include <app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h>
#include <app/clusters/general-diagnostics-server/general-diagnostics-server.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/server/Dnssd.h>
@@ -191,10 +192,13 @@
nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance();
initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
- // Use GenericFaultTestEventTriggerDelegate to inject faults
- static GenericFaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ // Use GenericFaultTestEventTriggerHandler to inject faults
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static GenericFaultTestEventTriggerHandler sFaultTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sFaultTestEventTriggerHandler) == CHIP_NO_ERROR);
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
chip::Server::GetInstance().Init(initParams);
diff --git a/examples/lighting-app/infineon/cyw30739/src/main.cpp b/examples/lighting-app/infineon/cyw30739/src/main.cpp
index 1473025..f851e2e 100644
--- a/examples/lighting-app/infineon/cyw30739/src/main.cpp
+++ b/examples/lighting-app/infineon/cyw30739/src/main.cpp
@@ -26,8 +26,9 @@
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
#include <OTAConfig.h>
#endif
+#include <app/TestEventTriggerDelegate.h>
#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
@@ -191,10 +192,13 @@
// Print QR Code URL
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
/* Start CHIP datamodel server */
- static chip::OTATestEventTriggerDelegate testEventTriggerDelegate{ chip::ByteSpan(sTestEventTriggerEnableKey) };
+ static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);
chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp
index 0363210..494095e 100644
--- a/examples/lighting-app/nrfconnect/main/AppTask.cpp
+++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp
@@ -27,8 +27,9 @@
#include <DeviceInfoProviderImpl.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/DeferredAttributePersistenceProvider.h>
+#include <app/TestEventTriggerDelegate.h>
#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/Dnssd.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
@@ -243,9 +244,12 @@
#endif
static CommonCaseDeviceServerInitParams initParams;
- static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams));
AppFabricTableDelegate::Init();
diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp
index 557293f..b1fc51c 100644
--- a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp
+++ b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp
@@ -286,8 +286,8 @@
chip::DeviceLayer::SetDeviceInfoProvider(&infoProvider);
// Init ZCL Data Model and start server
- static DefaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ static DefaultTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
nativeParams.lockCb = LockOpenThreadTask;
nativeParams.unlockCb = UnlockOpenThreadTask;
diff --git a/examples/lighting-app/nxp/k32w/k32w1/main/AppTask.cpp b/examples/lighting-app/nxp/k32w/k32w1/main/AppTask.cpp
index 66eee72..7150003 100644
--- a/examples/lighting-app/nxp/k32w/k32w1/main/AppTask.cpp
+++ b/examples/lighting-app/nxp/k32w/k32w1/main/AppTask.cpp
@@ -214,8 +214,8 @@
#endif
// Init ZCL Data Model and start server
- static DefaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ static DefaultTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
nativeParams.lockCb = LockOpenThreadTask;
nativeParams.unlockCb = UnlockOpenThreadTask;
diff --git a/examples/lighting-app/qpg/BUILD.gn b/examples/lighting-app/qpg/BUILD.gn
index d8f8631..c835e0b 100644
--- a/examples/lighting-app/qpg/BUILD.gn
+++ b/examples/lighting-app/qpg/BUILD.gn
@@ -51,7 +51,7 @@
output_name = "chip-${qpg_target_ic}-lighting-example.out"
sources = [
- "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp",
+ "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp",
"${examples_plat_dir}/app/main.cpp",
"${examples_plat_dir}/ota/ota.cpp",
"${examples_plat_dir}/powercycle_counting.c",
diff --git a/examples/lighting-app/qpg/src/AppTask.cpp b/examples/lighting-app/qpg/src/AppTask.cpp
index 1dd1aa8..4dafde6 100644
--- a/examples/lighting-app/qpg/src/AppTask.cpp
+++ b/examples/lighting-app/qpg/src/AppTask.cpp
@@ -33,7 +33,8 @@
#include <app/server/OnboardingCodesUtil.h>
#include <app-common/zap-generated/attributes/Accessors.h>
-#include <app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h>
+#include <app/TestEventTriggerDelegate.h>
+#include <app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h>
#include <app/clusters/general-diagnostics-server/general-diagnostics-server.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/clusters/on-off-server/on-off-server.h>
@@ -264,10 +265,13 @@
nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance();
initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
- // Use GenericFaultTestEventTriggerDelegate to inject faults
- static GenericFaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ // Use GenericFaultTestEventTriggerHandler to inject faults
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static GenericFaultTestEventTriggerHandler sFaultTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sFaultTestEventTriggerHandler) == CHIP_NO_ERROR);
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
chip::Server::GetInstance().Init(initParams);
diff --git a/examples/lock-app/infineon/cyw30739/src/main.cpp b/examples/lock-app/infineon/cyw30739/src/main.cpp
index 76fa848..a0a9248 100644
--- a/examples/lock-app/infineon/cyw30739/src/main.cpp
+++ b/examples/lock-app/infineon/cyw30739/src/main.cpp
@@ -28,9 +28,10 @@
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
#include <OTAConfig.h>
#endif
+#include <app/TestEventTriggerDelegate.h>
#include <app/clusters/door-lock-server/door-lock-server.h>
#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
@@ -191,10 +192,13 @@
// Print QR Code URL
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
/* Start CHIP datamodel server */
- static chip::OTATestEventTriggerDelegate testEventTriggerDelegate{ chip::ByteSpan(sTestEventTriggerEnableKey) };
+ static chip::SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static chip::OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(chip::ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
static chip::CommonCaseDeviceServerInitParams initParams;
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate);
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);
chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;
diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp
index d64a495..07a96b6 100644
--- a/examples/lock-app/nrfconnect/main/AppTask.cpp
+++ b/examples/lock-app/nrfconnect/main/AppTask.cpp
@@ -25,9 +25,10 @@
#include <DeviceInfoProviderImpl.h>
#include <app-common/zap-generated/attributes/Accessors.h>
+#include <app/TestEventTriggerDelegate.h>
#include <app/clusters/door-lock-server/door-lock-server.h>
#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <credentials/DeviceAttestationCredsProvider.h>
@@ -209,9 +210,12 @@
#endif
static CommonCaseDeviceServerInitParams initParams;
- static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams));
AppFabricTableDelegate::Init();
diff --git a/examples/lock-app/qpg/BUILD.gn b/examples/lock-app/qpg/BUILD.gn
index 2426fa7..3079487 100644
--- a/examples/lock-app/qpg/BUILD.gn
+++ b/examples/lock-app/qpg/BUILD.gn
@@ -51,7 +51,7 @@
output_name = "chip-${qpg_target_ic}-lock-example.out"
sources = [
- "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp",
+ "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp",
"${examples_plat_dir}/app/main.cpp",
"${examples_plat_dir}/ota/ota.cpp",
"src/AppTask.cpp",
diff --git a/examples/lock-app/qpg/src/AppTask.cpp b/examples/lock-app/qpg/src/AppTask.cpp
index 8bbd6b7..54a4b2a 100644
--- a/examples/lock-app/qpg/src/AppTask.cpp
+++ b/examples/lock-app/qpg/src/AppTask.cpp
@@ -26,7 +26,8 @@
#include <app/server/OnboardingCodesUtil.h>
#include <app-common/zap-generated/attributes/Accessors.h>
-#include <app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h>
+#include <app/TestEventTriggerDelegate.h>
+#include <app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h>
#include <app/clusters/general-diagnostics-server/general-diagnostics-server.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/server/Dnssd.h>
@@ -189,10 +190,13 @@
nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance();
initParams.endpointNativeParams = static_cast<void *>(&nativeParams);
- // Use GenericFaultTestEventTriggerDelegate to inject faults
- static GenericFaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ // Use GenericFaultTestEventTriggerHandler to inject faults
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static GenericFaultTestEventTriggerHandler sFaultTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sFaultTestEventTriggerHandler) == CHIP_NO_ERROR);
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
chip::Server::GetInstance().Init(initParams);
diff --git a/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp b/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp
index 9cfddd6..8bbae5e 100644
--- a/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp
+++ b/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp
@@ -28,10 +28,4 @@
return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
}
-CHIP_ERROR AmebaTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger)
-{
- bool success = emberAfHandleEventTrigger(eventTrigger);
- return success ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT;
-}
-
} // namespace chip
diff --git a/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.h b/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.h
index d461194..9e77040 100644
--- a/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.h
+++ b/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.h
@@ -18,35 +18,12 @@
#pragma once
-#include "SmokeCOAlarmManager.h"
+#include <stdint.h>
+
#include <app/TestEventTriggerDelegate.h>
-
-namespace chip {
-
-class AmebaTestEventTriggerDelegate : public TestEventTriggerDelegate
-{
-public:
- explicit AmebaTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {}
-
- /**
- * @brief Checks to see if `enableKey` provided matches value chosen by the manufacturer.
- * @param enableKey Buffer of the key to verify.
- * @return True or False.
- */
- bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
-
- /**
- * @brief User handler for handling the test event trigger based on `eventTrigger` provided.
- * @param eventTrigger Event trigger to handle.
- * @return CHIP_NO_ERROR on success or CHIP_ERROR_INVALID_ARGUMENT on failure.
- */
- CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
-
-private:
- ByteSpan mEnableKey;
-};
-
-} // namespace chip
+#include <lib/core/CHIPError.h>
+#include <lib/support/CodeUtils.h>
+#include <lib/support/Span.h>
/**
* @brief User handler for handling the test event trigger
@@ -55,7 +32,40 @@
*
* @param eventTrigger Event trigger to handle
*
+ * @warning *** DO NOT USE FOR STANDARD CLUSTER EVENT TRIGGERS ***
+ *
+ * TODO(#31723): Rename `emberAfHandleEventTrigger` to `AmebaHandleGlobalTestEventTrigger`
+ *
* @retval true on success
* @retval false if error happened
*/
bool emberAfHandleEventTrigger(uint64_t eventTrigger);
+
+namespace chip {
+
+class AmebaTestEventTriggerDelegate : public TestEventTriggerDelegate, TestEventTriggerHandler
+{
+public:
+ explicit AmebaTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey)
+ {
+ VerifyOrDie(AddHandler(this) == CHIP_NO_ERROR);
+ }
+
+ /**
+ * @brief Checks to see if `enableKey` provided matches value chosen by the manufacturer.
+ * @param enableKey Buffer of the key to verify.
+ * @return True or False.
+ */
+ bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
+
+ CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override
+ {
+ // 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/esp32/common/Esp32AppServer.cpp b/examples/platform/esp32/common/Esp32AppServer.cpp
index fee8788..b60685d 100644
--- a/examples/platform/esp32/common/Esp32AppServer.cpp
+++ b/examples/platform/esp32/common/Esp32AppServer.cpp
@@ -19,8 +19,9 @@
#include "Esp32AppServer.h"
#include "CHIPDeviceManager.h"
#include <app/InteractionModelEngine.h>
+#include <app/TestEventTriggerDelegate.h>
#include <app/clusters/network-commissioning/network-commissioning.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/Dnssd.h>
#include <app/server/Server.h>
#include <platform/ESP32/NetworkCommissioningDriver.h>
@@ -169,8 +170,11 @@
ESP_LOGE(TAG, "Failed to convert the EnableKey string to octstr type value");
memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey));
}
- static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
#endif // CONFIG_TEST_EVENT_TRIGGER_ENABLED
(void) initParams.InitializeStaticResourcesBeforeServerInit();
if (sAppDelegate != nullptr)
diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp
index 04274ab..061d7b6 100644
--- a/examples/platform/linux/AppMain.cpp
+++ b/examples/platform/linux/AppMain.cpp
@@ -75,19 +75,19 @@
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER
-#include <app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h>
+#include <app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h>
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_BOOLEAN_STATE_CONFIGURATION_TRIGGER
-#include <app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.h>
+#include <app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.h>
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER
-#include <app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h>
+#include <app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h>
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER
-#include <app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.h>
+#include <app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h>
#endif
#include <app/TestEventTriggerDelegate.h>
@@ -331,34 +331,13 @@
}
#endif
-class SampleTestEventTriggerDelegate : public TestEventTriggerDelegate
+class SampleTestEventTriggerHandler : public TestEventTriggerHandler
{
-public:
- /// NOTE: If you copy this, please use the reserved range FFFF_FFFF_<VID_HEX>_xxxx for your trigger codes.
+ /// NOTE: If you copy this for NON-STANDARD CLUSTERS OR USAGES, please use the reserved range FFFF_FFFF_<VID_HEX>_xxxx for your
+ /// trigger codes. NOTE: Standard codes are <CLUSTER_ID_HEX>_xxxx_xxxx_xxxx.
static constexpr uint64_t kSampleTestEventTriggerAlwaysSuccess = static_cast<uint64_t>(0xFFFF'FFFF'FFF1'0000ull);
- SampleTestEventTriggerDelegate() { memset(&mEnableKey[0], 0, sizeof(mEnableKey)); }
-
- /**
- * @brief Initialize the delegate with a key and an optional other handler
- *
- * The `otherDelegate` will be called if there is no match of the eventTrigger
- * when HandleEventTrigger is called, if it is non-null.
- *
- * @param enableKey - EnableKey to use for this instance.
- * @param otherDelegate - Other delegate (e.g. OTA delegate) where defer trigger. Can be nullptr
- * @return CHIP_NO_ERROR on success, CHIP_ERROR_INVALID_ARGUMENT if enableKey is wrong size.
- */
- CHIP_ERROR Init(ByteSpan enableKey, TestEventTriggerDelegate * otherDelegate)
- {
- VerifyOrReturnError(enableKey.size() == sizeof(mEnableKey), CHIP_ERROR_INVALID_ARGUMENT);
- mOtherDelegate = otherDelegate;
- MutableByteSpan ourEnableKeySpan(mEnableKey);
- return CopySpanToMutableSpan(enableKey, ourEnableKeySpan);
- }
-
- bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override { return enableKey.data_equal(ByteSpan(mEnableKey)); }
-
+public:
CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override
{
ChipLogProgress(Support, "Saw TestEventTrigger: " ChipLogFormatX64, ChipLogValueX64(eventTrigger));
@@ -370,12 +349,8 @@
return CHIP_NO_ERROR;
}
- return (mOtherDelegate != nullptr) ? mOtherDelegate->HandleEventTrigger(eventTrigger) : CHIP_ERROR_INVALID_ARGUMENT;
+ return CHIP_ERROR_INVALID_ARGUMENT;
}
-
-private:
- uint8_t mEnableKey[TestEventTriggerDelegate::kEnableKeyLength];
- TestEventTriggerDelegate * mOtherDelegate = nullptr;
};
int ChipLinuxAppInit(int argc, char * const argv[], OptionSet * customOptions,
@@ -549,44 +524,36 @@
initParams.operationalKeystore = &LinuxDeviceOptions::GetInstance().mCSRResponseOptions.badCsrOperationalKeyStoreForTest;
}
- TestEventTriggerDelegate * otherDelegate = nullptr;
+ // For general testing of TestEventTrigger, we have a common "core" event trigger delegate.
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate;
+ static SampleTestEventTriggerHandler sTestEventTriggerHandler;
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey)) ==
+ CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sTestEventTriggerHandler) == CHIP_NO_ERROR);
+
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
// We want to allow triggering OTA queries if OTA requestor is enabled
- static OTATestEventTriggerDelegate otaTestEventTriggerDelegate{ ByteSpan(
- LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey) };
- otherDelegate = &otaTestEventTriggerDelegate;
+ static OTATestEventTriggerHandler sOtaTestEventTriggerHandler;
+ sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler);
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER
- static SmokeCOTestEventTriggerDelegate smokeCOTestEventTriggerDelegate{
- ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), otherDelegate
- };
- otherDelegate = &smokeCOTestEventTriggerDelegate;
+ static SmokeCOTestEventTriggerHandler sSmokeCOTestEventTriggerHandler;
+ sTestEventTriggerDelegate.AddHandler(&sSmokeCOTestEventTriggerHandler);
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_BOOLEAN_STATE_CONFIGURATION_TRIGGER
- static BooleanStateConfigurationTestEventTriggerDelegate booleanStateConfigurationTestEventTriggerDelegate{
- ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), otherDelegate
- };
- otherDelegate = &booleanStateConfigurationTestEventTriggerDelegate;
+ static BooleanStateConfigurationTestEventTriggerHandler sBooleanStateConfigurationTestEventTriggerHandler;
+ sTestEventTriggerDelegate.AddHandler(&sBooleanStateConfigurationTestEventTriggerHandler);
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER
- static EnergyEvseTestEventTriggerDelegate energyEvseTestEventTriggerDelegate{
- ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), otherDelegate
- };
- otherDelegate = &energyEvseTestEventTriggerDelegate;
+ static EnergyEvseTestEventTriggerHandler sEnergyEvseTestEventTriggerHandler;
+ sTestEventTriggerDelegate.AddHandler(&sEnergyEvseTestEventTriggerHandler);
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER
- static EnergyReportingTestEventTriggerDelegate energyReportingTestEventTriggerDelegate{
- ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), otherDelegate
- };
- otherDelegate = &energyReportingTestEventTriggerDelegate;
+ static EnergyReportingTestEventTriggerHandler sEnergyReportingTestEventTriggerHandler;
+ sTestEventTriggerDelegate.AddHandler(&sEnergyReportingTestEventTriggerHandler);
#endif
- // For general testing of TestEventTrigger, we have a common "core" event trigger delegate.
- static SampleTestEventTriggerDelegate testEventTriggerDelegate;
- VerifyOrDie(testEventTriggerDelegate.Init(ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey),
- otherDelegate) == CHIP_NO_ERROR);
-
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
// We need to set DeviceInfoProvider before Server::Init to setup the storage of DeviceInfoProvider properly.
DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);
diff --git a/examples/platform/linux/BUILD.gn b/examples/platform/linux/BUILD.gn
index f82702b..8cf00c5 100644
--- a/examples/platform/linux/BUILD.gn
+++ b/examples/platform/linux/BUILD.gn
@@ -32,24 +32,24 @@
source_set("ota-test-event-trigger") {
sources = [
- "${chip_root}/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h",
+ "${chip_root}/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.h",
]
}
source_set("smco-test-event-trigger") {
- sources = [ "${chip_root}/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h" ]
+ sources = [ "${chip_root}/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h" ]
}
source_set("boolean-state-configuration-test-event-trigger") {
- sources = [ "${chip_root}/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.h" ]
+ sources = [ "${chip_root}/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.h" ]
}
source_set("energy-evse-test-event-trigger") {
- sources = [ "${chip_root}/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h" ]
+ sources = [ "${chip_root}/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h" ]
}
source_set("energy-reporting-test-event-trigger") {
- sources = [ "${chip_root}/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.h" ]
+ sources = [ "${chip_root}/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h" ]
}
source_set("app-main") {
diff --git a/examples/platform/nxp/se05x/linux/AppMain.cpp b/examples/platform/nxp/se05x/linux/AppMain.cpp
index 2c04b81..bd13e24 100644
--- a/examples/platform/nxp/se05x/linux/AppMain.cpp
+++ b/examples/platform/nxp/se05x/linux/AppMain.cpp
@@ -69,7 +69,8 @@
#endif // CHIP_CONFIG_TRANSPORT_TRACE_ENABLED
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/TestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#endif
#include <signal.h>
@@ -315,9 +316,12 @@
}
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
- static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(
- LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey) };
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey)) ==
+ CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
#endif
// We need to set DeviceInfoProvider before Server::Init to setup the storage of DeviceInfoProvider properly.
diff --git a/examples/platform/nxp/se05x/linux/BUILD.gn b/examples/platform/nxp/se05x/linux/BUILD.gn
index 2a93a4b..a5efe46 100644
--- a/examples/platform/nxp/se05x/linux/BUILD.gn
+++ b/examples/platform/nxp/se05x/linux/BUILD.gn
@@ -25,7 +25,7 @@
source_set("ota-test-event-trigger") {
sources = [
- "${chip_root}/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h",
+ "${chip_root}/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.h",
]
}
diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp
index 1197e4d..3a78cf7 100644
--- a/examples/platform/silabs/MatterConfig.cpp
+++ b/examples/platform/silabs/MatterConfig.cpp
@@ -219,8 +219,9 @@
SILABS_LOG("Failed to convert the EnableKey string to octstr type value");
memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey));
}
- static SilabsTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ // TODO(#31723): Show to customers that they can do `Server::GetInstance().GetTestEventTriggerDelegate().AddHandler()`
+ static SilabsTestEventTriggerDelegate sTestEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
#endif // SILABS_TEST_EVENT_TRIGGER_ENABLED
#if CHIP_CRYPTO_PLATFORM && !(defined(SIWX_917))
@@ -232,8 +233,9 @@
#ifdef PERFORMANCE_TEST_ENABLED
// Set up Test Event Trigger command of the General Diagnostics cluster. Used only in performance testing
- static SilabsTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(kTestEventTriggerEnableKey) };
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ // 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
diff --git a/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp b/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp
index f231067..f9a11df 100644
--- a/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp
+++ b/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp
@@ -27,10 +27,4 @@
return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
}
-CHIP_ERROR SilabsTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger)
-{
- bool success = emberAfHandleEventTrigger(eventTrigger);
- return success ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT;
-}
-
} // namespace chip
diff --git a/examples/platform/silabs/SilabsTestEventTriggerDelegate.h b/examples/platform/silabs/SilabsTestEventTriggerDelegate.h
index e9cd62f..e08e972 100644
--- a/examples/platform/silabs/SilabsTestEventTriggerDelegate.h
+++ b/examples/platform/silabs/SilabsTestEventTriggerDelegate.h
@@ -18,14 +18,38 @@
#pragma once
+#include <stdint.h>
+
#include <app/TestEventTriggerDelegate.h>
+#include <lib/core/CHIPError.h>
+#include <lib/support/CodeUtils.h>
+#include <lib/support/Span.h>
+
+/**
+ * @brief User handler for handling the test event trigger
+ *
+ * @note If TestEventTrigger is enabled, it needs to be implemented in the app
+ *
+ * @param eventTrigger Event trigger to handle
+ *
+ * @warning *** DO NOT USE FOR STANDARD CLUSTER EVENT TRIGGERS ***
+ *
+ * TODO(#31723): Rename `emberAfHandleEventTrigger` to `AmebaHandleGlobalTestEventTrigger`
+ *
+ * @retval true on success
+ * @retval false if error happened
+ */
+bool emberAfHandleEventTrigger(uint64_t eventTrigger);
namespace chip {
-class SilabsTestEventTriggerDelegate : public TestEventTriggerDelegate
+class SilabsTestEventTriggerDelegate : public TestEventTriggerDelegate, TestEventTriggerHandler
{
public:
- explicit SilabsTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {}
+ explicit SilabsTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey)
+ {
+ VerifyOrDie(AddHandler(this) == CHIP_NO_ERROR);
+ }
/**
* @brief Checks to see if `enableKey` provided matches value chosen by the manufacturer.
@@ -35,26 +59,19 @@
bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
/**
- * @brief User handler for handling the test event trigger based on `eventTrigger` provided.
- * @param eventTrigger Event trigger to handle.
- * @return CHIP_NO_ERROR on success or CHIP_ERROR_INVALID_ARGUMENT on failure.
+ * @brief Delegates handling to global `emberAfHandleEventTrigger` function. DO NOT EXTEND.
+ *
+ * @param eventTrigger - trigger to process.
+ * @return CHIP_NO_ERROR if properly handled, else another CHIP_ERROR.
*/
- CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
+ CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override
+ {
+ // 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
-
-/**
- * @brief User handler for handling the test event trigger
- *
- * @note If TestEventTrigger is enabled, it needs to be implemented in the app
- *
- * @param eventTrigger Event trigger to handle
- *
- * @retval true on success
- * @retval false if error happened
- */
-bool emberAfHandleEventTrigger(uint64_t eventTrigger);
diff --git a/examples/providers/DeviceInfoProviderImpl.cpp b/examples/providers/DeviceInfoProviderImpl.cpp
index 5524b77..7b07561 100644
--- a/examples/providers/DeviceInfoProviderImpl.cpp
+++ b/examples/providers/DeviceInfoProviderImpl.cpp
@@ -100,8 +100,8 @@
VerifyOrReturnError(std::strlen(labelPtr) <= kMaxLabelNameLength, false);
VerifyOrReturnError(std::strlen(valuePtr) <= kMaxLabelValueLength, false);
- Platform::CopyString(mFixedLabelNameBuf, kMaxLabelNameLength + 1, labelPtr);
- Platform::CopyString(mFixedLabelValueBuf, kMaxLabelValueLength + 1, valuePtr);
+ Platform::CopyString(mFixedLabelNameBuf, labelPtr);
+ Platform::CopyString(mFixedLabelValueBuf, valuePtr);
output.label = CharSpan::fromCharString(mFixedLabelNameBuf);
output.value = CharSpan::fromCharString(mFixedLabelValueBuf);
diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp
index fa38eba..329c8d9 100644
--- a/examples/pump-app/nrfconnect/main/AppTask.cpp
+++ b/examples/pump-app/nrfconnect/main/AppTask.cpp
@@ -25,7 +25,8 @@
#include <DeviceInfoProviderImpl.h>
#include <app-common/zap-generated/attributes/Accessors.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/TestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <app/util/attribute-storage.h>
@@ -186,9 +187,12 @@
#endif
static CommonCaseDeviceServerInitParams initParams;
- static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams));
AppFabricTableDelegate::Init();
diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp
index db96480..ca79a41 100644
--- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp
+++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp
@@ -25,7 +25,8 @@
#include <DeviceInfoProviderImpl.h>
#include <app-common/zap-generated/attributes/Accessors.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/TestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <app/util/attribute-storage.h>
@@ -184,9 +185,12 @@
#endif
static CommonCaseDeviceServerInitParams initParams;
- static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams));
AppFabricTableDelegate::Init();
diff --git a/examples/smoke-co-alarm-app/silabs/src/SmokeCoAlarmManager.cpp b/examples/smoke-co-alarm-app/silabs/src/SmokeCoAlarmManager.cpp
index 85c8bca..7d64a03 100644
--- a/examples/smoke-co-alarm-app/silabs/src/SmokeCoAlarmManager.cpp
+++ b/examples/smoke-co-alarm-app/silabs/src/SmokeCoAlarmManager.cpp
@@ -21,7 +21,7 @@
#include "AppTask.h"
#include <FreeRTOS.h>
-#include <app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h>
+#include <app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h>
#include <lib/support/TypeTraits.h>
using namespace chip;
diff --git a/examples/thermostat/qpg/BUILD.gn b/examples/thermostat/qpg/BUILD.gn
index d428557..9989e34 100644
--- a/examples/thermostat/qpg/BUILD.gn
+++ b/examples/thermostat/qpg/BUILD.gn
@@ -51,7 +51,7 @@
output_name = "chip-${qpg_target_ic}-thermostat-example.out"
sources = [
- "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp",
+ "${chip_root}/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp",
"${examples_plat_dir}/app/main.cpp",
"${examples_plat_dir}/ota/ota.cpp",
"src/AppTask.cpp",
diff --git a/examples/window-app/nrfconnect/main/AppTask.cpp b/examples/window-app/nrfconnect/main/AppTask.cpp
index f607114..7c50aed 100644
--- a/examples/window-app/nrfconnect/main/AppTask.cpp
+++ b/examples/window-app/nrfconnect/main/AppTask.cpp
@@ -24,8 +24,9 @@
#include <DeviceInfoProviderImpl.h>
+#include <app/TestEventTriggerDelegate.h>
#include <app/clusters/identify-server/identify-server.h>
-#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
+#include <app/clusters/ota-requestor/OTATestEventTriggerHandler.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/server/Server.h>
#include <app/util/attribute-storage.h>
@@ -188,9 +189,12 @@
#endif
static CommonCaseDeviceServerInitParams initParams;
- static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) };
+ static SimpleTestEventTriggerDelegate sTestEventTriggerDelegate{};
+ static OTATestEventTriggerHandler sOtaTestEventTriggerHandler{};
+ VerifyOrDie(sTestEventTriggerDelegate.Init(ByteSpan(sTestEventTriggerEnableKey)) == CHIP_NO_ERROR);
+ VerifyOrDie(sTestEventTriggerDelegate.AddHandler(&sOtaTestEventTriggerHandler) == CHIP_NO_ERROR);
(void) initParams.InitializeStaticResourcesBeforeServerInit();
- initParams.testEventTriggerDelegate = &testEventTriggerDelegate;
+ initParams.testEventTriggerDelegate = &sTestEventTriggerDelegate;
ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams));
AppFabricTableDelegate::Init();
diff --git a/src/app/TestEventTriggerDelegate.h b/src/app/TestEventTriggerDelegate.h
index 5f72415..33869d8 100644
--- a/src/app/TestEventTriggerDelegate.h
+++ b/src/app/TestEventTriggerDelegate.h
@@ -18,12 +18,27 @@
#pragma once
#include <lib/core/CHIPError.h>
+#include <lib/support/IntrusiveList.h>
#include <lib/support/Span.h>
#include <stddef.h>
#include <stdint.h>
namespace chip {
+class TestEventTriggerHandler : public IntrusiveListNodeBase<IntrusiveMode::AutoUnlink>
+{
+public:
+ virtual ~TestEventTriggerHandler() = default;
+ /**
+ * Handles the test event trigger based on `eventTrigger` provided.
+ *
+ * @param[in] eventTrigger Event trigger to handle.
+ *
+ * @return CHIP_NO_ERROR on success or another CHIP_ERROR on failure
+ */
+ virtual CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) = 0;
+};
+
class TestEventTriggerDelegate
{
public:
@@ -39,14 +54,76 @@
virtual bool DoesEnableKeyMatch(const ByteSpan & enableKey) const = 0;
/**
- * Expectation is that the caller has already validated the enable key before calling this.
* Handles the test event trigger based on `eventTrigger` provided.
*
+ * By default, this iterates over handlers added via `AddEventTriggerHandler`.
+ *
+ * If more specific behavior is desired, the method can be completely overridden.
+ *
* @param[in] eventTrigger Event trigger to handle.
*
* @return CHIP_NO_ERROR on success or another CHIP_ERROR on failure
*/
- virtual CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) = 0;
+ virtual CHIP_ERROR HandleEventTriggers(uint64_t eventTrigger)
+ {
+ CHIP_ERROR last_error = CHIP_ERROR_INVALID_ARGUMENT;
+ for (TestEventTriggerHandler & handler : mHandlerList)
+ {
+ last_error = handler.HandleEventTrigger(eventTrigger);
+ if (last_error == CHIP_NO_ERROR)
+ {
+ break;
+ }
+ }
+
+ return last_error;
+ }
+
+ CHIP_ERROR AddHandler(TestEventTriggerHandler * handler)
+ {
+ VerifyOrReturnError(!mHandlerList.Contains(handler), CHIP_ERROR_INVALID_ARGUMENT);
+ mHandlerList.PushBack(handler);
+ return CHIP_NO_ERROR;
+ }
+
+ void RemoveHandler(TestEventTriggerHandler * handler)
+ {
+ VerifyOrReturn(mHandlerList.Contains(handler));
+ mHandlerList.Remove(handler);
+ }
+
+ void ClearAllHandlers() { mHandlerList.Clear(); }
+
+protected:
+ IntrusiveList<TestEventTriggerHandler, IntrusiveMode::AutoUnlink> mHandlerList;
+};
+
+/**
+ * @brief TestEventTriggerDelegate that owns its enable key in RAM.
+ *
+ */
+class SimpleTestEventTriggerDelegate : public TestEventTriggerDelegate
+{
+public:
+ SimpleTestEventTriggerDelegate() { memset(&mEnableKey[0], 0, sizeof(mEnableKey)); }
+
+ /**
+ * @brief Initialize the delegate with a key
+ *
+ * @param enableKey - EnableKey to use for this instance.
+ * @return CHIP_NO_ERROR on success, CHIP_ERROR_INVALID_ARGUMENT if enableKey is wrong size.
+ */
+ CHIP_ERROR Init(ByteSpan enableKey)
+ {
+ VerifyOrReturnError(enableKey.size() == sizeof(mEnableKey), CHIP_ERROR_INVALID_ARGUMENT);
+ MutableByteSpan ourEnableKeySpan(mEnableKey);
+ return CopySpanToMutableSpan(enableKey, ourEnableKeySpan);
+ }
+
+ bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override { return enableKey.data_equal(ByteSpan(mEnableKey)); }
+
+private:
+ uint8_t mEnableKey[TestEventTriggerDelegate::kEnableKeyLength];
};
} // namespace chip
diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni
index 6404eb3..09d1186 100644
--- a/src/app/chip_data_model.gni
+++ b/src/app/chip_data_model.gni
@@ -255,8 +255,8 @@
"${_app_root}/clusters/${cluster}/DefaultOTARequestorUserConsent.h",
"${_app_root}/clusters/${cluster}/ExtendedOTARequestorDriver.cpp",
"${_app_root}/clusters/${cluster}/OTARequestorStorage.h",
- "${_app_root}/clusters/${cluster}/OTATestEventTriggerDelegate.cpp",
- "${_app_root}/clusters/${cluster}/OTATestEventTriggerDelegate.h",
+ "${_app_root}/clusters/${cluster}/OTATestEventTriggerHandler.cpp",
+ "${_app_root}/clusters/${cluster}/OTATestEventTriggerHandler.h",
]
} else if (cluster == "bindings") {
sources += [
@@ -322,15 +322,14 @@
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
"${_app_root}/clusters/${cluster}/${cluster}.h",
- "${_app_root}/clusters/${cluster}/SmokeCOTestEventTriggerDelegate.cpp",
- "${_app_root}/clusters/${cluster}/SmokeCOTestEventTriggerDelegate.h",
+ "${_app_root}/clusters/${cluster}/SmokeCOTestEventTriggerHandler.h",
]
} else if (cluster == "boolean-state-configuration-server") {
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
"${_app_root}/clusters/${cluster}/${cluster}.h",
- "${_app_root}/clusters/${cluster}/BooleanStateConfigurationTestEventTriggerDelegate.cpp",
- "${_app_root}/clusters/${cluster}/BooleanStateConfigurationTestEventTriggerDelegate.h",
+ "${_app_root}/clusters/${cluster}/BooleanStateConfigurationTestEventTriggerHandler.cpp",
+ "${_app_root}/clusters/${cluster}/BooleanStateConfigurationTestEventTriggerHandler.h",
]
} else if (cluster == "air-quality-server") {
sources += [
@@ -341,8 +340,7 @@
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
"${_app_root}/clusters/${cluster}/${cluster}.h",
- "${_app_root}/clusters/${cluster}/EnergyEvseTestEventTriggerDelegate.cpp",
- "${_app_root}/clusters/${cluster}/EnergyEvseTestEventTriggerDelegate.h",
+ "${_app_root}/clusters/${cluster}/EnergyEvseTestEventTriggerHandler.h",
]
} else if (cluster == "diagnostic-logs-server") {
sources += [
@@ -356,8 +354,7 @@
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
"${_app_root}/clusters/${cluster}/${cluster}.h",
- "${_app_root}/clusters/${cluster}/EnergyReportingTestEventTriggerDelegate.cpp",
- "${_app_root}/clusters/${cluster}/EnergyReportingTestEventTriggerDelegate.h",
+ "${_app_root}/clusters/${cluster}/EnergyReportingTestEventTriggerHandler.h",
]
} else {
sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ]
diff --git a/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.cpp b/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.cpp
similarity index 66%
rename from src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.cpp
rename to src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.cpp
index 00a4259..b2ffe7a 100644
--- a/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.cpp
+++ b/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.cpp
@@ -15,27 +15,18 @@
* limitations under the License.
*/
-#include "BooleanStateConfigurationTestEventTriggerDelegate.h"
+#include "BooleanStateConfigurationTestEventTriggerHandler.h"
using namespace chip::app::Clusters::BooleanStateConfiguration;
namespace chip {
-bool BooleanStateConfigurationTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const
-{
- return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
-}
-
-CHIP_ERROR BooleanStateConfigurationTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger)
+CHIP_ERROR BooleanStateConfigurationTestEventTriggerHandler::HandleEventTrigger(uint64_t eventTrigger)
{
if (HandleBooleanStateConfigurationTestEventTrigger(eventTrigger))
{
return CHIP_NO_ERROR;
}
- if (mOtherDelegate != nullptr)
- {
- return mOtherDelegate->HandleEventTrigger(eventTrigger);
- }
return CHIP_ERROR_INVALID_ARGUMENT;
}
diff --git a/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.h b/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.h
similarity index 72%
rename from src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.h
rename to src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.h
index 43b68e2..92aa2e8 100644
--- a/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerDelegate.h
+++ b/src/app/clusters/boolean-state-configuration-server/BooleanStateConfigurationTestEventTriggerHandler.h
@@ -28,21 +28,10 @@
kSensorUntrigger = 0x0080000000000001,
};
-class BooleanStateConfigurationTestEventTriggerDelegate : public TestEventTriggerDelegate
+class BooleanStateConfigurationTestEventTriggerHandler : public TestEventTriggerHandler
{
public:
- explicit BooleanStateConfigurationTestEventTriggerDelegate(const ByteSpan & enableKey,
- TestEventTriggerDelegate * otherDelegate) :
- mEnableKey(enableKey),
- mOtherDelegate(otherDelegate)
- {}
-
- bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
-
-private:
- ByteSpan mEnableKey;
- TestEventTriggerDelegate * mOtherDelegate;
};
} // namespace chip
diff --git a/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.cpp b/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.cpp
deleted file mode 100644
index 210ab40..0000000
--- a/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Copyright (c) 2024 Project CHIP Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "EnergyReportingTestEventTriggerDelegate.h"
-
-namespace chip {
-
-bool EnergyReportingTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const
-{
- return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
-}
-
-CHIP_ERROR EnergyReportingTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger)
-{
- if (HandleEnergyReportingTestEventTrigger(eventTrigger))
- {
- return CHIP_NO_ERROR;
- }
- if (mOtherDelegate != nullptr)
- {
- return mOtherDelegate->HandleEventTrigger(eventTrigger);
- }
- return CHIP_ERROR_INVALID_ARGUMENT;
-}
-
-} // namespace chip
diff --git a/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.h b/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h
similarity index 64%
rename from src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.h
rename to src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h
index a7beef6..d254d7a 100644
--- a/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerDelegate.h
+++ b/src/app/clusters/electrical-energy-measurement-server/EnergyReportingTestEventTriggerHandler.h
@@ -20,6 +20,18 @@
#include <app-common/zap-generated/cluster-objects.h>
#include <app/TestEventTriggerDelegate.h>
+/**
+ * @brief User handler for handling the test event trigger
+ *
+ * @note If TestEventTrigger is enabled, it needs to be implemented in the app
+ *
+ * @param eventTrigger Event trigger to handle
+ *
+ * @retval true on success
+ * @retval false if error happened
+ */
+bool HandleEnergyReportingTestEventTrigger(uint64_t eventTrigger);
+
namespace chip {
/*
@@ -40,44 +52,19 @@
};
-class EnergyReportingTestEventTriggerDelegate : public TestEventTriggerDelegate
+class EnergyReportingTestEventTriggerHandler : public TestEventTriggerHandler
{
public:
- /**
- * This class expects the enableKey ByteSpan to be valid forever.
- * Typically this feature is only enabled in certification testing
- * and uses a static secret key in the device for testing (e.g. in factory data)
- */
- explicit EnergyReportingTestEventTriggerDelegate(const ByteSpan & enableKey, TestEventTriggerDelegate * otherDelegate) :
- mEnableKey(enableKey), mOtherDelegate(otherDelegate)
- {}
+ EnergyReportingTestEventTriggerHandler() {}
- /* This function returns True if the enableKey received in the TestEventTrigger command
- * matches the value passed into the constructor.
- */
- bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
-
- /** This function must return True if the eventTrigger is recognised and handled
- * It must return False to allow a higher level TestEvent handler to check other
- * clusters that may handle it.
- */
- CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
-
-private:
- ByteSpan mEnableKey;
- TestEventTriggerDelegate * mOtherDelegate;
+ CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override
+ {
+ if (HandleEnergyReportingTestEventTrigger(eventTrigger))
+ {
+ return CHIP_NO_ERROR;
+ }
+ return CHIP_ERROR_INVALID_ARGUMENT;
+ }
};
} // namespace chip
-
-/**
- * @brief User handler for handling the test event trigger
- *
- * @note If TestEventTrigger is enabled, it needs to be implemented in the app
- *
- * @param eventTrigger Event trigger to handle
- *
- * @retval true on success
- * @retval false if error happened
- */
-bool HandleEnergyReportingTestEventTrigger(uint64_t eventTrigger);
diff --git a/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.cpp b/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.cpp
deleted file mode 100644
index 78fb870..0000000
--- a/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- * Copyright (c) 2023 Project CHIP Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "EnergyEvseTestEventTriggerDelegate.h"
-
-using namespace chip::app::Clusters::EnergyEvse;
-
-namespace chip {
-
-bool EnergyEvseTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const
-{
- return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
-}
-
-CHIP_ERROR EnergyEvseTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger)
-{
- if (HandleEnergyEvseTestEventTrigger(eventTrigger))
- {
- return CHIP_NO_ERROR;
- }
- if (mOtherDelegate != nullptr)
- {
- return mOtherDelegate->HandleEventTrigger(eventTrigger);
- }
- return CHIP_ERROR_INVALID_ARGUMENT;
-}
-
-} // namespace chip
diff --git a/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h b/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h
similarity index 78%
rename from src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h
rename to src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h
index 3c1dff4..307156e 100644
--- a/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h
+++ b/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h
@@ -20,6 +20,18 @@
#include <app-common/zap-generated/cluster-objects.h>
#include <app/TestEventTriggerDelegate.h>
+/**
+ * @brief User handler for handling the test event trigger
+ *
+ * @note If TestEventTrigger is enabled, it needs to be implemented in the app
+ *
+ * @param eventTrigger Event trigger to handle
+ *
+ * @retval true on success
+ * @retval false if error happened
+ */
+bool HandleEnergyEvseTestEventTrigger(uint64_t eventTrigger);
+
namespace chip {
/*
@@ -55,44 +67,23 @@
kEVSEDiagnosticsComplete = 0x0099000000000020,
};
-class EnergyEvseTestEventTriggerDelegate : public TestEventTriggerDelegate
+class EnergyEvseTestEventTriggerHandler : public TestEventTriggerHandler
{
public:
- /**
- * This class expects the enableKey ByteSpan to be valid forever.
- * Typically this feature is only enabled in certification testing
- * and uses a static secret key in the device for testing (e.g. in factory data)
- */
- explicit EnergyEvseTestEventTriggerDelegate(const ByteSpan & enableKey, TestEventTriggerDelegate * otherDelegate) :
- mEnableKey(enableKey), mOtherDelegate(otherDelegate)
- {}
-
- /* This function returns True if the enableKey received in the TestEventTrigger command
- * matches the value passed into the constructor.
- */
- bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
+ explicit EnergyEvseTestEventTriggerHandler() {}
/** This function must return True if the eventTrigger is recognised and handled
* It must return False to allow a higher level TestEvent handler to check other
* clusters that may handle it.
*/
- CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
-
-private:
- ByteSpan mEnableKey;
- TestEventTriggerDelegate * mOtherDelegate;
+ CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override
+ {
+ if (HandleEnergyEvseTestEventTrigger(eventTrigger))
+ {
+ return CHIP_NO_ERROR;
+ }
+ return CHIP_ERROR_INVALID_ARGUMENT;
+ }
};
} // namespace chip
-
-/**
- * @brief User handler for handling the test event trigger
- *
- * @note If TestEventTrigger is enabled, it needs to be implemented in the app
- *
- * @param eventTrigger Event trigger to handle
- *
- * @retval true on success
- * @retval false if error happened
- */
-bool HandleEnergyEvseTestEventTrigger(uint64_t eventTrigger);
diff --git a/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h
deleted file mode 100644
index f304518..0000000
--- a/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Copyright (c) 2022 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <app/TestEventTriggerDelegate.h>
-
-namespace chip {
-
-class GenericFaultTestEventTriggerDelegate : public TestEventTriggerDelegate
-{
-public:
- static constexpr uint64_t kGenericFaultQueryTrigger = 0xFFFF'FFFF'10D0'0001;
- static constexpr uint64_t kGenericFaultQueryFabricIndexMask = 0xff;
-
- explicit GenericFaultTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {}
-
- bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
- CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
-
-private:
- ByteSpan mEnableKey;
-};
-
-} // namespace chip
diff --git a/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp
similarity index 89%
rename from src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp
rename to src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp
index 6c50b58..b733524 100644
--- a/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp
+++ b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-#include "GenericFaultTestEventTriggerDelegate.h"
+#include "GenericFaultTestEventTriggerHandler.h"
#include <app/clusters/general-diagnostics-server/general-diagnostics-server.h>
#include <lib/support/CodeUtils.h>
@@ -25,15 +25,10 @@
namespace chip {
-bool GenericFaultTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const
-{
- return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
-}
-
-CHIP_ERROR GenericFaultTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger)
+CHIP_ERROR GenericFaultTestEventTriggerHandler::HandleEventTrigger(uint64_t eventTrigger)
{
- if ((eventTrigger & ~kGenericFaultQueryFabricIndexMask) == kGenericFaultQueryTrigger)
+ if (eventTrigger == kGenericFaultQueryTrigger)
{
// Fault injection
GeneralFaults<kMaxHardwareFaults> hwFaultsPrevious;
diff --git a/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h
similarity index 66%
copy from src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h
copy to src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h
index 6c78a16..4dea743 100644
--- a/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h
+++ b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h
@@ -22,19 +22,12 @@
namespace chip {
-class OTATestEventTriggerDelegate : public TestEventTriggerDelegate
+class GenericFaultTestEventTriggerHandler : public TestEventTriggerHandler
{
public:
- static constexpr uint64_t kOtaQueryTrigger = 0x0100'0000'0000'0100;
- static constexpr uint64_t kOtaQueryFabricIndexMask = 0xff;
+ static constexpr uint64_t kGenericFaultQueryTrigger = 0x3333'FFFF'10D0'0001;
- explicit OTATestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {}
-
- bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
-
-private:
- ByteSpan mEnableKey;
};
} // namespace chip
diff --git a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp
index c0130e9..c392c96 100644
--- a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp
+++ b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp
@@ -380,7 +380,7 @@
return true;
}
- CHIP_ERROR handleEventTriggerResult = triggerDelegate->HandleEventTrigger(commandData.eventTrigger);
+ CHIP_ERROR handleEventTriggerResult = triggerDelegate->HandleEventTriggers(commandData.eventTrigger);
// When HandleEventTrigger fails, we simply convert any error to INVALID_COMMAND
commandObj->AddStatus(commandPath, (handleEventTriggerResult != CHIP_NO_ERROR) ? Status::InvalidCommand : Status::Success);
diff --git a/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.cpp b/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.cpp
similarity index 80%
rename from src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.cpp
rename to src/app/clusters/ota-requestor/OTATestEventTriggerHandler.cpp
index a879f81..885aced 100644
--- a/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.cpp
+++ b/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.cpp
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-#include "OTATestEventTriggerDelegate.h"
+#include "OTATestEventTriggerHandler.h"
#include "OTARequestorInterface.h"
@@ -24,12 +24,7 @@
namespace chip {
-bool OTATestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const
-{
- return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
-}
-
-CHIP_ERROR OTATestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger)
+CHIP_ERROR OTATestEventTriggerHandler::HandleEventTrigger(uint64_t eventTrigger)
{
if ((eventTrigger & ~kOtaQueryFabricIndexMask) == kOtaQueryTrigger)
{
diff --git a/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h b/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.h
similarity index 73%
rename from src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h
rename to src/app/clusters/ota-requestor/OTATestEventTriggerHandler.h
index 6c78a16..bb49a3d 100644
--- a/src/app/clusters/ota-requestor/OTATestEventTriggerDelegate.h
+++ b/src/app/clusters/ota-requestor/OTATestEventTriggerHandler.h
@@ -22,19 +22,15 @@
namespace chip {
-class OTATestEventTriggerDelegate : public TestEventTriggerDelegate
+class OTATestEventTriggerHandler : public TestEventTriggerHandler
{
public:
- static constexpr uint64_t kOtaQueryTrigger = 0x0100'0000'0000'0100;
+ static constexpr uint64_t kOtaQueryTrigger = 0x002a'0000'0000'0100;
static constexpr uint64_t kOtaQueryFabricIndexMask = 0xff;
- explicit OTATestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {}
+ OTATestEventTriggerHandler() {}
- bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
-
-private:
- ByteSpan mEnableKey;
};
} // namespace chip
diff --git a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp
deleted file mode 100644
index 597737b..0000000
--- a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- * Copyright (c) 2023 Project CHIP Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "SmokeCOTestEventTriggerDelegate.h"
-
-using namespace chip::app::Clusters::SmokeCoAlarm;
-
-namespace chip {
-
-bool SmokeCOTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const
-{
- return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
-}
-
-CHIP_ERROR SmokeCOTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger)
-{
- if (HandleSmokeCOTestEventTrigger(eventTrigger))
- {
- return CHIP_NO_ERROR;
- }
- if (mOtherDelegate != nullptr)
- {
- return mOtherDelegate->HandleEventTrigger(eventTrigger);
- }
- return CHIP_ERROR_INVALID_ARGUMENT;
-}
-
-} // namespace chip
diff --git a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h
deleted file mode 100644
index 599eb6a..0000000
--- a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *
- * Copyright (c) 2023 Project CHIP Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <app-common/zap-generated/cluster-objects.h>
-#include <app/TestEventTriggerDelegate.h>
-
-namespace chip {
-
-enum class SmokeCOTrigger : uint64_t
-{
- // Force alarm commands
- kForceSmokeWarning = 0xffffffff00000090,
- kForceCOWarning = 0xffffffff00000091,
- kForceSmokeInterconnect = 0xffffffff00000092,
- kForceMalfunction = 0xffffffff00000093,
- kForceCOInterconnect = 0xffffffff00000094,
- kForceLowBatteryWarning = 0xffffffff00000095,
- kForceSmokeContaminationHigh = 0xffffffff00000096,
- kForceSmokeContaminationLow = 0xffffffff00000097,
- kForceSmokeSensitivityHigh = 0xffffffff00000098,
- kForceSmokeSensitivityLow = 0xffffffff00000099,
- kForceEndOfLife = 0xffffffff0000009a,
- kForceSilence = 0xffffffff0000009b,
- kForceSmokeCritical = 0xffffffff0000009c,
- kForceCOCritical = 0xffffffff0000009d,
- kForceLowBatteryCritical = 0xffffffff0000009e,
- // Clear alarm commands
- kClearSmoke = 0xffffffff000000a0,
- kClearCO = 0xffffffff000000a1,
- kClearSmokeInterconnect = 0xffffffff000000a2,
- kClearMalfunction = 0xffffffff000000a3,
- kClearCOInterconnect = 0xffffffff000000a4,
- kClearBatteryLevelLow = 0xffffffff000000a5,
- kClearContamination = 0xffffffff000000a6,
- kClearSensitivity = 0xffffffff000000a8,
- kClearEndOfLife = 0xffffffff000000aa,
- kClearSilence = 0xffffffff000000ab
-};
-
-class SmokeCOTestEventTriggerDelegate : public TestEventTriggerDelegate
-{
-public:
- explicit SmokeCOTestEventTriggerDelegate(const ByteSpan & enableKey, TestEventTriggerDelegate * otherDelegate) :
- mEnableKey(enableKey), mOtherDelegate(otherDelegate)
- {}
-
- bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
- CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
-
-private:
- ByteSpan mEnableKey;
- TestEventTriggerDelegate * mOtherDelegate;
-};
-
-} // namespace chip
-
-/**
- * @brief User handler for handling the test event trigger
- *
- * @note If TestEventTrigger is enabled, it needs to be implemented in the app
- *
- * @param eventTrigger Event trigger to handle
- *
- * @retval true on success
- * @retval false if error happened
- */
-bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger);
diff --git a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h
new file mode 100644
index 0000000..a64ab5f
--- /dev/null
+++ b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h
@@ -0,0 +1,78 @@
+/*
+ *
+ * Copyright (c) 2023 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <app-common/zap-generated/cluster-objects.h>
+#include <app/TestEventTriggerDelegate.h>
+
+/**
+ * @brief User handler for handling the test event trigger
+ *
+ * @note If TestEventTrigger is enabled, it needs to be implemented in the app
+ *
+ * @param eventTrigger Event trigger to handle
+ *
+ * @retval true on success
+ * @retval false if error happened
+ */
+bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger);
+
+namespace chip {
+
+enum class SmokeCOTrigger : uint64_t
+{
+ // Force alarm commands
+ kForceSmokeWarning = 0x005c'0000'00000090,
+ kForceCOWarning = 0x005c'0000'00000091,
+ kForceSmokeInterconnect = 0x005c'0000'00000092,
+ kForceMalfunction = 0x005c'0000'00000093,
+ kForceCOInterconnect = 0x005c'0000'00000094,
+ kForceLowBatteryWarning = 0x005c'0000'00000095,
+ kForceSmokeContaminationHigh = 0x005c'0000'00000096,
+ kForceSmokeContaminationLow = 0x005c'0000'00000097,
+ kForceSmokeSensitivityHigh = 0x005c'0000'00000098,
+ kForceSmokeSensitivityLow = 0x005c'0000'00000099,
+ kForceEndOfLife = 0x005c'0000'0000009a,
+ kForceSilence = 0x005c'0000'0000009b,
+ kForceSmokeCritical = 0x005c'0000'0000009c,
+ kForceCOCritical = 0x005c'0000'0000009d,
+ kForceLowBatteryCritical = 0x005c'0000'0000009e,
+ // Clear alarm commands
+ kClearSmoke = 0x005c'0000'000000a0,
+ kClearCO = 0x005c'0000'000000a1,
+ kClearSmokeInterconnect = 0x005c'0000'000000a2,
+ kClearMalfunction = 0x005c'0000'000000a3,
+ kClearCOInterconnect = 0x005c'0000'000000a4,
+ kClearBatteryLevelLow = 0x005c'0000'000000a5,
+ kClearContamination = 0x005c'0000'000000a6,
+ kClearSensitivity = 0x005c'0000'000000a8,
+ kClearEndOfLife = 0x005c'0000'000000aa,
+ kClearSilence = 0x005c'0000'000000ab
+};
+
+class SmokeCOTestEventTriggerHandler : public TestEventTriggerHandler
+{
+public:
+ SmokeCOTestEventTriggerHandler() = default;
+ CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override
+ {
+ return HandleSmokeCOTestEventTrigger(eventTrigger) ? CHIP_NO_ERROR : CHIP_ERROR_INVALID_ARGUMENT;
+ }
+};
+
+} // namespace chip
diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn
index d0f9a73..9a21f1f 100644
--- a/src/app/tests/BUILD.gn
+++ b/src/app/tests/BUILD.gn
@@ -153,6 +153,7 @@
"TestReportingEngine.cpp",
"TestStatusIB.cpp",
"TestStatusResponseMessage.cpp",
+ "TestTestEventTriggerDelegate.cpp",
"TestTimeSyncDataProvider.cpp",
"TestTimedHandler.cpp",
"TestWriteInteraction.cpp",
diff --git a/src/app/tests/TestTestEventTriggerDelegate.cpp b/src/app/tests/TestTestEventTriggerDelegate.cpp
new file mode 100644
index 0000000..cd7f3ae
--- /dev/null
+++ b/src/app/tests/TestTestEventTriggerDelegate.cpp
@@ -0,0 +1,192 @@
+/*
+ *
+ * Copyright (c) 2024 Project CHIP Authors
+ * All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+
+#include <app/TestEventTriggerDelegate.h>
+#include <lib/support/Span.h>
+#include <lib/support/UnitTestRegistration.h>
+#include <nlunit-test.h>
+
+using namespace chip;
+
+namespace {
+
+class TestEventHandler : public TestEventTriggerHandler
+{
+public:
+ TestEventHandler() = delete;
+
+ explicit TestEventHandler(uint64_t supportedEventTriggerValue) : mSupportedEventTriggerValue(supportedEventTriggerValue) {}
+
+ CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override
+ {
+ if (eventTrigger == mSupportedEventTriggerValue)
+ {
+ ++mCount;
+ return CHIP_NO_ERROR;
+ }
+ return CHIP_ERROR_INVALID_ARGUMENT;
+ }
+
+ int GetCount() const { return mCount; }
+ void ClearCount() { mCount = 0; }
+
+private:
+ uint64_t mSupportedEventTriggerValue;
+ int mCount = 0;
+};
+
+class TestEventDelegate : public TestEventTriggerDelegate
+{
+public:
+ explicit TestEventDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {}
+
+ bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override
+ {
+ return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
+ }
+
+private:
+ ByteSpan mEnableKey;
+};
+
+void TestKeyChecking(nlTestSuite * aSuite, void * aContext)
+{
+ const uint8_t kTestKey[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+ const uint8_t kBadKey[16] = { 255, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+ const uint8_t kDiffLenBadKey[17] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+ TestEventDelegate delegate{ ByteSpan{ kTestKey } };
+
+ NL_TEST_ASSERT(aSuite, delegate.DoesEnableKeyMatch(ByteSpan{ kTestKey }) == true);
+ NL_TEST_ASSERT(aSuite, delegate.DoesEnableKeyMatch(ByteSpan{ kBadKey }) == false);
+ NL_TEST_ASSERT(aSuite, delegate.DoesEnableKeyMatch(ByteSpan{ kDiffLenBadKey }) == false);
+ NL_TEST_ASSERT(aSuite, delegate.DoesEnableKeyMatch(ByteSpan{}) == false);
+}
+
+void TestHandlerManagement(nlTestSuite * aSuite, void * aContext)
+{
+ const uint8_t kTestKey[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+
+ TestEventDelegate delegate{ ByteSpan{ kTestKey } };
+
+ TestEventHandler event1Handler{ 1 };
+ TestEventHandler event2Handler{ 2 };
+
+ // Add 2, check 2 works 1 doesn't.
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) != CHIP_NO_ERROR);
+
+ NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event2Handler) == CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event2Handler) != CHIP_NO_ERROR);
+
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) == CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) != CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) == CHIP_NO_ERROR);
+
+ NL_TEST_ASSERT(aSuite, event1Handler.GetCount() == 0);
+ NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 2);
+
+ event1Handler.ClearCount();
+ event2Handler.ClearCount();
+
+ // Add 1, check 1 and 2 work.
+ NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event1Handler) == CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event1Handler) != CHIP_NO_ERROR);
+
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) == CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) == CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) == CHIP_NO_ERROR);
+
+ NL_TEST_ASSERT(aSuite, event1Handler.GetCount() == 2);
+ NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 1);
+
+ event1Handler.ClearCount();
+ event2Handler.ClearCount();
+
+ // Remove 2, check 1 works.
+ delegate.RemoveHandler(&event2Handler);
+
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) == CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) != CHIP_NO_ERROR);
+
+ NL_TEST_ASSERT(aSuite, event1Handler.GetCount() == 1);
+ NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 0);
+
+ // Remove again, should be NO-OP.
+ delegate.RemoveHandler(&event2Handler);
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) != CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 0);
+
+ event1Handler.ClearCount();
+ event2Handler.ClearCount();
+
+ // Add 2 again, check 1 and 2 work.
+ NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event2Handler) == CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event2Handler) != CHIP_NO_ERROR);
+
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) == CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) == CHIP_NO_ERROR);
+
+ NL_TEST_ASSERT(aSuite, event1Handler.GetCount() == 1);
+ NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 1);
+
+ event1Handler.ClearCount();
+ event2Handler.ClearCount();
+
+ // Remove all handlers, check neither works.
+ delegate.ClearAllHandlers();
+
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(1) != CHIP_NO_ERROR);
+ NL_TEST_ASSERT(aSuite, delegate.HandleEventTriggers(2) != CHIP_NO_ERROR);
+
+ NL_TEST_ASSERT(aSuite, event1Handler.GetCount() == 0);
+ NL_TEST_ASSERT(aSuite, event2Handler.GetCount() == 0);
+
+ // Add a handler at the end: having it remaining should not cause crashes/leaks.
+ NL_TEST_ASSERT(aSuite, delegate.AddHandler(&event2Handler) == CHIP_NO_ERROR);
+}
+
+int TestSetup(void * inContext)
+{
+ return SUCCESS;
+}
+
+int TestTeardown(void * inContext)
+{
+ return SUCCESS;
+}
+
+} // namespace
+
+int TestTestEventTriggerDelegate()
+{
+ static nlTest sTests[] = { NL_TEST_DEF("TestKeyChecking", TestKeyChecking),
+ NL_TEST_DEF("TestHandlerManagement", TestHandlerManagement), NL_TEST_SENTINEL() };
+
+ nlTestSuite theSuite = {
+ "TestTestEventTriggerDelegate",
+ &sTests[0],
+ TestSetup,
+ TestTeardown,
+ };
+
+ nlTestRunner(&theSuite, nullptr);
+ return (nlTestRunnerStats(&theSuite));
+}
+
+CHIP_REGISTER_TEST_SUITE(TestTestEventTriggerDelegate)
diff --git a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml
index 37b3eb0..4d26172 100644
--- a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml
+++ b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_2.yaml
@@ -29,13 +29,13 @@
defaultValue: "hex:00112233445566778899aabbccddeeff"
TEST_EVENT_TRIGGER_WARNING_SMOKE_ALARM:
type: int64u
- defaultValue: "0xffffffff00000090"
+ defaultValue: "0x005c000000000090"
TEST_EVENT_TRIGGER_CRITICAL_SMOKE_ALARM:
type: int64u
- defaultValue: "0xffffffff0000009c"
+ defaultValue: "0x005c00000000009c"
TEST_EVENT_TRIGGER_SMOKE_ALARM_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a0"
+ defaultValue: "0x005c0000000000a0"
tests:
- label: "Step 1: Commission DUT to TH"
diff --git a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml
index c9de09f..21aa0d7 100644
--- a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml
+++ b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_5.yaml
@@ -29,58 +29,58 @@
defaultValue: "hex:00112233445566778899aabbccddeeff"
TEST_EVENT_TRIGGER_WARNING_SMOKE_ALARM:
type: int64u
- defaultValue: "0xffffffff00000090"
+ defaultValue: "0x005c000000000090"
TEST_EVENT_TRIGGER_CRITICAL_SMOKE_ALARM:
type: int64u
- defaultValue: "0xffffffff0000009c"
+ defaultValue: "0x005c00000000009c"
TEST_EVENT_TRIGGER_SMOKE_ALARM_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a0"
+ defaultValue: "0x005c0000000000a0"
TEST_EVENT_TRIGGER_WARNING_CO_ALARM:
type: int64u
- defaultValue: "0xffffffff00000091"
+ defaultValue: "0x005c000000000091"
TEST_EVENT_TRIGGER_CRITICAL_CO_ALARM:
type: int64u
- defaultValue: "0xffffffff0000009d"
+ defaultValue: "0x005c00000000009d"
TEST_EVENT_TRIGGER_CO_ALARM_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a1"
+ defaultValue: "0x005c0000000000a1"
TEST_EVENT_TRIGGER_DEVICE_MUTED:
type: int64u
- defaultValue: "0xffffffff0000009b"
+ defaultValue: "0x005c00000000009b"
TEST_EVENT_TRIGGER_DEVICE_MUTED_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000ab"
+ defaultValue: "0x005c0000000000ab"
TEST_EVENT_TRIGGER_INTERCONNECT_SMOKE_ALARM:
type: int64u
- defaultValue: "0xffffffff00000092"
+ defaultValue: "0x005c000000000092"
TEST_EVENT_TRIGGER_INTERCONNECT_SMOKE_ALARM_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a2"
+ defaultValue: "0x005c0000000000a2"
TEST_EVENT_TRIGGER_INTERCONNECT_CO_ALARM:
type: int64u
- defaultValue: "0xffffffff00000094"
+ defaultValue: "0x005c000000000094"
TEST_EVENT_TRIGGER_INTERCONNECT_CO_ALARM_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a4"
+ defaultValue: "0x005c0000000000a4"
TEST_EVENT_TRIGGER_CONTAMINATION_STATE_HIGH:
type: int64u
- defaultValue: "0xffffffff00000096"
+ defaultValue: "0x005c000000000096"
TEST_EVENT_TRIGGER_CONTAMINATION_STATE_LOW:
type: int64u
- defaultValue: "0xffffffff00000097"
+ defaultValue: "0x005c000000000097"
TTEST_EVENT_TRIGGER_CONTAMINATION_STATE_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a6"
+ defaultValue: "0x005c0000000000a6"
TEST_EVENT_TRIGGER_SENSITIVITY_LEVEL_HIGH:
type: int64u
- defaultValue: "0xffffffff00000098"
+ defaultValue: "0x005c000000000098"
TEST_EVENT_TRIGGER_SENSITIVITY_LEVEL_LOW:
type: int64u
- defaultValue: "0xffffffff00000099"
+ defaultValue: "0x005c000000000099"
TTEST_EVENT_TRIGGER_SENSITIVITY_LEVEL_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a8"
+ defaultValue: "0x005c0000000000a8"
tests:
- label: "Step 1: Commission DUT to TH"
diff --git a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_6.yaml b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_6.yaml
index 00ecd8b..2889336 100644
--- a/src/app/tests/suites/certification/Test_TC_SMOKECO_2_6.yaml
+++ b/src/app/tests/suites/certification/Test_TC_SMOKECO_2_6.yaml
@@ -29,34 +29,34 @@
defaultValue: "hex:00112233445566778899aabbccddeeff"
TEST_EVENT_TRIGGER_WARNING_SMOKE_ALARM:
type: int64u
- defaultValue: "0xffffffff00000090"
+ defaultValue: "0x005c000000000090"
TEST_EVENT_TRIGGER_SMOKE_ALARM_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a0"
+ defaultValue: "0x005c0000000000a0"
TEST_EVENT_TRIGGER_WARNING_CO_ALARM:
type: int64u
- defaultValue: "0xffffffff00000091"
+ defaultValue: "0x005c000000000091"
TEST_EVENT_TRIGGER_CO_ALARM_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a1"
+ defaultValue: "0x005c0000000000a1"
TEST_EVENT_TRIGGER_WARNING_BATTERY_ALERT:
type: int64u
- defaultValue: "0xffffffff00000095"
+ defaultValue: "0x005c000000000095"
TEST_EVENT_TRIGGER_BATTERY_ALERT_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a5"
+ defaultValue: "0x005c0000000000a5"
TEST_EVENT_TRIGGER_INTERCONNECT_SMOKE_ALARM:
type: int64u
- defaultValue: "0xffffffff00000092"
+ defaultValue: "0x005c000000000092"
TEST_EVENT_TRIGGER_INTERCONNECT_SMOKE_ALARM_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a2"
+ defaultValue: "0x005c0000000000a2"
TEST_EVENT_TRIGGER_INTERCONNECT_CO_ALARM:
type: int64u
- defaultValue: "0xffffffff00000094"
+ defaultValue: "0x005c000000000094"
TEST_EVENT_TRIGGER_INTERCONNECT_CO_ALARM_CLEAR:
type: int64u
- defaultValue: "0xffffffff000000a4"
+ defaultValue: "0x005c0000000000a4"
HIEST_PRI_ALARM:
type: int8u
defaultValue: 1
diff --git a/src/lib/support/IntrusiveList.h b/src/lib/support/IntrusiveList.h
index 8bd0afb..961113e 100644
--- a/src/lib/support/IntrusiveList.h
+++ b/src/lib/support/IntrusiveList.h
@@ -439,6 +439,14 @@
void Remove(T * value) { IntrusiveListBase::Remove(Hook::ToNode(value)); }
void Replace(T * original, T * replacement) { IntrusiveListBase::Replace(Hook::ToNode(original), Hook::ToNode(replacement)); }
bool Contains(const T * value) const { return IntrusiveListBase::Contains(Hook::ToNode(value)); }
+
+ void Clear()
+ {
+ while (begin() != end())
+ {
+ Remove(&(*begin()));
+ }
+ }
};
} // namespace chip
diff --git a/src/lib/support/tests/TestIntrusiveList.cpp b/src/lib/support/tests/TestIntrusiveList.cpp
index afe7a1c..0d1779b 100644
--- a/src/lib/support/tests/TestIntrusiveList.cpp
+++ b/src/lib/support/tests/TestIntrusiveList.cpp
@@ -131,6 +131,35 @@
list.Remove(&b);
}
+void TestClear(nlTestSuite * inSuite, void * inContext)
+{
+ ListNode a, b, c;
+ IntrusiveList<ListNode> list;
+
+ NL_TEST_ASSERT(inSuite, !list.Contains(&a));
+ NL_TEST_ASSERT(inSuite, !list.Contains(&b));
+ NL_TEST_ASSERT(inSuite, !list.Contains(&c));
+
+ list.PushBack(&a);
+ list.PushFront(&c);
+
+ NL_TEST_ASSERT(inSuite, list.Contains(&a));
+ NL_TEST_ASSERT(inSuite, !list.Contains(&b));
+ NL_TEST_ASSERT(inSuite, list.Contains(&c));
+
+ list.PushBack(&b);
+
+ NL_TEST_ASSERT(inSuite, list.Contains(&a));
+ NL_TEST_ASSERT(inSuite, list.Contains(&b));
+ NL_TEST_ASSERT(inSuite, list.Contains(&c));
+
+ list.Clear();
+
+ NL_TEST_ASSERT(inSuite, !list.Contains(&a));
+ NL_TEST_ASSERT(inSuite, !list.Contains(&b));
+ NL_TEST_ASSERT(inSuite, !list.Contains(&c));
+}
+
void TestReplaceNode(nlTestSuite * inSuite, void * inContext)
{
ListNode a, b;
@@ -242,6 +271,7 @@
NL_TEST_DEF_FN(TestReplaceNode), //
NL_TEST_DEF_FN(TestMoveList), //
NL_TEST_DEF_FN(TestAutoUnlink), //
+ NL_TEST_DEF_FN(TestClear), //
NL_TEST_SENTINEL(), //
};
diff --git a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp
index 1a01acf..69935bb 100644
--- a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp
+++ b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp
@@ -28,15 +28,4 @@
return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
}
-CHIP_ERROR DefaultTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger)
-{
- if (eventTrigger == kQueryTrigger)
- {
- ChipLogProgress(DeviceLayer, "DefaultTestEventTriggerDelegate: event triggered");
- return CHIP_NO_ERROR;
- }
-
- return CHIP_ERROR_INVALID_ARGUMENT;
-}
-
} // namespace chip
diff --git a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h
index cf71fb3..0bfd4c5 100644
--- a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h
+++ b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h
@@ -25,12 +25,9 @@
class DefaultTestEventTriggerDelegate : public TestEventTriggerDelegate
{
public:
- static constexpr uint64_t kQueryTrigger = 1234;
-
explicit DefaultTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {}
bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
- CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
private:
ByteSpan mEnableKey;
diff --git a/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.cpp b/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.cpp
index 1a01acf..69935bb 100644
--- a/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.cpp
+++ b/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.cpp
@@ -28,15 +28,4 @@
return !mEnableKey.empty() && mEnableKey.data_equal(enableKey);
}
-CHIP_ERROR DefaultTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger)
-{
- if (eventTrigger == kQueryTrigger)
- {
- ChipLogProgress(DeviceLayer, "DefaultTestEventTriggerDelegate: event triggered");
- return CHIP_NO_ERROR;
- }
-
- return CHIP_ERROR_INVALID_ARGUMENT;
-}
-
} // namespace chip
diff --git a/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.h b/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.h
index cf71fb3..0bfd4c5 100644
--- a/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.h
+++ b/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.h
@@ -25,12 +25,9 @@
class DefaultTestEventTriggerDelegate : public TestEventTriggerDelegate
{
public:
- static constexpr uint64_t kQueryTrigger = 1234;
-
explicit DefaultTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {}
bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override;
- CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
private:
ByteSpan mEnableKey;
diff --git a/src/python_testing/TC_BOOLCFG_4_2.py b/src/python_testing/TC_BOOLCFG_4_2.py
index 06f5eca..c0a74a9 100644
--- a/src/python_testing/TC_BOOLCFG_4_2.py
+++ b/src/python_testing/TC_BOOLCFG_4_2.py
@@ -65,10 +65,11 @@
asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params,
"PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in "
- "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:<key>")
+ "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:<key>, "
+ "e.g. --hex-arg PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f")
endpoint = self.user_params.get("endpoint", 1)
- enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big')
+ enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY']
self.step(1)
attributes = Clusters.BooleanStateConfiguration.Attributes
diff --git a/src/python_testing/TC_BOOLCFG_4_3.py b/src/python_testing/TC_BOOLCFG_4_3.py
index 40a44a0..90106ef 100644
--- a/src/python_testing/TC_BOOLCFG_4_3.py
+++ b/src/python_testing/TC_BOOLCFG_4_3.py
@@ -77,10 +77,11 @@
asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params,
"PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in "
- "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:<key>")
+ "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:<key>, "
+ "e.g. --hex-arg PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f")
endpoint = self.user_params.get("endpoint", 1)
- enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big')
+ enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY']
self.step(1)
attributes = Clusters.BooleanStateConfiguration.Attributes
diff --git a/src/python_testing/TC_BOOLCFG_4_4.py b/src/python_testing/TC_BOOLCFG_4_4.py
index 12c350b..b60ef12 100644
--- a/src/python_testing/TC_BOOLCFG_4_4.py
+++ b/src/python_testing/TC_BOOLCFG_4_4.py
@@ -69,10 +69,11 @@
asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params,
"PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in "
- "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:<key>")
+ "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:<key>, "
+ "e.g. --hex-arg PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f")
endpoint = self.user_params.get("endpoint", 1)
- enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big')
+ enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY']
self.step(1)
attributes = Clusters.BooleanStateConfiguration.Attributes
diff --git a/src/python_testing/TC_BOOLCFG_5_1.py b/src/python_testing/TC_BOOLCFG_5_1.py
index 3d3d1b6..90868fd 100644
--- a/src/python_testing/TC_BOOLCFG_5_1.py
+++ b/src/python_testing/TC_BOOLCFG_5_1.py
@@ -64,10 +64,11 @@
asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params,
"PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in "
- "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:<key>")
+ "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:<key>, "
+ "e.g. --hex-arg PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f")
endpoint = self.user_params.get("endpoint", 1)
- enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big')
+ enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY']
self.step(1)
attributes = Clusters.BooleanStateConfiguration.Attributes
diff --git a/src/python_testing/TC_BOOLCFG_5_2.py b/src/python_testing/TC_BOOLCFG_5_2.py
index 65dd00f..6e26576 100644
--- a/src/python_testing/TC_BOOLCFG_5_2.py
+++ b/src/python_testing/TC_BOOLCFG_5_2.py
@@ -63,10 +63,11 @@
asserts.assert_true('PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY' in self.matter_test_config.global_test_params,
"PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY must be included on the command line in "
- "the --int-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:<key>")
+ "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:<key>, "
+ "e.g. --hex-arg PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f")
endpoint = self.user_params.get("endpoint", 1)
- enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY'].to_bytes(16, byteorder='big')
+ enableKey = self.matter_test_config.global_test_params['PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_KEY']
self.step(1)
attributes = Clusters.BooleanStateConfiguration.Attributes