Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ namespace {
std::unordered_map<EndpointId, LazyRegisteredServerCluster<TemperatureMeasurementCluster>> gServers;
} // namespace

namespace chip::app::Clusters::TemperatureMeasurement {

TemperatureMeasurementCluster * FindClusterOnEndpoint(EndpointId endpointId)
{
auto it = gServers.find(endpointId);
if (it == gServers.end() || !it->second.IsConstructed()) {
return nullptr;
}
return &it->second.Cluster();
}

CHIP_ERROR SetMeasuredValue(EndpointId endpointId, DataModel::Nullable<int16_t> measuredValue)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this helper really needed? I mean the end user can call FindClusterOnEndpoint() and then call cluster->SetMeasuredValue().

{
auto * cluster = FindClusterOnEndpoint(endpointId);
VerifyOrReturnError(cluster != nullptr, CHIP_ERROR_NOT_FOUND);
return cluster->SetMeasuredValue(measuredValue);
}

} // namespace chip::app::Clusters::TemperatureMeasurement

void ESPMatterTemperatureMeasurementClusterServerInitCallback(EndpointId endpointId)
{
VerifyOrReturn(cluster::get(endpointId, TemperatureMeasurement::Id) != nullptr,
Expand Down
Loading