[Code Driven Cluster] temperature measurement cluster#43204
[Code Driven Cluster] temperature measurement cluster#43204arielsz71 wants to merge 16 commits intoproject-chip:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request decouples the Temperature Measurement cluster by migrating it to a code-driven implementation. The changes are extensive, touching many example applications to adopt the new API for setting temperature values. New cluster implementation files, tests, and build configurations have been added. The overall approach is solid and the implementation appears correct and consistent across the codebase. I have one suggestion to improve the formatting of the new README file for better readability.
| # This cluster is currently following a code driven approach. | ||
|
|
||
| # This means that the Accessors for the attribute MeasuredValue are no longer available. | ||
|
|
||
| # Now to set the value for this attribute the following code change applies: | ||
|
|
||
| # BEFORE (using the Accessors) | ||
|
|
||
| app::Clusters::TemperatureMeasurement::Attributes::MeasuredValue::Set(1, value); | ||
|
|
||
| # CURRENT (using the code driven approach) | ||
|
|
||
| auto temperatureMeasurement = app::Clusters::TemperatureMeasurement::FindClusterOnEndpoint(1); | ||
| VerifyOrReturn(temperatureMeasurement != nullptr); | ||
|
|
||
| CHIP_ERROR err = temperatureMeasurement->SetMeasuredValue(value); | ||
| if (err == CHIP_NO_ERROR) | ||
| { | ||
| // SetMeasuredValue() succeeded | ||
| } | ||
| else | ||
| { | ||
| // SetMeasuredValue() failed | ||
| } |
There was a problem hiding this comment.
The markdown formatting in this file seems incorrect. Each line starting with a # will render as a top-level heading, which is likely not the intended formatting. I've suggested a change to use proper markdown for headers, paragraphs, and fenced code blocks to improve readability.
This cluster is currently following a code driven approach.
This means that the Accessors for the attribute `MeasuredValue` are no longer available.
Now to set the value for this attribute the following code change applies:
### BEFORE (using the Accessors)
```cpp
app::Clusters::TemperatureMeasurement::Attributes::MeasuredValue::Set(1, value);CURRENT (using the code driven approach)
auto temperatureMeasurement = app::Clusters::TemperatureMeasurement::FindClusterOnEndpoint(1);
VerifyOrReturn(temperatureMeasurement != nullptr);
CHIP_ERROR err = temperatureMeasurement->SetMeasuredValue(value);
if (err == CHIP_NO_ERROR)
{
// SetMeasuredValue() succeeded
}
else
{
// SetMeasuredValue() failed
}|
PR #43204: Size comparison from 3ba5c51 to 173848d Full report (20 builds for cc13x4_26x4, cc32xx, efr32, nrfconnect, nxp, psoc6, qpg, realtek, stm32)
|
|
|
||
| // update the temp attribute here for hardcoded endpoint 1 | ||
| chip::app::Clusters::TemperatureMeasurement::Attributes::MeasuredValue::Set(1, static_cast<int16_t>(n * 100)); | ||
| TEMPORARY_RETURN_IGNORED temperatureMeasurement->SetMeasuredValue(static_cast<int16_t>(n * 100)); |
There was a problem hiding this comment.
Maybe LogErrorOnFailure instead of temporary ignored? I would avoid adding new TEMPORARY_RETURN_IGNORED for new code.
|
PR #43204: Size comparison from c1553ce to 6b7957d Full report (31 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
|
|
PR #43204: Size comparison from c1553ce to 934d157 Increases above 0.2%:
Full report (33 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
|
|
PR #43204: Size comparison from 4d6f12f to 248baea Full report (34 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
|
| @@ -0,0 +1,24 @@ | |||
| # This cluster is currently following a code driven approach. | |||
|
|
|||
| # This means that the Accessors for the attribute MeasuredValue are no longer available. | |||
There was a problem hiding this comment.
Getter is still there, right? Just not setter. And getter will not get the "current" value, just the default one.
But if we stop getting it in CodegenIntegration, we could make the getter go away too, right?
| DataModel::Nullable<int16_t> measuredValue{}; | ||
| MeasuredValue::Get(endpointId, measuredValue); |
There was a problem hiding this comment.
I'm not sure it makes sense to have a ZAP-configured MeasuredValue... I think we should just start the cluster off with null until the app actually provides a measurement.
Summary
Decoupling temperature measurement cluster (code driven cluster implementation)
Related issues
Fixes #43113
Testing
Tested using chip-all-clusters-app and matter-repl.