Skip to content

Commit 0c2e51d

Browse files
[ESP32] Migrate Matter tracing from Insights backend to Diagnostics backend (project-chip#37893)
* remove insights backend and enable diagnostics with light example light example insight removal diagnostic data delegate implementation removed esp_insight_trace and esp_insight_stats config options fix insight file include issue - print memory in each timer iteration modify enable diagnostics method as per the latest update - move retrieve buffer to stack inside enable diagnostics method - use map with string compare removed insights support from energy-gateway-app Remove insights from idf_component.yml file Add insights delegate Move insights init code to delegate - Mode insights-delegate to common code insights support in energy-management-app update docs and readme for examples Restyled changes Replace diagnostics kconfig option * Remove newly added files from the esp_trace insights backend update diagnostics config option * Added missing bits in examples - addressed comments * Restyled by clang-format * Restyled by prettier-markdown * Remove insights dependency from examples * Update diagnostic config option from ESP_DIAGNOSTICS_ENABLED to CHIP_ENABLE_ESP_DIAGNOSTICS * Address Review comments * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent a6e7ae0 commit 0c2e51d

41 files changed

Lines changed: 487 additions & 1087 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config/esp32/components/chip/CMakeLists.txt

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -331,29 +331,16 @@ if (CONFIG_SEC_CERT_DAC_PROVIDER)
331331
chip_gn_arg_append("chip_use_secure_cert_dac_provider" "true")
332332
endif()
333333

334-
if (CONFIG_ENABLE_ESP_INSIGHTS_TRACE)
335-
chip_gn_arg_bool("matter_enable_tracing_support" "true")
336-
chip_gn_arg_append("matter_trace_config" "\"${CHIP_ROOT}/src/tracing/esp32_trace:esp32_trace_tracing\"")
337-
endif()
338-
339-
if (CONFIG_ENABLE_ESP_DIAGNOSTICS)
334+
if (CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS)
340335
chip_gn_arg_bool("matter_enable_tracing_support" "true")
341336
chip_gn_arg_append("matter_trace_config" "\"${CHIP_ROOT}/src/tracing/esp32_diagnostics:esp32_diagnostic_tracing\"")
342337
endif()
343338

344-
if (CONFIG_ENABLE_ESP_INSIGHTS_SYSTEM_STATS)
345-
chip_gn_arg_append("matter_enable_esp_insights_system_stats" "true")
346-
endif()
347-
348339
if (CONFIG_USE_ESP32_ECDSA_PERIPHERAL)
349340
chip_gn_arg_append("chip_use_esp32_ecdsa_peripheral" "true")
350341
endif()
351342

352-
if (CONFIG_ENABLE_ESP_INSIGHTS_TRACE)
353-
target_include_directories(${COMPONENT_LIB} INTERFACE "${CHIP_ROOT}/src/tracing/esp32_trace/include")
354-
endif()
355-
356-
if (CONFIG_ENABLE_ESP_DIAGNOSTICS)
343+
if (CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS)
357344
target_include_directories(${COMPONENT_LIB} INTERFACE "${CHIP_ROOT}/src/tracing/esp32_diagnostics/include")
358345
endif()
359346

@@ -426,11 +413,7 @@ if(CONFIG_ENABLE_PW_RPC)
426413
list(APPEND chip_libraries "${CMAKE_CURRENT_BINARY_DIR}/lib/libPwRpc.a")
427414
endif()
428415

429-
if (CONFIG_ENABLE_ESP_INSIGHTS_TRACE)
430-
list(APPEND chip_libraries "${CMAKE_CURRENT_BINARY_DIR}/lib/libEsp32TracingBackend.a")
431-
endif()
432-
433-
if (CONFIG_ENABLE_ESP_DIAGNOSTICS)
416+
if (CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS)
434417
list(APPEND chip_libraries "${CMAKE_CURRENT_BINARY_DIR}/lib/libEsp32DiagnosticsBackend.a")
435418
endif()
436419

config/esp32/components/chip/Kconfig

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -889,54 +889,38 @@ menu "CHIP Device Layer"
889889
By default, the implementation reads the Certification Declaration (CD) from the 'chip-factory'
890890
NVS namespace. If this option is enabled, the application can use an API to set a CD,
891891
the configured CD will be used for subsequent CD reads.
892-
893-
config ENABLE_ESP_INSIGHTS_TRACE
894-
bool "Enable Matter ESP Insights"
895-
depends on ESP_INSIGHTS_ENABLED
896-
default y
897-
help
898-
ESP Insights is a remote diagnostics solution to monitor the health of ESP devices in the field.
899-
Enabling the above option will enable the esp32 specific tracing functionality and report the
900-
diagnostic information to the insights cloud.
901-
902-
config ENABLE_ESP_INSIGHTS_SYSTEM_STATS
903-
bool "Enable System Stats for insights"
904-
depends on ESP_INSIGHTS_ENABLED
905-
default n
906-
help
907-
This option enables the system statistics to be sent to the insights cloud.
908-
909-
config MAX_PERMIT_LIST_SIZE
910-
int "Set permit list size for Insights traces"
911-
range 5 30
912-
depends on ESP_INSIGHTS_ENABLED
913-
default 20
914-
help
915-
Set the maximum number of group entries that can be included in the permit list for reporting
916-
traces to Insights. This ensures proper management of trace reporting capacity.
917892
endmenu
918893

919894
menu "Diagnostics Options"
920-
config ENABLE_ESP_DIAGNOSTICS
895+
config CHIP_ENABLE_ESP_DIAGNOSTICS
921896
bool "Enable ESP Platform Diagnostics for Matter"
922897
default n
923898
help
924899
Enables the ESP Diagnostics platform to collect, store, and retrieve diagnostic data for the Matter protocol.
925900
This feature helps monitor system health and performance by providing insights through diagnostics logs.
926901

927-
config ENABLE_ESP_DIAGNOSTIC_TRACES
902+
config CHIP_ENABLE_ESP_DIAGNOSTIC_TRACES
928903
bool "Enable Traces"
929904
default y
930-
depends on ENABLE_ESP_DIAGNOSTICS
905+
depends on CHIP_ENABLE_ESP_DIAGNOSTICS
931906
help
932907
Enable Traces for the ESP Platform Diagnostics for Matter.
933908

934-
config ENABLE_ESP_DIAGNOSTIC_METRICS
909+
config CHIP_ENABLE_ESP_DIAGNOSTIC_METRICS
935910
bool "Enable Metrics"
936911
default y
937-
depends on ENABLE_ESP_DIAGNOSTICS
912+
depends on CHIP_ENABLE_ESP_DIAGNOSTICS
938913
help
939914
Enable Metrics for the ESP Platform Diagnostics for Matter.
915+
916+
config MAX_PERMIT_LIST_SIZE
917+
int "Set permit list size for Insights traces"
918+
range 5 30
919+
depends on CHIP_ENABLE_ESP_DIAGNOSTICS
920+
default 20
921+
help
922+
Set the maximum number of group entries that can be included in the permit list for reporting
923+
traces to Insights. This ensures proper management of trace reporting capacity.
940924
endmenu
941925

942926
menu "Testing Options"

config/esp32/components/chip/idf_component.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ dependencies:
1616
rules:
1717
- if: "idf_version >=4.4"
1818

19-
espressif/esp_insights:
20-
version: "^1.2.4"
21-
require: public
22-
# There is an issue with IDF-Component-Manager when ESP Insights is included.
23-
# Issue: https://github.com/project-chip/connectedhomeip/issues/29125
24-
rules:
25-
- if: "idf_version >=5.0"
26-
- if: "target != esp32h2"
27-
2819
espressif/esp_delta_ota:
2920
version: "^1.1.0"
3021
require: public

docs/platforms/esp32/diagnostics.md

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Enable the following configuration options to use the ESP32 Diagnostic Logs
99
Provider:
1010

1111
```
12-
CONFIG_ENABLE_ESP_DIAGNOSTICS=y
12+
CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS=y
1313
```
1414

1515
This option enables the diagnostic logs storage functionality. By default, this
@@ -21,15 +21,15 @@ options accordingly:
2121
To enable only metrics:
2222

2323
```
24-
CONFIG_ENABLE_ESP_DIAGNOSTIC_TRACES=n
25-
CONFIG_ENABLE_ESP_DIAGNOSTIC_METRICS=y
24+
CONFIG_CHIP_ENABLE_ESP_DIAGNOSTIC_TRACES=n
25+
CONFIG_CHIP_ENABLE_ESP_DIAGNOSTIC_METRICS=y
2626
```
2727

2828
To enable only traces:
2929

3030
```
31-
CONFIG_ENABLE_ESP_DIAGNOSTIC_TRACES=y
32-
CONFIG_ENABLE_ESP_DIAGNOSTIC_METRICS=n
31+
CONFIG_CHIP_ENABLE_ESP_DIAGNOSTIC_TRACES=y
32+
CONFIG_CHIP_ENABLE_ESP_DIAGNOSTIC_METRICS=n
3333
```
3434

3535
After modifying the configuration options, make sure to perform a clean build to
@@ -67,12 +67,12 @@ Add the diagnostic logs provider delegate header to your application:
6767
Define buffers to store and retrieve diagnostic data:
6868

6969
```cpp
70-
#ifdef CONFIG_ENABLE_ESP_DIAGNOSTICS
70+
#ifdef CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS
7171
static uint8_t retrievalBuffer[CONFIG_RETRIEVAL_BUFFER_SIZE]; // Buffer for retrieving diagnostics
7272
static uint8_t endUserBuffer[CONFIG_END_USER_BUFFER_SIZE]; // Buffer for storing diagnostics
7373

7474
using namespace chip::app::Clusters::DiagnosticLogs;
75-
#endif // CONFIG_ENABLE_ESP_DIAGNOSTICS
75+
#endif // CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS
7676
```
7777

7878
The buffer sizes can be configured through Kconfig options:
@@ -87,14 +87,14 @@ The buffer sizes can be configured through Kconfig options:
8787
Implement the diagnostic logs cluster initialization callback:
8888

8989
```cpp
90-
#ifdef CONFIG_ENABLE_ESP_DIAGNOSTICS
90+
#ifdef CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS
9191
void emberAfDiagnosticLogsClusterInitCallback(chip::EndpointId endpoint)
9292
{
9393
auto & logProvider = LogProvider::GetInstance();
9494
logProvider.Init(endUserBuffer, CONFIG_END_USER_BUFFER_SIZE, retrievalBuffer, CONFIG_RETRIEVAL_BUFFER_SIZE);
9595
DiagnosticLogsServer::Instance().SetDiagnosticLogsProviderDelegate(endpoint, &logProvider);
9696
}
97-
#endif // CONFIG_ENABLE_ESP_DIAGNOSTICS
97+
#endif // CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS
9898
```
9999

100100
This callback initializes the log provider with the configured buffers and sets
@@ -123,11 +123,49 @@ CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF=y
123123

124124
The `examples/temperature-measurement-app/esp32/` demonstrates proper
125125
integration: For more information related to the retrieval of diagnostics
126-
through diagnosticlogs cluster refer readme.md in app folder.
126+
through diagnosticlogs cluster refer Readme.md in app folder.
127+
128+
# Using ESP32 Insights Integration
129+
130+
This section describes how to integrate ESP Insights functionality for automatic
131+
diagnostic data collection and cloud reporting.
132+
133+
## Configuration Options
134+
135+
Enable the following configuration options to use ESP Insights:
136+
137+
```
138+
CONFIG_ESP_INSIGHTS_ENABLED=y
139+
CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS=y
140+
```
141+
142+
Both options are required:
143+
144+
- `CONFIG_ESP_INSIGHTS_ENABLED`: Enables ESP Insights cloud integration
145+
- `CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS`: Enables diagnostic data collection
146+
147+
## Implementation Reference
148+
149+
The ESP32 Insights delegate implementation is available at:
150+
151+
```
152+
examples/platform/esp32/diagnostics/insights/insights-delegate.h
153+
examples/platform/esp32/diagnostics/insights/insights-delegate.cpp
154+
```
155+
156+
These files contain the implementation of the `InsightsDelegate` class which
157+
handles diagnostic data collection and transmission to ESP Insights.
158+
159+
## Insights Example Integration
160+
161+
The `examples/lighting-app/esp32/` demonstrates proper integration:
162+
163+
For more detailed information about insights integration refer to the README.md
164+
file in each application folder.
127165

128166
## Important Notes
129167

130168
- The diagnostic logs provider **must** be explicitly enabled through the
131-
`CONFIG_ENABLE_ESP_DIAGNOSTICS` option
169+
`CONFIG_CHIP_ENABLE_ESP_DIAGNOSTICS` option
132170
- Buffer sizes should be adjusted based on your application's needs
133171
- The provider supports end-user support logs and crash logs (when configured)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
/build/
22
/sdkconfig
33
/sdkconfig.old
4-
main/insights_auth_key.txt

examples/energy-gateway-app/esp32/README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,6 @@ and refer
99
[building and commissioning](../../../docs/platforms/esp32/build_app_and_commission.md)
1010
guides to get started.
1111

12-
### Enabling ESP-Insights:
13-
14-
- Before building the app, enable the option: `ESP_INSIGHTS_ENABLED` through
15-
menuconfig.
16-
17-
- Create a file named `insights_auth_key.txt` in the main directory of the
18-
example.
19-
20-
- Follow the steps present
21-
[here](https://github.com/espressif/esp-insights/blob/main/examples/README.md#set-up-esp-insights-account)
22-
to set up an insights_account and the auth key created while setting it up
23-
will be used in the example.
24-
25-
- Download the auth key and copy Auth Key to the example
26-
27-
```
28-
cp /path/to/auth/key.txt path/to/connectedhomeip/examples/energy-gateway-app/esp32/main/insights_auth_key.txt
29-
```
30-
31-
---
32-
33-
- [Cluster Control](#cluster-control)
34-
- [Matter OTA guide](../../../docs/platforms/esp32/ota.md)
35-
36-
---
37-
3812
### Build time configuration
3913

4014
- Test Event Trigger support: By default the `CommodityPrice` and

examples/energy-gateway-app/esp32/main/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ chip_configure_data_model(${COMPONENT_LIB}
7979
ZAP_FILE ${ENERGY_GATEWAY_DIR}/energy-gateway-common/energy-gateway-app.zap
8080
)
8181

82-
if(CONFIG_ENABLE_ESP_INSIGHTS_TRACE)
83-
target_add_binary_data(${COMPONENT_TARGET} "insights_auth_key.txt" TEXT)
84-
endif()
85-
8682
target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")
8783
target_compile_options(${COMPONENT_LIB} PUBLIC
8884
"-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>"

examples/energy-gateway-app/esp32/main/main.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,13 @@
6262
#include <platform/ESP32/ESP32SecureCertDACProvider.h>
6363
#endif
6464

65-
#if CONFIG_ENABLE_ESP_INSIGHTS_TRACE
66-
#include <esp_insights.h>
67-
#include <tracing/esp32_trace/esp32_tracing.h>
68-
#include <tracing/registry.h>
69-
#endif
70-
7165
using namespace ::chip;
7266
using namespace chip::app;
7367
using namespace chip::app::Clusters;
7468
using namespace ::chip::Credentials;
7569
using namespace ::chip::DeviceManager;
7670
using namespace ::chip::DeviceLayer;
7771

78-
#if CONFIG_ENABLE_ESP_INSIGHTS_TRACE
79-
extern const char insights_auth_key_start[] asm("_binary_insights_auth_key_txt_start");
80-
extern const char insights_auth_key_end[] asm("_binary_insights_auth_key_txt_end");
81-
#endif
82-
8372
static const char * TAG = "energy-gateway-app";
8473

8574
static AppDeviceCallbacks EchoCallbacks;
@@ -136,23 +125,6 @@ static void InitServer(intptr_t context)
136125
DeviceCallbacksDelegate::Instance().SetAppDelegate(&sAppDeviceCallbacksDelegate);
137126
Esp32AppServer::Init(); // Init ZCL Data Model and CHIP App Server AND
138127
// Initialize device attestation config
139-
#if CONFIG_ENABLE_ESP_INSIGHTS_TRACE
140-
esp_insights_config_t config = {
141-
.log_type = ESP_DIAG_LOG_TYPE_ERROR | ESP_DIAG_LOG_TYPE_WARNING | ESP_DIAG_LOG_TYPE_EVENT,
142-
.auth_key = insights_auth_key_start,
143-
};
144-
145-
esp_err_t ret = esp_insights_init(&config);
146-
147-
if (ret != ESP_OK)
148-
{
149-
ESP_LOGE(TAG, "Failed to initialize ESP Insights, err:0x%x", ret);
150-
}
151-
152-
static Tracing::Insights::ESP32Backend backend;
153-
Tracing::Register(backend);
154-
#endif
155-
156128
// Application code should always be initialised after the initialisation of
157129
// server.
158130
ApplicationInit();

examples/evse-app/esp32/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
/build/
22
/sdkconfig
33
/sdkconfig.old
4-
main/insights_auth_key.txt

examples/evse-app/esp32/README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,6 @@ and refer
1010
[building and commissioning](../../../docs/platforms/esp32/build_app_and_commission.md)
1111
guides to get started.
1212

13-
### Enabling ESP-Insights:
14-
15-
- Before building the app, enable the option: `ESP_INSIGHTS_ENABLED` through
16-
menuconfig.
17-
18-
- Create a file named `insights_auth_key.txt` in the main directory of the
19-
example.
20-
21-
- Follow the steps present
22-
[here](https://github.com/espressif/esp-insights/blob/main/examples/README.md#set-up-esp-insights-account)
23-
to set up an insights_account and the auth key created while setting it up
24-
will be used in the example.
25-
26-
- Download the auth key and copy Auth Key to the example
27-
28-
```bash
29-
cp /path/to/auth/key.txt path/to/connectedhomeip/examples/evse-app/esp32/main/insights_auth_key.txt
30-
```
31-
32-
---
33-
34-
- [Cluster Control](#cluster-control)
35-
- [Matter OTA guide](../../../docs/platforms/esp32/ota.md)
36-
37-
---
38-
3913
### Build time configuration
4014

4115
- Test Event Trigger support: By default the EVSE, Device Energy Management

0 commit comments

Comments
 (0)