From 1293456fa1025b445e4c9123f0220f3c8b42bcf4 Mon Sep 17 00:00:00 2001 From: AlvinHsiao Date: Sat, 1 Oct 2022 05:12:11 +0800 Subject: [PATCH] [Infineon] Implement TestEventTrigger delegate for OTA query (#22749) * Make it possible to use TestEventTrigger command of GeneralDiagnostics cluster to trigger OTA query on demand. * Use OTATestEventTriggerDelegate in CYW30739 example. --- examples/lighting-app/infineon/cyw30739/src/main.cpp | 8 ++++++++ examples/lock-app/infineon/cyw30739/src/main.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/examples/lighting-app/infineon/cyw30739/src/main.cpp b/examples/lighting-app/infineon/cyw30739/src/main.cpp index 136af11cb04fa7..639ca07595c304 100644 --- a/examples/lighting-app/infineon/cyw30739/src/main.cpp +++ b/examples/lighting-app/infineon/cyw30739/src/main.cpp @@ -27,6 +27,7 @@ #include #endif #include +#include #include #include #include @@ -54,6 +55,11 @@ static wiced_led_config_t chip_lighting_led_config = { .bright = 50, }; +// NOTE! This key is for test/certification only and should not be available in production devices! +uint8_t sTestEventTriggerEnableKey[chip::TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, + 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, + 0xcc, 0xdd, 0xee, 0xff }; + /********************************************************** * Identify Callbacks *********************************************************/ @@ -177,8 +183,10 @@ 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::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); + initParams.testEventTriggerDelegate = &testEventTriggerDelegate; gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; diff --git a/examples/lock-app/infineon/cyw30739/src/main.cpp b/examples/lock-app/infineon/cyw30739/src/main.cpp index d72d154e7c3a10..2f8bd88eeff599 100644 --- a/examples/lock-app/infineon/cyw30739/src/main.cpp +++ b/examples/lock-app/infineon/cyw30739/src/main.cpp @@ -30,6 +30,7 @@ #endif #include #include +#include #include #include #include @@ -69,6 +70,11 @@ static void UpdateClusterState(intptr_t context); #define _countof(a) (sizeof(a) / sizeof(a[0])) #endif +// NOTE! This key is for test/certification only and should not be available in production devices! +uint8_t sTestEventTriggerEnableKey[chip::TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, + 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, + 0xcc, 0xdd, 0xee, 0xff }; + static wiced_led_config_t chip_lighting_led_config[2] = { { .led = PLATFORM_LED_1, @@ -174,8 +180,10 @@ 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::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); + initParams.testEventTriggerDelegate = &testEventTriggerDelegate; gExampleDeviceInfoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams;