temperature_measurement: add FindClusterOnEndpoint and SetMeasuredVal… - #1816
temperature_measurement: add FindClusterOnEndpoint and SetMeasuredVal…#1816dietolive-tw wants to merge 1 commit into
Conversation
|
One thing missing before this can land: the PR only adds the symbols to integration.cpp, but all three sibling clusters ship a matching integration.h that publicly declares FindClusterOnEndpoint and SetMeasuredValue: Note: the upstream connectedhomeip/src/app/clusters/temperature-measurement-server/CodegenIntegration.h already declares these symbols, so app code already has a declaration available via that header — integration.h is not a blocker. The case for adding it is purely consistency with the sibling measurement clusters, which all ship a matching integration.h and #include "integration.h" first in their integration.cpp. Could you add temperature_measurement/integration.h mirroring flow_measurement/integration.h (just swap the type to TemperatureMeasurementCluster and the arg to Nullable<int16_t>)? Rest looks good to me. |
…ue wrappers The flow_measurement and relative_humidity_measurement integration.cpp files provide namespace-level FindClusterOnEndpoint() and SetMeasuredValue() wrappers so application code can write to codegen cluster storage directly (bypassing esp-matter attribute::update, which desyncs for non-writable attributes on codegen clusters — esp-matter storage vs codegen mMeasuredValue). temperature_measurement was missing these wrappers. Add them following the flow_measurement pattern so apps using TemperatureMeasurement can use SetMeasuredValue() the same way. Refs: pattern from clusters/flow_measurement/integration.cpp
6803bff to
3abe4c2
Compare
temperature_measurement: add FindClusterOnEndpoint and SetMeasuredValue wrappers
The flow_measurement and relative_humidity_measurement integration.cpp files provide namespace-level FindClusterOnEndpoint() and SetMeasuredValue() wrappers so application code can write to codegen cluster storage directly (bypassing esp-matter attribute::update, which desyncs for non-writable attributes on codegen clusters — esp-matter storage vs codegen mMeasuredValue).
temperature_measurement was missing these wrappers. Add them following the flow_measurement pattern so apps using TemperatureMeasurement can use SetMeasuredValue() the same way.
Refs: pattern from clusters/flow_measurement/integration.cpp
Description
temperature_measurementwas the only measurement cluster incomponents/esp_matter/data_model_provider/clusters/withoutnamespace-level
FindClusterOnEndpoint()andSetMeasuredValue()wrappers in its
integration.cpp.flow_measurementandrelative_humidity_measurementalready provide them.For codegen-backed clusters, writing a non-writable attribute via
esp_matter::attribute::update()desyncs the two stores: it writesthe esp-matter storage, but
ReadAttributereads from the codegenmMeasuredValue. Application code that wants to updateMeasuredValuemust call the codegenSetMeasuredValue()method onthe cluster instance.
The cluster instance is looked up via
FindClusterOnEndpoint(endpointId),which exists in
CodegenIntegration.h— but the matchingCodegenIntegration.cppis excluded from the esp-matter build byCMakeLists.txt(EXCLUDE_SRCS_LISTforCodegen*.cpp). The othermeasurement clusters solve this by re-declaring the wrapper in
integration.cpp(the file actually compiled).Without this wrapper, apps that call
TemperatureMeasurement::SetMeasuredValue()get a link error.Changes
components/esp_matter/data_model_provider/clusters/temperature_measurement/integration.cppFindClusterOnEndpoint(EndpointId)(matchesflow_measurementpattern)SetMeasuredValue(EndpointId, DataModel::Nullable<int16_t>)convenience wrapperRelated
components/esp_matter/data_model_provider/clusters/flow_measurement/integration.cppcomponents/esp_matter/data_model_provider/clusters/relative_humidity_measurement/integration.cppcomponents/esp_matter/data_model_provider/CMakeLists.txt(EXCLUDE_SRCS_LISTforCodegen*.cpp)Testing
flow_measurement/integration.cppandrelative_humidity_measurement/integration.cppexactly — no behaviorchange for apps that do not call the new wrappers.
TemperatureMeasurement::SetMeasuredValue(); without this wrapper the linkstep fails with an undefined reference to
FindClusterOnEndpoint(EndpointId), with it the link succeeds and theattribute reads back the value set via the codegen path.
Checklist
Before submitting a Pull Request, please ensure the following: