Skip to content

Commit

Permalink
SoftwareDiagnostics::Watermark support based on implementation flags (#…
Browse files Browse the repository at this point in the history
…19195)

* Make watermark feature enum visible, use it

* Make sure platforms with a `ResetWatermarks` return true on the support method

* Add featuremap as access interface for software diagnostics, resort items
  • Loading branch information
andy31415 authored Jun 6, 2022
1 parent 4276152 commit 883d799
Show file tree
Hide file tree
Showing 24 changed files with 94 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2938,6 +2938,10 @@ server cluster Scenes = 5 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,10 @@ server cluster Scenes = 5 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

info event SoftwareFault = 0 {
SoftwareFaultStruct softwareFault = 0;
}
Expand Down
4 changes: 4 additions & 0 deletions examples/bridge-app/bridge-common/bridge-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@ server cluster OperationalCredentials = 62 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,10 @@ client cluster Scenes = 5 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
4 changes: 4 additions & 0 deletions examples/lighting-app/lighting-common/lighting-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,10 @@ server cluster OperationalCredentials = 62 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
4 changes: 4 additions & 0 deletions examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,10 @@ server cluster PowerSourceConfiguration = 46 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
4 changes: 4 additions & 0 deletions examples/placeholder/linux/apps/app1/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,10 @@ server cluster Scenes = 5 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
4 changes: 4 additions & 0 deletions examples/placeholder/linux/apps/app2/config.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,10 @@ server cluster Scenes = 5 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,10 @@ client cluster PumpConfigurationAndControl = 512 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@ server cluster OperationalCredentials = 62 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

info event SoftwareFault = 0 {
SoftwareFaultStruct softwareFault = 0;
}
Expand Down
4 changes: 4 additions & 0 deletions examples/thermostat/thermostat-common/thermostat.matter
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,10 @@ server cluster Scenes = 5 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
4 changes: 4 additions & 0 deletions examples/tv-app/tv-common/tv-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,10 @@ server cluster RelativeHumidityMeasurement = 1029 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,10 @@ server cluster Scenes = 5 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
4 changes: 4 additions & 0 deletions examples/window-app/common/window-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,10 @@ client cluster Scenes = 5 {
}

server cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,27 @@ CHIP_ERROR SoftwareDiagosticsAttrAccess::Read(const ConcreteReadAttributePath &

switch (aPath.mAttributeId)
{
case CurrentHeapFree::Id: {
case CurrentHeapFree::Id:
return ReadIfSupported(&DiagnosticDataProvider::GetCurrentHeapFree, aEncoder);
}
case CurrentHeapUsed::Id: {
case CurrentHeapUsed::Id:
return ReadIfSupported(&DiagnosticDataProvider::GetCurrentHeapUsed, aEncoder);
}
case CurrentHeapHighWatermark::Id: {
case CurrentHeapHighWatermark::Id:
return ReadIfSupported(&DiagnosticDataProvider::GetCurrentHeapHighWatermark, aEncoder);
}
case ThreadMetrics::Id: {
case ThreadMetrics::Id:
return ReadThreadMetrics(aEncoder);
case Clusters::Globals::Attributes::FeatureMap::Id: {
BitFlags<SoftwareDiagnosticsFeature> features;

if (DeviceLayer::GetDiagnosticDataProvider().SupportsWatermarks())
{
features.Set(SoftwareDiagnosticsFeature::kWaterMarks);
}

return aEncoder.Encode(features);
}
default: {
default:
break;
}
}
return CHIP_NO_ERROR;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ limitations under the License.
</event>
</cluster>
<bitmap name="SoftwareDiagnosticsFeature" type="BITMAP32">
<cluster code="0x0034"/>
<field name="WaterMarks" mask="0x1"/>
</bitmap>
</configurator>
3 changes: 2 additions & 1 deletion src/app/zap-templates/zcl/zcl.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@
],
"Software Diagnostics": [
"CurrentHeapFree",
"CurrentHeapUsed",
"CurrentHeapHighWatermark",
"CurrentHeapUsed",
"FeatureMap",
"ThreadMetrics"
],
"Test Cluster": [
Expand Down
4 changes: 4 additions & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -3362,6 +3362,10 @@ client cluster Scenes = 5 {
}

client cluster SoftwareDiagnostics = 52 {
bitmap SoftwareDiagnosticsFeature : BITMAP32 {
kWaterMarks = 0x1;
}

struct ThreadMetrics {
int64u id = 0;
optional char_string<8> name = 1;
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/include/platform/DiagnosticDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ class DiagnosticDataProvider
/**
* Software Diagnostics methods.
*/

/// Feature support - this returns support gor GetCurrentHeapHighWatermark and ResetWatermarks()
virtual bool SupportsWatermarks() { return false; }

virtual CHIP_ERROR GetCurrentHeapFree(uint64_t & currentHeapFree);
virtual CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed);
virtual CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark);
Expand Down
1 change: 1 addition & 0 deletions src/platform/Darwin/DiagnosticDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider
CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override;

// ===== Methods that implement the DiagnosticDataProvider abstract interface.
bool SupportsWatermarks() override { return true; }
CHIP_ERROR ResetWatermarks() override;
};

Expand Down
1 change: 1 addition & 0 deletions src/platform/EFR32/DiagnosticDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider

// ===== Methods that implement the PlatformManager abstract interface.

bool SupportsWatermarks() override { return true; }
CHIP_ERROR GetCurrentHeapFree(uint64_t & currentHeapFree) override;
CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed) override;
CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) override;
Expand Down
1 change: 1 addition & 0 deletions src/platform/Linux/DiagnosticDataProviderImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider

// ===== Methods that implement the DiagnosticDataProvider abstract interface.

bool SupportsWatermarks() override { return true; }
CHIP_ERROR GetCurrentHeapFree(uint64_t & currentHeapFree) override;
CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed) override;
CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) override;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 883d799

Please sign in to comment.