Skip to content

Commit 8b29ccb

Browse files
committed
example/temperature-measurement-app
- Resolve buffer issues - Use single buffer for store and retrieve of diagnostics - Resolve data loss issue
1 parent ae51ae7 commit 8b29ccb

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

examples/temperature-measurement-app/esp32/main/diagnostic-logs-provider-delegate-impl.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ using namespace chip::app::Clusters::DiagnosticLogs;
2929
LogProvider LogProvider::sInstance;
3030
LogProvider::CrashLogContext LogProvider::sCrashLogContext;
3131

32-
#if CONFIG_ENABLE_ESP_DIAGNOSTICS_TRACE
33-
static uint8_t retrieveBuffer[RETRIEVAL_BUFFER_SIZE];
34-
MutableByteSpan endUserSupportSpan(retrieveBuffer, sizeof(retrieveBuffer));
35-
#endif
36-
3732
namespace {
3833
bool IsValidIntent(IntentEnum intent)
3934
{
@@ -83,7 +78,7 @@ size_t LogProvider::GetSizeForIntent(IntentEnum intent)
8378
case IntentEnum::kEndUserSupport:
8479
{
8580
#if CONFIG_ENABLE_ESP_DIAGNOSTICS_TRACE
86-
return RETRIEVAL_BUFFER_SIZE;
81+
return DIAGNOSTIC_BUFFER_SIZE;
8782
#else
8883
return static_cast<size_t>(endUserSupportLogEnd - endUserSupportLogStart);
8984
#endif
@@ -122,10 +117,10 @@ CHIP_ERROR LogProvider::PrepareLogContextForIntent(LogContext * context, IntentE
122117
case IntentEnum::kEndUserSupport: {
123118
#if CONFIG_ENABLE_ESP_DIAGNOSTICS_TRACE
124119
DiagnosticStorageImpl & diagnosticStorage = DiagnosticStorageImpl::GetInstance();
120+
MutableByteSpan endUserSupportSpan(endUserBuffer, DIAGNOSTIC_BUFFER_SIZE);
125121

126122
if (diagnosticStorage.IsEmptyBuffer())
127123
{
128-
printf("Buffer is empty\n");
129124
ChipLogError(DeviceLayer, "Empty Diagnostic buffer");
130125
return CHIP_ERROR_NOT_FOUND;
131126
}
@@ -144,6 +139,7 @@ CHIP_ERROR LogProvider::PrepareLogContextForIntent(LogContext * context, IntentE
144139
#endif
145140
}
146141
break;
142+
147143
case IntentEnum::kNetworkDiag: {
148144
context->NetworkDiag.span =
149145
ByteSpan(&networkDiagnosticLogStart[0], static_cast<size_t>(networkDiagnosticLogEnd - networkDiagnosticLogStart));

examples/temperature-measurement-app/esp32/main/include/diagnostic-logs-provider-delegate-impl.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#endif // defined(CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH) && defined(CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF)
3232

3333
#if CONFIG_ENABLE_ESP_DIAGNOSTICS_TRACE
34-
#define RETRIEVAL_BUFFER_SIZE CONFIG_END_USER_BUFFER_SIZE
34+
#define DIAGNOSTIC_BUFFER_SIZE CONFIG_END_USER_BUFFER_SIZE
35+
static uint8_t endUserBuffer[DIAGNOSTIC_BUFFER_SIZE];
36+
3537
using namespace chip::Tracing::Diagnostics;
3638
#endif
3739

examples/temperature-measurement-app/esp32/main/main.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ extern const char TAG[] = "temperature-measurement-app";
7676

7777
static AppDeviceCallbacks EchoCallbacks;
7878

79-
#if CONFIG_ENABLE_ESP_DIAGNOSTICS_TRACE
80-
using namespace chip::Tracing::Diagnostics;
81-
static uint8_t endUserBuffer[CONFIG_END_USER_BUFFER_SIZE];
82-
static size_t buffer_size = CONFIG_END_USER_BUFFER_SIZE;
83-
#endif
84-
8579
static void InitServer(intptr_t context)
8680
{
8781
Esp32AppServer::Init(); // Init ZCL Data Model and CHIP App Server AND Initialize device attestation config
@@ -94,7 +88,7 @@ extern "C" void app_main()
9488
#endif
9589

9690
#if CONFIG_ENABLE_ESP_DIAGNOSTICS_TRACE
97-
static ESP32Diagnostics diagnosticBackend(endUserBuffer, buffer_size);
91+
static ESP32Diagnostics diagnosticBackend(endUserBuffer, DIAGNOSTIC_BUFFER_SIZE);
9892
Tracing::Register(diagnosticBackend);
9993
#endif
10094

0 commit comments

Comments
 (0)