Skip to content

Commit 6c89640

Browse files
ESP32: Add lit-icd-app example for ESP32-H2 and ESP32-C6 (#32784)
* Add lit-icd-app example for ESP32-H2 and ESP32-C6 * Restyled by prettier-markdown --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent f1abb59 commit 6c89640

16 files changed

+494
-23
lines changed

docs/guides/esp32/build_app_and_commission.md

+2-11
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ and the ESP32S3.
3131

3232
All the applications support variants of ESP32, ESP32C3, ESP32S3 chips.
3333

34-
ESP32H2 and ESP32C6 are only supported and tested with lighting-app and
35-
all-clusters-app.
34+
ESP32H2 and ESP32C6 are only supported and tested with lighting-app,
35+
lit-icd-app, and all-clusters-app.
3636

3737
Note: M5Stack Core 2 display is not supported in the tft component, while other
3838
functionality can still work fine.
@@ -85,15 +85,6 @@ functionality can still work fine.
8585
$ idf.py set-target (target chip)
8686
```
8787
88-
All the example applications supports target chips: esp32, esp32s3, esp32c3
89-
90-
ESP32H2 and ESP32C6 are only supported in lighting-app, to set it as target
91-
92-
```
93-
$ idf.py --preview set-target esp32h2
94-
$ idf.py --preview set-target esp32c6
95-
```
96-
9788
- Configuration Options
9889
9990
To build the default configuration (`sdkconfig.defaults`) skip this step.

examples/lit-icd-app/esp32/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.vscode
2+
3+
/build/
4+
/sdkconfig
5+
/sdkconfig.old
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# Copyright (c) 2024 Project CHIP Authors
3+
# All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# The following lines of boilerplate have to be in your project's
18+
# CMakeLists in this exact order for cmake to work correctly
19+
cmake_minimum_required(VERSION 3.5)
20+
21+
set(PROJECT_VER "v1.0")
22+
set(PROJECT_VER_NUMBER 1)
23+
24+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
25+
26+
27+
set(EXTRA_COMPONENT_DIRS
28+
"${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components"
29+
)
30+
31+
project(lit-icd-app)
32+
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H" APPEND)
33+
idf_build_set_property(C_COMPILE_OPTIONS "-Os" APPEND)
34+
# For the RISC-V chips, project_include.cmake sets -Wno-format, but does not clear various
35+
# flags that depend on -Wformat
36+
idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security" APPEND)
37+
38+
# -Wmaybe-uninitialized has too many false positives, including on std::optional
39+
# and chip::Optional. Make it nonfatal.
40+
#
41+
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
42+
idf_build_set_property(COMPILE_OPTIONS "-Wno-error=maybe-uninitialized" APPEND)

examples/lit-icd-app/esp32/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Matter ESP32 LIT ICD Example
2+
3+
This example is meant to represent a power-save application.
4+
5+
Please
6+
[setup ESP-IDF and CHIP Environment](../../../docs/guides/esp32/setup_idf_chip.md)
7+
and refer
8+
[building and commissioning](../../../docs/guides/esp32/build_app_and_commission.md)
9+
guides to get started.
10+
11+
**Note**: Currently only Thread devices can run this example.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#
2+
# Copyright (c) 2024 Project CHIP Authors
3+
# All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
#
18+
19+
get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH)
20+
21+
set(PRIV_INCLUDE_DIRS_LIST
22+
"${CMAKE_CURRENT_LIST_DIR}/include"
23+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32"
24+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers"
25+
)
26+
set(SRC_DIRS_LIST
27+
"${CMAKE_CURRENT_LIST_DIR}"
28+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
29+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
30+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
31+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
32+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
33+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server"
34+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server"
35+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic-information"
36+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/bindings"
37+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor"
38+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server"
39+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server"
40+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server"
41+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server"
42+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server"
43+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server"
44+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/icd-management-server"
45+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server"
46+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning"
47+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server"
48+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor"
49+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server"
50+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server"
51+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server"
52+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server"
53+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common"
54+
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers"
55+
)
56+
57+
idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST}
58+
SRC_DIRS ${SRC_DIRS_LIST})
59+
60+
include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake")
61+
chip_app_component_codegen("${CHIP_ROOT}/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter")
62+
chip_app_component_zapgen("${CHIP_ROOT}/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap")
63+
64+
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
65+
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
66+
target_compile_options(${COMPONENT_LIB} PUBLIC
67+
"-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>"
68+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
/**
20+
* @file DeviceCallbacks.cpp
21+
*
22+
* Implements all the callbacks to the application from the CHIP Stack
23+
*
24+
**/
25+
#include "DeviceCallbacks.h"
26+
27+
static const char TAG[] = "devicecallbacks";
28+
29+
using namespace ::chip;
30+
using namespace ::chip::Inet;
31+
using namespace ::chip::System;
32+
33+
void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId,
34+
uint8_t type, uint16_t size, uint8_t * value)
35+
{
36+
ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%" PRIx32 "', EndPoint ID: '0x%x', Attribute ID: '0x%" PRIx32 "'",
37+
clusterId, endpointId, attributeId);
38+
39+
// TODO handle this callback in switch statement
40+
ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId);
41+
42+
ESP_LOGI(TAG, "Current free heap: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT));
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#
2+
# Copyright (c) 2020 Project CHIP Authors
3+
# All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# Description:
18+
# Configuration options CHIP ESP32 demo application.
19+
#
20+
21+
menu "Demo"
22+
23+
choice
24+
prompt "Rendezvous Mode"
25+
default RENDEZVOUS_MODE_BLE
26+
help
27+
Specifies the Rendezvous mode of the peripheral.
28+
29+
config RENDEZVOUS_MODE_WIFI
30+
bool "Wi-Fi"
31+
config RENDEZVOUS_MODE_BLE
32+
bool "BLE"
33+
config RENDEZVOUS_MODE_THREAD
34+
bool "Thread"
35+
config RENDEZVOUS_MODE_ETHERNET
36+
bool "Ethernet"
37+
endchoice
38+
39+
config RENDEZVOUS_MODE
40+
int
41+
range 0 8
42+
default 1 if RENDEZVOUS_MODE_WIFI
43+
default 2 if RENDEZVOUS_MODE_BLE
44+
default 4 if RENDEZVOUS_MODE_THREAD
45+
default 8 if RENDEZVOUS_MODE_ETHERNET
46+
47+
endmenu
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
/**
20+
* @file DeviceCallbacks.h
21+
*
22+
* Implementations for the DeviceManager callbacks for this application
23+
*
24+
**/
25+
26+
#ifndef DEVICE_CALLBACKS_H
27+
#define DEVICE_CALLBACKS_H
28+
29+
#include <common/CHIPDeviceManager.h>
30+
#include <common/CommonDeviceCallbacks.h>
31+
32+
class AppDeviceCallbacks : public CommonDeviceCallbacks
33+
{
34+
public:
35+
virtual void PostAttributeChangeCallback(chip::EndpointId endpointId, chip::ClusterId clusterId, chip::AttributeId attributeId,
36+
uint8_t type, uint16_t size, uint8_t * value);
37+
};
38+
39+
#endif // DEVICE_CALLBACKS_H

0 commit comments

Comments
 (0)