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 36716ec69ce52e..fe2ec9050683e8 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 +#include #include #include 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 4b1e883a6b7d17..88c85f71fc3687 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 +#include #include #include diff --git a/examples/all-clusters-app/ameba/main/SmokeCOAlarmManager.cpp b/examples/all-clusters-app/ameba/main/SmokeCOAlarmManager.cpp index bede2bcf537a76..027bb055cca44f 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 +#include #include using namespace chip; diff --git a/examples/all-clusters-app/ameba/main/chipinterface.cpp b/examples/all-clusters-app/ameba/main/chipinterface.cpp index 21280c676154be..20de9cd1ff0124 100644 --- a/examples/all-clusters-app/ameba/main/chipinterface.cpp +++ b/examples/all-clusters-app/ameba/main/chipinterface.cpp @@ -140,8 +140,10 @@ static void InitServer(intptr_t context) 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 390ee679d0d255..af6177299a3948 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 #include -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 9f471943406c80..f8d117790fac3d 100644 --- a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp @@ -27,8 +27,9 @@ #include #include +#include #include -#include +#include #include #include @@ -204,9 +205,12 @@ CHIP_ERROR AppTask::Init() #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 70cd63e7926c8d..0f204671a9feca 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 #include -#include +#include #include -#include +#include 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 d316dd807c13e2..424ef46d58e259 100644 --- a/examples/energy-management-app/linux/README.md +++ b/examples/energy-management-app/linux/README.md @@ -366,7 +366,7 @@ If you haven't implemented a real EVSE but want to simulate plugging in an EV 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 dbfdb81b875b3f..483a475b51cee0 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 #endif +#include #include -#include +#include #include #include #include @@ -192,10 +193,13 @@ void InitApp(intptr_t args) // 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 a4b5ac5b47b318..06ac797f6a6899 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 +#include #include -#include +#include #include #include #include @@ -215,9 +216,12 @@ CHIP_ERROR AppTask::Init() #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 659f2d4ab1efd3..055cfd46f95abb 100644 --- a/examples/light-switch-app/qpg/BUILD.gn +++ b/examples/light-switch-app/qpg/BUILD.gn @@ -51,7 +51,7 @@ qpg_executable("light_switch_app") { 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 9f6662206f2e74..f02823b178220d 100644 --- a/examples/light-switch-app/qpg/src/AppTask.cpp +++ b/examples/light-switch-app/qpg/src/AppTask.cpp @@ -31,7 +31,8 @@ using namespace ::chip; #include -#include +#include +#include #include #include #include @@ -191,10 +192,13 @@ void AppTask::InitServer(intptr_t arg) nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); initParams.endpointNativeParams = static_cast(&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 14730252de08b3..f851e2e8819664 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 #endif +#include #include -#include +#include #include #include #include @@ -191,10 +192,13 @@ void InitApp(intptr_t args) // 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 03632106fc8667..494095e04de9dc 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -27,8 +27,9 @@ #include #include #include +#include #include -#include +#include #include #include #include @@ -243,9 +244,12 @@ CHIP_ERROR AppTask::Init() #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 557293f6bac2aa..b1fc51c7c29360 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 @@ void AppTask::InitServer(intptr_t arg) 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 66eee725c581c2..7150003f599588 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 @@ void AppTask::InitServer(intptr_t arg) #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 d8f86311d627eb..c835e0bf3cdaed 100644 --- a/examples/lighting-app/qpg/BUILD.gn +++ b/examples/lighting-app/qpg/BUILD.gn @@ -51,7 +51,7 @@ qpg_executable("lighting_app") { 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 1dd1aa85514a7a..4dafde6ac41960 100644 --- a/examples/lighting-app/qpg/src/AppTask.cpp +++ b/examples/lighting-app/qpg/src/AppTask.cpp @@ -33,7 +33,8 @@ #include #include -#include +#include +#include #include #include #include @@ -264,10 +265,13 @@ void AppTask::InitServer(intptr_t arg) nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); initParams.endpointNativeParams = static_cast(&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 76fa8484ce74eb..a0a92487a807bc 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 #endif +#include #include #include -#include +#include #include #include #include @@ -191,10 +192,13 @@ void InitApp(intptr_t args) // 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 d64a4950ace777..07a96b6d6c29b2 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -25,9 +25,10 @@ #include #include +#include #include #include -#include +#include #include #include #include @@ -209,9 +210,12 @@ CHIP_ERROR AppTask::Init() #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 2426fa7c3179d5..30794878fd1ae8 100644 --- a/examples/lock-app/qpg/BUILD.gn +++ b/examples/lock-app/qpg/BUILD.gn @@ -51,7 +51,7 @@ qpg_executable("lock_app") { 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 8bbd6b7ce19a8a..54a4b2a5d2a3f3 100644 --- a/examples/lock-app/qpg/src/AppTask.cpp +++ b/examples/lock-app/qpg/src/AppTask.cpp @@ -26,7 +26,8 @@ #include #include -#include +#include +#include #include #include #include @@ -189,10 +190,13 @@ void AppTask::InitServer(intptr_t arg) nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); initParams.endpointNativeParams = static_cast(&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 9cfddd6f3de9fa..8bbae5e1978097 100644 --- a/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp +++ b/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.cpp @@ -28,10 +28,4 @@ bool AmebaTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKe 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 d461194de9b642..9e770406303645 100644 --- a/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.h +++ b/examples/platform/ameba/test_event_trigger/AmebaTestEventTriggerDelegate.h @@ -18,15 +18,38 @@ #pragma once -#include "SmokeCOAlarmManager.h" +#include + #include +#include +#include +#include + +/** + * @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 AmebaTestEventTriggerDelegate : public TestEventTriggerDelegate +class AmebaTestEventTriggerDelegate : public TestEventTriggerDelegate, TestEventTriggerHandler { public: - explicit AmebaTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {} + 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. @@ -35,27 +58,14 @@ class AmebaTestEventTriggerDelegate : public TestEventTriggerDelegate */ 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; + 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/platform/esp32/common/Esp32AppServer.cpp b/examples/platform/esp32/common/Esp32AppServer.cpp index fee87880d2d9e1..b60685d34debca 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 +#include #include -#include +#include #include #include #include @@ -169,8 +170,11 @@ void Esp32AppServer::Init(AppDelegate * sAppDelegate) 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 04274ab2f33c24..061d7b66c5e4c6 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 +#include #endif #if CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER -#include +#include #endif #if CHIP_DEVICE_CONFIG_ENABLE_BOOLEAN_STATE_CONFIGURATION_TRIGGER -#include +#include #endif #if CHIP_DEVICE_CONFIG_ENABLE_ENERGY_EVSE_TRIGGER -#include +#include #endif #if CHIP_DEVICE_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER -#include +#include #endif #include @@ -331,34 +331,13 @@ static bool EnsureWiFiIsStarted() } #endif -class SampleTestEventTriggerDelegate : public TestEventTriggerDelegate +class SampleTestEventTriggerHandler : public TestEventTriggerHandler { -public: - /// NOTE: If you copy this, please use the reserved range FFFF_FFFF__xxxx for your trigger codes. + /// NOTE: If you copy this for NON-STANDARD CLUSTERS OR USAGES, please use the reserved range FFFF_FFFF__xxxx for your + /// trigger codes. NOTE: Standard codes are _xxxx_xxxx_xxxx. static constexpr uint64_t kSampleTestEventTriggerAlwaysSuccess = static_cast(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 @@ class SampleTestEventTriggerDelegate : public TestEventTriggerDelegate 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 @@ void ChipLinuxAppMainLoop(AppMainLoopImplementation * impl) 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 f82702be227709..8cf00c5be5e62c 100644 --- a/examples/platform/linux/BUILD.gn +++ b/examples/platform/linux/BUILD.gn @@ -32,24 +32,24 @@ config("app-main-config") { 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 2c04b81b0ce8bb..bd13e249683fcb 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 +#include +#include #endif #include @@ -315,9 +316,12 @@ void ChipLinuxAppMainLoop(AppMainLoopImplementation * impl) } #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 2a93a4bf085a3e..a5efe460745ddd 100644 --- a/examples/platform/nxp/se05x/linux/BUILD.gn +++ b/examples/platform/nxp/se05x/linux/BUILD.gn @@ -25,7 +25,7 @@ config("app-main-config") { 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 1197e4d48cd83b..3a78cf774c8c5a 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -219,8 +219,9 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) 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 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) #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 f231067cec851b..f9a11df74d7ae9 100644 --- a/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp +++ b/examples/platform/silabs/SilabsTestEventTriggerDelegate.cpp @@ -27,10 +27,4 @@ bool SilabsTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableK 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 e9cd62fb813e50..e08e972f690f67 100644 --- a/examples/platform/silabs/SilabsTestEventTriggerDelegate.h +++ b/examples/platform/silabs/SilabsTestEventTriggerDelegate.h @@ -18,14 +18,38 @@ #pragma once +#include + #include +#include +#include +#include + +/** + * @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 @@ class SilabsTestEventTriggerDelegate : public TestEventTriggerDelegate 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 5524b770c0585a..7b07561c2caf98 100644 --- a/examples/providers/DeviceInfoProviderImpl.cpp +++ b/examples/providers/DeviceInfoProviderImpl.cpp @@ -100,8 +100,8 @@ bool DeviceInfoProviderImpl::FixedLabelIteratorImpl::Next(FixedLabelType & outpu 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 fa38eba254853a..329c8d95f64beb 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -25,7 +25,8 @@ #include #include -#include +#include +#include #include #include #include @@ -186,9 +187,12 @@ CHIP_ERROR AppTask::Init() #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 db96480e5acb9d..ca79a41160a9d2 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -25,7 +25,8 @@ #include #include -#include +#include +#include #include #include #include @@ -184,9 +185,12 @@ CHIP_ERROR AppTask::Init() #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 85c8bca2193a67..7d64a036371a6f 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 -#include +#include #include using namespace chip; diff --git a/examples/thermostat/qpg/BUILD.gn b/examples/thermostat/qpg/BUILD.gn index d4285571114721..9989e349fc6c86 100644 --- a/examples/thermostat/qpg/BUILD.gn +++ b/examples/thermostat/qpg/BUILD.gn @@ -51,7 +51,7 @@ qpg_executable("thermostat") { 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 f607114da6d031..7c50aedc97e2bb 100644 --- a/examples/window-app/nrfconnect/main/AppTask.cpp +++ b/examples/window-app/nrfconnect/main/AppTask.cpp @@ -24,8 +24,9 @@ #include +#include #include -#include +#include #include #include #include @@ -188,9 +189,12 @@ CHIP_ERROR AppTask::Init() #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 5f72415d021104..33869d8c0903bd 100644 --- a/src/app/TestEventTriggerDelegate.h +++ b/src/app/TestEventTriggerDelegate.h @@ -18,12 +18,27 @@ #pragma once #include +#include #include #include #include namespace chip { +class TestEventTriggerHandler : public IntrusiveListNodeBase +{ +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 @@ class TestEventTriggerDelegate 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 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 6404eb306d2c45..09d11860c7fed5 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -255,8 +255,8 @@ template("chip_data_model") { "${_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 @@ template("chip_data_model") { 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 @@ template("chip_data_model") { 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 @@ template("chip_data_model") { 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 00a42592929671..b2ffe7a1606dbe 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 43b68e284497e0..92aa2e8a86abec 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 @@ enum class BooleanStateConfigurationTrigger : uint64_t 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 210ab401bc2221..00000000000000 --- 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 a7beef6c2838ce..d254d7a2db697d 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 #include +/** + * @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 @@ enum class EnergyReportingTrigger : uint64_t }; -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) - {} - - /* 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; + EnergyReportingTestEventTriggerHandler() {} - /** 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 78fb87085f3b10..00000000000000 --- 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 3c1dff4f5e7f81..307156e21f1197 100644 --- a/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerDelegate.h +++ b/src/app/clusters/energy-evse-server/EnergyEvseTestEventTriggerHandler.h @@ -20,6 +20,18 @@ #include #include +/** + * @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 @@ enum class EnergyEvseTrigger : uint64_t 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.cpp b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp similarity index 90% rename from src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.cpp rename to src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.cpp index 6c50b581e397d7..b733524839d583 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 #include @@ -25,15 +25,10 @@ using namespace ::chip::DeviceLayer; 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 hwFaultsPrevious; diff --git a/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h similarity index 65% rename from src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h rename to src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h index f304518c38fd75..4dea743eec1c94 100644 --- a/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerDelegate.h +++ b/src/app/clusters/general-diagnostics-server/GenericFaultTestEventTriggerHandler.h @@ -22,19 +22,12 @@ namespace chip { -class GenericFaultTestEventTriggerDelegate : public TestEventTriggerDelegate +class GenericFaultTestEventTriggerHandler : public TestEventTriggerHandler { public: - static constexpr uint64_t kGenericFaultQueryTrigger = 0xFFFF'FFFF'10D0'0001; - static constexpr uint64_t kGenericFaultQueryFabricIndexMask = 0xff; + static constexpr uint64_t kGenericFaultQueryTrigger = 0x3333'FFFF'10D0'0001; - 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/general-diagnostics-server.cpp b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp index c0130e9cd0068a..c392c963dc5bdd 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 @@ bool emberAfGeneralDiagnosticsClusterTestEventTriggerCallback(CommandHandler * c 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 a879f817ed9b86..885aced7fe9ee2 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 6c78a16a7665ff..bb49a3d23dc739 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 597737b14bb768..00000000000000 --- 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 599eb6ab2fc080..00000000000000 --- 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 -#include - -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 00000000000000..a64ab5fc5d5aa7 --- /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 +#include + +/** + * @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 d0f9a73178ccb0..9a21f1f4589d81 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -153,6 +153,7 @@ chip_test_suite_using_nltest("tests") { "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 00000000000000..cd7f3ae9cd7be3 --- /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 + +#include +#include +#include +#include + +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 37b3eb074031ac..4d26172d49d5c6 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 @@ config: 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 c9de09f10e4314..21aa0d7481c7c5 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 @@ config: 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 00ecd8b85a63b2..288933602dc872 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 @@ config: 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 8bd0afb0daf71d..961113e8d1ee6b 100644 --- a/src/lib/support/IntrusiveList.h +++ b/src/lib/support/IntrusiveList.h @@ -439,6 +439,14 @@ class IntrusiveList : public IntrusiveListBase 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 afe7a1c07f548a..0d1779b00ac987 100644 --- a/src/lib/support/tests/TestIntrusiveList.cpp +++ b/src/lib/support/tests/TestIntrusiveList.cpp @@ -131,6 +131,35 @@ void TestContains(nlTestSuite * inSuite, void * inContext) list.Remove(&b); } +void TestClear(nlTestSuite * inSuite, void * inContext) +{ + ListNode a, b, c; + IntrusiveList 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 @@ static const nlTest sTests[] = { 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 1a01acfdb69385..69935bb024559d 100644 --- a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp +++ b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp @@ -28,15 +28,4 @@ bool DefaultTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enable 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 cf71fb37d96470..0bfd4c5b0fa725 100644 --- a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h +++ b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h @@ -25,12 +25,9 @@ namespace chip { 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 1a01acfdb69385..69935bb024559d 100644 --- a/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.cpp +++ b/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.cpp @@ -28,15 +28,4 @@ bool DefaultTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enable 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 cf71fb37d96470..0bfd4c5b0fa725 100644 --- a/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.h +++ b/src/platform/nxp/k32w/k32w1/DefaultTestEventTriggerDelegate.h @@ -25,12 +25,9 @@ namespace chip { 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 06f5ecad6adbad..c0a74a9c46538a 100644 --- a/src/python_testing/TC_BOOLCFG_4_2.py +++ b/src/python_testing/TC_BOOLCFG_4_2.py @@ -65,10 +65,11 @@ async def test_TC_BOOLCFG_4_2(self): 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:") + "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_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 40a44a004a67e5..90106efc2b8ab4 100644 --- a/src/python_testing/TC_BOOLCFG_4_3.py +++ b/src/python_testing/TC_BOOLCFG_4_3.py @@ -77,10 +77,11 @@ async def test_TC_BOOLCFG_4_3(self): 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:") + "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_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 12c350baedbc40..b60ef12fd16f5f 100644 --- a/src/python_testing/TC_BOOLCFG_4_4.py +++ b/src/python_testing/TC_BOOLCFG_4_4.py @@ -69,10 +69,11 @@ async def test_TC_BOOLCFG_4_4(self): 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:") + "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_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 3d3d1b681752c9..90868fd8e6316c 100644 --- a/src/python_testing/TC_BOOLCFG_5_1.py +++ b/src/python_testing/TC_BOOLCFG_5_1.py @@ -64,10 +64,11 @@ async def test_TC_BOOLCFG_5_1(self): 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:") + "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_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 65dd00f7d690e2..6e2657698a9d5c 100644 --- a/src/python_testing/TC_BOOLCFG_5_2.py +++ b/src/python_testing/TC_BOOLCFG_5_2.py @@ -63,10 +63,11 @@ async def test_TC_BOOLCFG_5_2(self): 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:") + "the --hex-arg flag as PIXIT.BOOLCFG.TEST_EVENT_TRIGGER_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