Skip to content

Commit 4036819

Browse files
mideayanghuirestyled-commits
authored andcommitted
[Feature]add refrigerator example (#28390)
* Add refrigerator example build script * Add refrigerator app * Restyled by whitespace * Restyled by gn * Restyled by prettier-markdown * fix document missing * Restyled by prettier-markdown * fix document build error * update zap and matter with #28299 * optimize code and add composition type for endpoint * Restyled by clang-format * Optimize endpoint 1: 1. remove Refrigerator And Temperature Controlled Cabinet Mode cluster 2. remove Refrigerator alarm cluster 3. remove Binding and Group cluster in endpoint 1 * Restyled by clang-format * fix build error * fix bug: test fail in TC-SM-1.1/TC-DT-1.1 * remove identify and groups cluster in root node * add tag list feauture in endpoint 2 and endpoint 3 * Restyled by clang-format --------- Co-authored-by: Restyled.io <[email protected]>
1 parent bf6d463 commit 4036819

31 files changed

+15309
-2
lines changed

docs/examples/index.md

+9
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,15 @@ pump-controller-app/**/README
201201
pump-controller-app/cc13x2x7_26x2x7/doc/programming*
202202
```
203203

204+
## Refrigerator example
205+
206+
```{toctree}
207+
:glob:
208+
:maxdepth: 1
209+
210+
refrigerator-app/**/README
211+
```
212+
204213
## Shell example
205214

206215
```{toctree}

examples/refrigerator-app/asr/.gn

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) 2023 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+
target_cpu = "arm"
25+
26+
target_os = "freertos"
27+
28+
import("//args.gni")
29+
}
+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Copyright (c) 2023 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/asr.gni")
16+
import("//build_overrides/build.gni")
17+
import("//build_overrides/chip.gni")
18+
import("${asr_sdk_build_root}/asr_sdk.gni")
19+
import("${build_root}/config/defaults.gni")
20+
import("${chip_root}/src/lib/lib.gni")
21+
import("${chip_root}/src/platform/device.gni")
22+
import("${chip_root}/third_party/asr/asr_executable.gni")
23+
24+
import("cfg.gni")
25+
26+
assert(current_os == "freertos")
27+
28+
asr_project_dir = "${chip_root}/examples/refrigerator-app/asr"
29+
examples_plat_dir = "${chip_root}/examples/platform/asr"
30+
31+
declare_args() {
32+
# Dump memory usage at link time.
33+
chip_print_memory_usage = false
34+
}
35+
36+
asr_sdk_sources("refrigerator_app_sdk_sources") {
37+
include_dirs = [
38+
"${chip_root}/src/platform/ASR",
39+
"${asr_project_dir}/include",
40+
"${examples_plat_dir}",
41+
]
42+
43+
defines = [
44+
"ASR_LOG_ENABLED=1",
45+
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
46+
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}",
47+
]
48+
49+
if (chip_enable_factory_data) {
50+
defines += [
51+
"CONFIG_ENABLE_ASR_FACTORY_DATA_PROVIDER=1",
52+
"CONFIG_ENABLE_ASR_FACTORY_DEVICE_INFO_PROVIDER=1",
53+
]
54+
}
55+
56+
if (chip_lwip_ip6_hook) {
57+
defines += [
58+
"CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT",
59+
"CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT",
60+
]
61+
}
62+
63+
sources = [ "${asr_project_dir}/include/CHIPProjectConfig.h" ]
64+
65+
public_configs = [ "${asr_sdk_build_root}:asr_sdk_config" ]
66+
}
67+
68+
asr_executable("refrigerator_app") {
69+
include_dirs = []
70+
defines = []
71+
output_name = "chip-asr-refrigerator-example.out"
72+
73+
sources = [
74+
"${chip_root}/examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp",
75+
"${examples_plat_dir}/CHIPDeviceManager.cpp",
76+
"${examples_plat_dir}/init_Matter.cpp",
77+
"${examples_plat_dir}/init_asrPlatform.cpp",
78+
"${examples_plat_dir}/shell/matter_shell.cpp",
79+
"src/AppTask.cpp",
80+
"src/DeviceCallbacks.cpp",
81+
"src/main.cpp",
82+
]
83+
84+
if (chip_enable_ota_requestor) {
85+
sources += [ "${examples_plat_dir}/init_OTARequestor.cpp" ]
86+
}
87+
88+
deps = [
89+
":refrigerator_app_sdk_sources",
90+
"${chip_root}/examples/common/QRCode",
91+
"${chip_root}/examples/providers:device_info_provider",
92+
"${chip_root}/examples/refrigerator-app/refrigerator-common",
93+
"${chip_root}/src/lib",
94+
"${chip_root}/src/setup_payload",
95+
]
96+
97+
include_dirs += [
98+
"include",
99+
"${examples_plat_dir}",
100+
"${asr_project_dir}/include",
101+
"${chip_root}/src/lib",
102+
"${chip_root}/examples/refrigerator-app/refrigerator-common/include",
103+
]
104+
105+
defines = [ "ASR_NETWORK_LAYER_BLE=${chip_config_network_layer_ble}" ]
106+
107+
if (chip_build_libshell) {
108+
defines += [ "CONFIG_ENABLE_CHIP_SHELL=1" ]
109+
sources += [ "${examples_plat_dir}/shell/launch_shell.cpp" ]
110+
include_dirs += [ "${examples_plat_dir}/shell" ]
111+
}
112+
113+
if (chip_print_memory_usage) {
114+
ldflags += [
115+
"-Wl,--print-memory-usage",
116+
"-fstack-usage",
117+
]
118+
}
119+
120+
output_dir = root_out_dir
121+
}
122+
123+
group("asr") {
124+
deps = [ ":refrigerator_app" ]
125+
}
126+
127+
group("default") {
128+
deps = [ ":asr" ]
129+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright (c) 2023 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("//build_overrides/pigweed.gni")
17+
import("//cfg.gni")
18+
import("${chip_root}/src/platform/ASR/args.gni")
19+
20+
asr_target_project =
21+
get_label_info(":refrigerator_app_sdk_sources", "label_no_toolchain")
22+
23+
declare_args() {
24+
# Disable lock tracking, since our FreeRTOS configuration does not set
25+
# INCLUDE_xSemaphoreGetMutexHolder
26+
chip_stack_lock_tracking = "none"
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../build_overrides/

examples/refrigerator-app/asr/cfg.gni

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2023 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+
declare_args() {
16+
chip_enable_factory_data = false
17+
18+
chip_lwip_ip6_hook = false
19+
20+
setupPinCode = 20202021
21+
22+
setupDiscriminator = 3840
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 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+
#pragma once
20+
21+
// ---- Refrigerator Example App Config ----
22+
23+
#if (CFG_EASY_LOG_ENABLE == 1)
24+
#include "elog.h"
25+
#endif
26+
27+
#define APP_TASK_NAME "APP"
28+
29+
#define APP_TASK_STACK_SIZE (1024 * 4)
30+
31+
#define MATTER_DEVICE_NAME "Refrigerator"
32+
33+
#ifdef __cplusplus
34+
extern "C" {
35+
#endif
36+
37+
void appError(int err);
38+
void ASR_LOG(const char * aFormat, ...);
39+
40+
#ifdef __cplusplus
41+
}
42+
43+
#include <lib/core/CHIPError.h>
44+
void appError(CHIP_ERROR error);
45+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 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+
#pragma once
20+
21+
#include <stdbool.h>
22+
#include <stdint.h>
23+
24+
#include <lega_rtos_api.h>
25+
#include <platform/CHIPDeviceLayer.h>
26+
27+
class AppTask
28+
{
29+
30+
public:
31+
CHIP_ERROR StartAppTask();
32+
static void AppTaskMain(void * pvParameter);
33+
34+
private:
35+
friend AppTask & GetAppTask(void);
36+
37+
static AppTask sAppTask;
38+
};
39+
40+
inline AppTask & GetAppTask(void)
41+
{
42+
return AppTask::sAppTask;
43+
}

0 commit comments

Comments
 (0)