File tree 6 files changed +34
-16
lines changed
app/clusters/software-diagnostics-server
6 files changed +34
-16
lines changed Original file line number Diff line number Diff line change @@ -156,23 +156,11 @@ bool emberAfSoftwareDiagnosticsClusterResetWatermarksCallback(app::CommandHandle
156
156
{
157
157
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
158
158
159
- uint64_t currentHeapUsed;
160
- CHIP_ERROR err = DeviceLayer::GetDiagnosticDataProvider ().GetCurrentHeapUsed (currentHeapUsed);
161
-
162
- // Skip SetCurrentHeapHighWatermark if GetCurrentHeapUsed is not implemented
163
- if (err != CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE && err != CHIP_ERROR_NOT_IMPLEMENTED)
159
+ // If implemented, the server SHALL set the value of the CurrentHeapHighWatermark attribute to the
160
+ // value of the CurrentHeapUsed.
161
+ if (DeviceLayer::GetDiagnosticDataProvider ().ResetWatermarks () != CHIP_NO_ERROR)
164
162
{
165
- if (err == CHIP_NO_ERROR)
166
- {
167
- if (CHIP_NO_ERROR != DeviceLayer::GetDiagnosticDataProvider ().SetCurrentHeapHighWatermark (currentHeapUsed))
168
- {
169
- status = EMBER_ZCL_STATUS_FAILURE;
170
- }
171
- }
172
- else
173
- {
174
- status = EMBER_ZCL_STATUS_FAILURE;
175
- }
163
+ status = EMBER_ZCL_STATUS_FAILURE;
176
164
}
177
165
178
166
emberAfSendImmediateDefaultResponse (status);
Original file line number Diff line number Diff line change @@ -180,6 +180,7 @@ class DiagnosticDataProvider
180
180
virtual CHIP_ERROR GetCurrentHeapUsed (uint64_t & currentHeapUsed);
181
181
virtual CHIP_ERROR GetCurrentHeapHighWatermark (uint64_t & currentHeapHighWatermark);
182
182
virtual CHIP_ERROR SetCurrentHeapHighWatermark (uint64_t heapHighWatermark);
183
+ virtual CHIP_ERROR ResetWatermarks ();
183
184
184
185
/*
185
186
* Get the linked list of thread metrics of the current plaform. After usage, each caller of GetThreadMetrics
@@ -272,6 +273,11 @@ inline CHIP_ERROR DiagnosticDataProvider::SetCurrentHeapHighWatermark(uint64_t h
272
273
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
273
274
}
274
275
276
+ inline CHIP_ERROR DiagnosticDataProvider::ResetWatermarks ()
277
+ {
278
+ return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
279
+ }
280
+
275
281
inline CHIP_ERROR DiagnosticDataProvider::GetThreadMetrics (ThreadMetrics ** threadMetricsOut)
276
282
{
277
283
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
Original file line number Diff line number Diff line change @@ -68,5 +68,14 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetTotalOperationalHours(uint32_t & total
68
68
return CHIP_ERROR_INVALID_TIME;
69
69
}
70
70
71
+ CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks ()
72
+ {
73
+ // If implemented, the server SHALL set the value of the CurrentHeapHighWatermark attribute to the
74
+ // value of the CurrentHeapUsed.
75
+ // On Darwin, overide with non-op to pass CI.
76
+
77
+ return CHIP_NO_ERROR;
78
+ }
79
+
71
80
} // namespace DeviceLayer
72
81
} // namespace chip
Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider
38
38
// ===== Methods that implement the PlatformManager abstract interface.
39
39
CHIP_ERROR GetUpTime (uint64_t & upTime) override ;
40
40
CHIP_ERROR GetTotalOperationalHours (uint32_t & totalOperationalHours) override ;
41
+
42
+ // ===== Methods that implement the DiagnosticDataProvider abstract interface.
43
+ CHIP_ERROR ResetWatermarks () override ;
41
44
};
42
45
43
46
} // namespace DeviceLayer
Original file line number Diff line number Diff line change @@ -274,6 +274,17 @@ CHIP_ERROR DiagnosticDataProviderImpl::SetCurrentHeapHighWatermark(uint64_t heap
274
274
return CHIP_NO_ERROR;
275
275
}
276
276
277
+ CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks ()
278
+ {
279
+ // If implemented, the server SHALL set the value of the CurrentHeapHighWatermark attribute to the
280
+ // value of the CurrentHeapUsed.
281
+
282
+ // On Linux, the write operation is non-op since we always rely on the mallinfo system
283
+ // function to get the current heap memory.
284
+
285
+ return CHIP_NO_ERROR;
286
+ }
287
+
277
288
CHIP_ERROR DiagnosticDataProviderImpl::GetThreadMetrics (ThreadMetrics ** threadMetricsOut)
278
289
{
279
290
CHIP_ERROR err = CHIP_ERROR_READ_FAILED;
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider
44
44
CHIP_ERROR GetCurrentHeapHighWatermark (uint64_t & currentHeapHighWatermark) override ;
45
45
CHIP_ERROR GetThreadMetrics (ThreadMetrics ** threadMetricsOut) override ;
46
46
CHIP_ERROR SetCurrentHeapHighWatermark (uint64_t heapHighWatermark) override ;
47
+ CHIP_ERROR ResetWatermarks () override ;
47
48
void ReleaseThreadMetrics (ThreadMetrics * threadMetrics) override ;
48
49
49
50
CHIP_ERROR GetRebootCount (uint16_t & rebootCount) override ;
You can’t perform that action at this time.
0 commit comments