Skip to content

Commit 083803c

Browse files
authored
feat: Add terms-and-conditions sample app for CI testing (#36950)
* feat: Add terms-and-conditions sample app for CI testing Add a new sample application that demonstrates and tests the terms and conditions feature. This app will be integrated into the CI pipeline to prevent regressions and ensure the feature continues to work as expected. The sample app serves as both a reference implementation and an automated test case for the terms and conditions functionality. ```bash ./scripts/build/build_examples.py --target linux-x64-terms-and-conditions build ``` * Update cluster configurations for app testing - Enable switch cluster for basic app control testing - Enable network commissioning cluster for in-app commission testing - Disable provisional clusters as they are not required - Disable other non-required clusters to streamline testing setup This change focuses the cluster configuration on essential components needed for basic app control and commissioning testing scenarios. * refactor: Remove unused attributes from Switch cluster Remove unused attributes from the Switch cluster to comply with the "On/Off Light" device type specification as defined in the Matter device library v1.4. This change removes several server-side attributes including ServerList, ClientList, PartsList, and various internal lists that are not required for the basic On/Off Light functionality. * feat: Add Descriptor cluster and enable attribute reporting Add the mandatory Descriptor cluster to endpoint 1 and enable attribute reporting for the device. Changes include: - Add Descriptor cluster with all required attributes (deviceTypeList, serverList, etc.) - Enable reportable flag for multiple attributes with min/max reporting intervals - Configure all Descriptor cluster attributes as external callbacks This change ensures compliance with the Matter specification for the On/Off Light device type.
1 parent 72b1da7 commit 083803c

File tree

14 files changed

+4443
-2
lines changed

14 files changed

+4443
-2
lines changed

docs/issue_triage.md

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ types or functionality) as well as individual examples.
137137
| `examples/rvc-app` | | UNMAINTAINED |
138138
| `examples/smoke-co-alarm-app` | | UNMAINTAINED |
139139
| `examples/temperature-measurement-app` | | UNMAINTAINED |
140+
| `examples/terms-and-conditions-app` | James Swan | |
140141
| `examples/thermostat` | | UNMAINTAINED |
141142
| `examples/thread-br-app` | | UNMAINTAINED |
142143
| `examples/tv-app` | Chris DeCenzo, Lazar Kovacic | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
17+
# The location of the build configuration file.
18+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
19+
20+
# CHIP uses angle bracket includes.
21+
check_system_includes = true
22+
23+
default_args = {
24+
import("//args.gni")
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/chip.gni")
16+
import("${chip_root}/build/chip/tools.gni")
17+
import("${chip_root}/src/app/common_flags.gni")
18+
19+
executable("chip-terms-and-conditions-app") {
20+
sources = [ "main.cpp" ]
21+
22+
deps = [
23+
"${chip_root}/examples/platform/linux:app-main",
24+
"${chip_root}/examples/terms-and-conditions-app/terms-and-conditions-common",
25+
]
26+
27+
output_dir = root_out_dir
28+
}
29+
30+
group("default") {
31+
deps = [ ":chip-terms-and-conditions-app" ]
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/chip.gni")
16+
import("${chip_root}/config/standalone/args.gni")
17+
18+
chip_terms_and_conditions_required = true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../build_overrides
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include <AppMain.h>
20+
#include <app/server/TermsAndConditionsManager.h>
21+
#include <app/server/TermsAndConditionsProvider.h>
22+
23+
using namespace chip;
24+
using namespace chip::ArgParser;
25+
26+
static uint16_t sTcMinRequiredVersion = 0;
27+
static uint16_t sTcRequiredAcknowledgements = 0;
28+
29+
static OptionDef sTermsAndConditionsOptions[] = {
30+
{ "tc-min-required-version", kArgumentRequired, 'm' },
31+
{ "tc-required-acknowledgements", kArgumentRequired, 'r' },
32+
{ nullptr },
33+
};
34+
35+
static const char * const sTermsAndConditionsOptionHelp =
36+
"-m, --tc-min-required-version <number>\n Configure the minimum required TC version.\n\n"
37+
"-r, --tc-required-acknowledgements <number (bitfield)>\n Configure the required TC acknowledgements.\n\n";
38+
39+
static bool HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg)
40+
{
41+
switch (id)
42+
{
43+
case 'm':
44+
sTcMinRequiredVersion = static_cast<uint16_t>(atoi(arg));
45+
break;
46+
case 'r':
47+
sTcRequiredAcknowledgements = static_cast<uint16_t>(atoi(arg));
48+
break;
49+
default:
50+
PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", progName, name);
51+
return false;
52+
}
53+
54+
return true;
55+
}
56+
57+
static OptionSet sTermsAndConditionsCmdLineOptions = {
58+
HandleOption,
59+
sTermsAndConditionsOptions,
60+
"TERMS AND CONDITIONS OPTIONS",
61+
sTermsAndConditionsOptionHelp,
62+
};
63+
64+
void ApplicationInit()
65+
{
66+
const app::TermsAndConditions termsAndConditions = app::TermsAndConditions(sTcRequiredAcknowledgements, sTcMinRequiredVersion);
67+
PersistentStorageDelegate & persistentStorageDelegate = Server::GetInstance().GetPersistentStorage();
68+
app::TermsAndConditionsManager::GetInstance()->Init(&persistentStorageDelegate, MakeOptional(termsAndConditions));
69+
}
70+
71+
void ApplicationShutdown() {}
72+
73+
int main(int argc, char * argv[])
74+
{
75+
if (ChipLinuxAppInit(argc, argv, &sTermsAndConditionsCmdLineOptions) != 0)
76+
{
77+
return -1;
78+
}
79+
80+
ChipLinuxAppMainLoop();
81+
return 0;
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/chip.gni")
16+
17+
import("${chip_root}/src/app/chip_data_model.gni")
18+
19+
chip_data_model("terms-and-conditions-common") {
20+
zap_file = "terms-and-conditions-app.zap"
21+
is_server = true
22+
}

0 commit comments

Comments
 (0)