Skip to content

Commit 845ce9b

Browse files
[ICD] Add TestEventTrigger support to the ICDManager (#32898)
* Add TestEventTrigger to the ICDManager * Update copyright year * Update init / shutdown to not modify them * Remove unnecessary import * Fix nxp build * remove unnused import * add test event trigger to the app layer * Remove TestEventTrigger from known problems linter * fix typo * fix merge conflicts * update TestICDManager inits * Fix TestCommissionManager * move enum to the impl anonymous namespace
1 parent 935c793 commit 845ce9b

File tree

15 files changed

+210
-31
lines changed

15 files changed

+210
-31
lines changed

.github/workflows/lint.yml

+38-14
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ on:
2323
workflow_dispatch:
2424

2525
concurrency:
26-
group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }}
26+
group:
27+
${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name ==
28+
'pull_request' && github.event.number) || (github.event_name ==
29+
'workflow_dispatch' && github.run_number) || github.sha }}
2730
cancel-in-progress: true
2831

2932
jobs:
@@ -43,7 +46,7 @@ jobs:
4346
- name: Checkout submodules & Bootstrap
4447
uses: ./.github/actions/checkout-submodules-and-bootstrap
4548
with:
46-
platform: linux
49+
platform: linux
4750

4851
- name: Check for orphaned gn files
4952
if: always()
@@ -103,7 +106,6 @@ jobs:
103106
--known-failure app/reporting/reporting.cpp \
104107
--known-failure app/reporting/tests/MockReportScheduler.cpp \
105108
--known-failure app/reporting/tests/MockReportScheduler.h \
106-
--known-failure app/TestEventTriggerDelegate.h \
107109
--known-failure app/util/attribute-storage.cpp \
108110
--known-failure app/util/attribute-storage.h \
109111
--known-failure app/util/attribute-storage-detail.h \
@@ -174,23 +176,28 @@ jobs:
174176
# git grep exits with 0 if it finds a match, but we want
175177
# to fail (exit nonzero) on match. And we want to exclude this file,
176178
# to avoid our grep regexp matching itself.
177-
- name: Check for use of PRI*8, which are not supported on some libcs.
179+
- name:
180+
Check for use of PRI*8, which are not supported on some libcs.
178181
if: always()
179182
run: |
180183
git grep -I -n "PRI.8" -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)third_party/lwip/repo/lwip/src/include/lwip/arch.h' && exit 1 || exit 0
181184
182185
# git grep exits with 0 if it finds a match, but we want
183186
# to fail (exit nonzero) on match. And we want to exclude this file,
184187
# to avoid our grep regexp matching itself.
185-
- name: Check for use of PRI*16, which are not supported on some libcs.
188+
- name:
189+
Check for use of PRI*16, which are not supported on some
190+
libcs.
186191
if: always()
187192
run: |
188193
git grep -I -n "PRI.16" -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)third_party/lwip/repo/lwip/src/include/lwip/arch.h' && exit 1 || exit 0
189194
190195
# git grep exits with 0 if it finds a match, but we want
191196
# to fail (exit nonzero) on match. And we want to exclude this file,
192197
# to avoid our grep regexp matching itself.
193-
- name: Check for use of PRI*64, which are not supported on some libcs.
198+
- name:
199+
Check for use of PRI*64, which are not supported on some
200+
libcs.
194201
if: always()
195202
run: |
196203
# TODO: MessageDefHelper should ideally not be excluded here.
@@ -230,22 +237,28 @@ jobs:
230237
# git grep exits with 0 if it finds a match, but we want
231238
# to fail (exit nonzero) on match. And we want to exclude this file,
232239
# to avoid our grep regexp matching itself.
233-
- name: Check for use of 0x%u and the like, which lead to misleading output.
240+
- name:
241+
Check for use of 0x%u and the like, which lead to misleading
242+
output.
234243
if: always()
235244
run: |
236245
git grep -I -n '0x%[0-9l.-]*[^0-9lxX".-]' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0
237246
238247
# git grep exits with 0 if it finds a match, but we want
239248
# to fail (exit nonzero) on match. And we want to exclude this file,
240249
# to avoid our grep regexp matching itself.
241-
- name: Check for use of '"0x" PRIu*' and the like, which lead to misleading output.
250+
- name:
251+
Check for use of '"0x" PRIu*' and the like, which lead to
252+
misleading output.
242253
if: always()
243254
run: |
244255
git grep -I -n '0x%[0-9-]*" *PRI[^xX]' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0
245256
246257
# git grep exits with 0 if it finds a match, but we want
247258
# to fail (exit nonzero) on match.
248-
- name: Check for use of NSLog instead of Matter logging in Matter framework
259+
- name:
260+
Check for use of NSLog instead of Matter logging in Matter
261+
framework
249262
if: always()
250263
run: |
251264
git grep -n 'NSLog(' -- src/darwin/Framework/CHIP && exit 1 || exit 0
@@ -254,7 +267,9 @@ jobs:
254267
# to fail (exit nonzero) on match. And we want to exclude this file,
255268
# to avoid our grep regexp matching itself, as well as excluding the files
256269
# that implement the type-safe accessors
257-
- name: Check for use of 'emberAfReadAttribute' instead of the type-safe getters
270+
- name:
271+
Check for use of 'emberAfReadAttribute' instead of the
272+
type-safe getters
258273
if: always()
259274
run: |
260275
git grep -I -n 'emberAfReadAttribute' -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)src/app/util/attribute-table.h' ':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' ':(exclude)src/app/zap-templates/templates/app/attributes/Accessors-src.zapt' ':(exclude)src/app/util/attribute-table.cpp' && exit 1 || exit 0
@@ -264,7 +279,9 @@ jobs:
264279
# to avoid our grep regexp matching itself, as well as excluding the files
265280
# that implement the type-safe accessors, attribute writing from the wire, and some
266281
# Pigweed RPC code that seems hard to update.
267-
- name: Check for use of 'emberAfWriteAttribute' instead of the type-safe setters
282+
- name:
283+
Check for use of 'emberAfWriteAttribute' instead of the
284+
type-safe setters
268285
if: always()
269286
run: |
270287
git grep -I -n 'emberAfWriteAttribute' -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' ':(exclude)src/app/zap-templates/templates/app/attributes/Accessors-src.zapt' ':(exclude)src/app/util/attribute-table.cpp' ':(exclude)examples/common/pigweed/rpc_services/Attributes.h' ':(exclude)src/app/util/attribute-table.h' ':(exclude)src/app/util/ember-compatibility-functions.cpp' && exit 1 || exit 0
@@ -278,22 +295,29 @@ jobs:
278295
# git grep exits with 0 if it finds a match, but we want
279296
# to fail (exit nonzero) on match. And we want to exclude this file,
280297
# to avoid our grep regexp matching itself.
281-
- name: Check for use of "SuccessOrExit(CHIP_ERROR_*)", which should probably be "SuccessOrExit(err = CHIP_ERROR_*)"
298+
- name:
299+
Check for use of "SuccessOrExit(CHIP_ERROR_*)", which should
300+
probably be "SuccessOrExit(err = CHIP_ERROR_*)"
282301
if: always()
283302
run: |
284303
git grep -I -n 'SuccessOrExit(CHIP_ERROR' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0
285304
286305
# git grep exits with 0 if it finds a match, but we want
287306
# to fail (exit nonzero) on match. And we want to exclude this file,
288307
# to avoid our grep regexp matching itself.
289-
- name: Check for use of "SuccessOrExit(something-without-assignment(", which should probably be "SuccessOrExit(err = something("
308+
- name:
309+
Check for use of
310+
"SuccessOrExit(something-without-assignment(", which should
311+
probably be "SuccessOrExit(err = something("
290312
if: always()
291313
run: |
292314
git grep -I -n 'SuccessOrExit([^=)]*(' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0
293315
294316
# git grep exits with 0 if it finds a match, but we want
295317
# to fail (exit nonzero) on match.
296-
- name: Check for use of "using namespace" outside of a class/function in headers.
318+
- name:
319+
Check for use of "using namespace" outside of a class/function
320+
in headers.
297321
if: always()
298322
run: |
299323
# Various platforms have `using namespace chip::Ble` in their BLEManager* headers; just exclude those for now.

.github/workflows/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ jobs:
508508
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
509509
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_5.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
510510
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test/lit-icd-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ICDM_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
511+
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test/lit-icd-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_ICDManagementCluster.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
511512
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
512513
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_IDM_1_4.py" --script-args "--hex-arg PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'
513514
scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_PWRTL_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"'

examples/lighting-app/nxp/k32w/k32w0/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ k32w0_executable("light_app") {
112112
"${chip_root}/examples/common/QRCode",
113113
"${chip_root}/examples/lighting-app/nxp/zap/",
114114
"${chip_root}/examples/providers:device_info_provider",
115+
"${chip_root}/src/app:test-event-trigger",
115116
"${chip_root}/src/lib",
116117
"${chip_root}/src/platform:syscalls_stub",
117118
"${chip_root}/third_party/mbedtls:mbedtls",

src/app/BUILD.gn

+4
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ source_set("constants") {
146146
]
147147
}
148148

149+
source_set("test-event-trigger") {
150+
sources = [ "TestEventTriggerDelegate.h" ]
151+
}
152+
149153
# interaction-model is a static-library because it currently requires global functions (app/util/...) that are stubbed in different test files that depend on the app static_library
150154
# which in tern depens on the interaction-model.
151155
# Using source_set prevents the unit test to build correctly.

src/app/icd/server/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ source_set("manager") {
8181
":notifier",
8282
":observer",
8383
"${chip_root}/src/app:subscription-info-provider",
84+
"${chip_root}/src/app:test-event-trigger",
8485
"${chip_root}/src/credentials:credentials",
8586
"${chip_root}/src/messaging",
8687
]

src/app/icd/server/ICDManager.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
#include <platform/internal/CHIPDeviceLayerInternal.h>
2929
#include <stdlib.h>
3030

31+
namespace {
32+
enum class ICDTestEventTriggerEvent : uint64_t
33+
{
34+
kAddActiveModeReq = 0x0046'0000'00000001,
35+
kRemoveActiveModeReq = 0x0046'0000'00000002,
36+
};
37+
} // namespace
38+
3139
namespace chip {
3240
namespace app {
3341

@@ -643,6 +651,27 @@ void ICDManager::ExtendActiveMode(Milliseconds16 extendDuration)
643651
}
644652
}
645653

654+
CHIP_ERROR ICDManager::HandleEventTrigger(uint64_t eventTrigger)
655+
{
656+
ICDTestEventTriggerEvent trigger = static_cast<ICDTestEventTriggerEvent>(eventTrigger);
657+
CHIP_ERROR err = CHIP_NO_ERROR;
658+
659+
switch (trigger)
660+
{
661+
case ICDTestEventTriggerEvent::kAddActiveModeReq:
662+
SetKeepActiveModeRequirements(KeepActiveFlag::kTestEventTriggerActiveMode, true);
663+
break;
664+
case ICDTestEventTriggerEvent::kRemoveActiveModeReq:
665+
SetKeepActiveModeRequirements(KeepActiveFlag::kTestEventTriggerActiveMode, false);
666+
break;
667+
default:
668+
err = CHIP_ERROR_INVALID_ARGUMENT;
669+
break;
670+
}
671+
672+
return err;
673+
}
674+
646675
ICDManager::ObserverPointer * ICDManager::RegisterObserver(ICDStateObserver * observer)
647676
{
648677
return mStateObserverPool.CreateObject(observer);

src/app/icd/server/ICDManager.h

+19-10
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@
1616
*/
1717
#pragma once
1818

19-
#include <app-common/zap-generated/cluster-enums.h>
20-
2119
#include <app/icd/server/ICDServerConfig.h>
2220

23-
#if CHIP_CONFIG_ENABLE_ICD_CIP
24-
#include <app/icd/server/ICDCheckInSender.h> // nogncheck
25-
#include <app/icd/server/ICDMonitoringTable.h> // nogncheck
26-
#endif // CHIP_CONFIG_ENABLE_ICD_CIP
27-
21+
#include <app-common/zap-generated/cluster-enums.h>
2822
#include <app/SubscriptionsInfoProvider.h>
23+
#include <app/TestEventTriggerDelegate.h>
2924
#include <app/icd/server/ICDConfigurationData.h>
3025
#include <app/icd/server/ICDNotifier.h>
3126
#include <app/icd/server/ICDStateObserver.h>
@@ -38,6 +33,11 @@
3833
#include <platform/internal/CHIPDeviceLayerInternal.h>
3934
#include <system/SystemClock.h>
4035

36+
#if CHIP_CONFIG_ENABLE_ICD_CIP
37+
#include <app/icd/server/ICDCheckInSender.h> // nogncheck
38+
#include <app/icd/server/ICDMonitoringTable.h> // nogncheck
39+
#endif // CHIP_CONFIG_ENABLE_ICD_CIP
40+
4141
namespace chip {
4242
namespace Crypto {
4343
using SymmetricKeystore = SessionKeystore;
@@ -54,7 +54,7 @@ class TestICDManager;
5454
/**
5555
* @brief ICD Manager is responsible of processing the events and triggering the correct action for an ICD
5656
*/
57-
class ICDManager : public ICDListener
57+
class ICDManager : public ICDListener, public TestEventTriggerHandler
5858
{
5959
public:
6060
// This structure is used for the creation an ObjectPool of ICDStateObserver pointers
@@ -129,6 +129,15 @@ class ICDManager : public ICDListener
129129
*/
130130
uint32_t StayActiveRequest(uint32_t stayActiveDuration);
131131

132+
/**
133+
* @brief TestEventTriggerHandler for the ICD feature set
134+
*
135+
* @param eventTrigger Event trigger to handle.
136+
* @return CHIP_ERROR CHIP_NO_ERROR - No erros during the processing
137+
* CHIP_ERROR_INVALID_ARGUMENT - eventTrigger isn't a valid value
138+
*/
139+
CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override;
140+
132141
#if CHIP_CONFIG_ENABLE_ICD_CIP
133142
void SendCheckInMsgs();
134143

@@ -165,14 +174,14 @@ class ICDManager : public ICDListener
165174
void OnSubscriptionReport() override;
166175

167176
protected:
177+
friend class TestICDManager;
178+
168179
/**
169180
* @brief Hepler function that extends the Active Mode duration as well as the Active Mode Jitter timer for the transition to
170181
* iddle mode.
171182
*/
172183
void ExtendActiveMode(System::Clock::Milliseconds16 extendDuration);
173184

174-
friend class TestICDManager;
175-
176185
static void OnIdleModeDone(System::Layer * aLayer, void * appState);
177186
static void OnActiveModeDone(System::Layer * aLayer, void * appState);
178187

src/app/icd/server/ICDNotifier.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ class ICDListener
3939
public:
4040
enum class KeepActiveFlagsValues : uint8_t
4141
{
42-
kCommissioningWindowOpen = 0x01,
43-
kFailSafeArmed = 0x02,
44-
kExchangeContextOpen = 0x04,
45-
kCheckInInProgress = 0x08,
46-
kInvalidFlag = 0x10, // Move up when adding more flags
42+
kCommissioningWindowOpen = 0x01,
43+
kFailSafeArmed = 0x02,
44+
kExchangeContextOpen = 0x04,
45+
kCheckInInProgress = 0x08,
46+
kTestEventTriggerActiveMode = 0x10,
47+
kInvalidFlag = 0x20, // Move up when adding more flags
4748
};
4849

4950
enum class ICDManagementEvents : uint8_t

src/app/server/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static_library("server") {
5252

5353
public_deps = [
5454
"${chip_root}/src/app",
55+
"${chip_root}/src/app:test-event-trigger",
5556
"${chip_root}/src/app/icd/server:icd-server-config",
5657
"${chip_root}/src/app/icd/server:observer",
5758
"${chip_root}/src/lib/address_resolve",

src/app/server/Server.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
348348

349349
mICDManager.Init(mDeviceStorage, &GetFabricTable(), mSessionKeystore, &mExchangeMgr,
350350
chip::app::InteractionModelEngine::GetInstance());
351+
352+
// Register Test Event Trigger Handler
353+
mTestEventTriggerDelegate->AddHandler(&mICDManager);
354+
351355
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
352356

353357
// This code is necessary to restart listening to existing groups after a reboot
@@ -592,6 +596,8 @@ void Server::Shutdown()
592596
Access::ResetAccessControlToDefault();
593597
Credentials::SetGroupDataProvider(nullptr);
594598
#if CHIP_CONFIG_ENABLE_ICD_SERVER
599+
// Remove Test Event Trigger Handler
600+
mTestEventTriggerDelegate->RemoveHandler(&mICDManager);
595601
mICDManager.Shutdown();
596602
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
597603
mAttributePersister.Shutdown();

0 commit comments

Comments
 (0)