-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[Soil Measurement] Adds server implementation for soil measurement cluster #38606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mergify
merged 25 commits into
project-chip:master
from
ReneJosefsen:rjosefsen/soil-measurement-server-impl
May 27, 2025
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
96ebccf
Enable soil measurement in all-clusters zap
ReneJosefsen 78464f7
Enabled soil measurement in all clusters
ReneJosefsen 72713c5
Added soil sensor to matter-devices
ReneJosefsen 9af9edd
Initial server impl
ReneJosefsen 28ad016
Added all-clusters stub and reworked server impl
ReneJosefsen d3c9044
Added SetSoilMoistureMeasuredValue function
ReneJosefsen e9d3046
Added function to header file
ReneJosefsen dfb8e6c
Removed server handling of measured value and added allcluster comman…
ReneJosefsen e9b4f7a
Moved server to use global structs and enum
ReneJosefsen 6f8b482
Remove redundant check
ReneJosefsen b01ef81
Marked SoilMoistureMeasuredValue as external
ReneJosefsen 6f87666
Added handling for cluster rev and soilMoistureMeasuredValue in server
ReneJosefsen e9ad1ba
Apply suggestions from code review
ReneJosefsen 227b1c8
Reworked server implementation based on review feedback
ReneJosefsen 4d2e7e5
Added ClusterRevision to list of external
ReneJosefsen 9855892
Updated SetSoilMeasurementAccuracy comment
ReneJosefsen 8356661
Add server build files
ReneJosefsen 52da415
Remove unused includes and used metadata cluster revision
ReneJosefsen ae8e49e
zap regen all
ReneJosefsen 57dcb5b
Addressed some review comments
ReneJosefsen 9475c8c
Address additional review comments
ReneJosefsen 4c75865
Update src/app/clusters/soil-measurement-server/soil-measurement-serv…
ReneJosefsen f21673b
Addressed review feedback
ReneJosefsen 10d1803
Reworked SetSimulatedSoilMoisture handling
ReneJosefsen 568b595
Added check to only change and report on value changes and address re…
ReneJosefsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
examples/all-clusters-app/all-clusters-common/include/soil-measurement-stub.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* | ||
* Copyright (c) 2025 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <app/clusters/soil-measurement-server/soil-measurement-server.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
namespace Clusters { | ||
namespace SoilMeasurement { | ||
|
||
Instance * GetInstance(); | ||
|
||
void Shutdown(); | ||
|
||
} // namespace SoilMeasurement | ||
} // namespace Clusters | ||
} // namespace app | ||
} // namespace chip |
65 changes: 65 additions & 0 deletions
65
examples/all-clusters-app/all-clusters-common/src/soil-measurement-stub.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* | ||
* Copyright (c) 2025 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <soil-measurement-stub.h> | ||
|
||
using namespace chip; | ||
using namespace chip::app; | ||
using namespace chip::app::Clusters; | ||
using namespace chip::app::Clusters::SoilMeasurement; | ||
|
||
static const Globals::Structs::MeasurementAccuracyRangeStruct::Type kDefaultSoilMoistureMeasurementLimitsAccuracyRange[] = { | ||
{ .rangeMin = 0, .rangeMax = 100, .percentMax = MakeOptional(static_cast<chip::Percent100ths>(10)) } | ||
}; | ||
|
||
static const Globals::Structs::MeasurementAccuracyStruct::Type kDefaultSoilMoistureMeasurementLimits = { | ||
.measurementType = Globals::MeasurementTypeEnum::kSoilMoisture, | ||
.measured = true, | ||
.minMeasuredValue = 0, | ||
.maxMeasuredValue = 100, | ||
.accuracyRanges = DataModel::List<const Globals::Structs::MeasurementAccuracyRangeStruct::Type>( | ||
kDefaultSoilMoistureMeasurementLimitsAccuracyRange) | ||
}; | ||
|
||
namespace { | ||
static std::unique_ptr<Instance> gSoilMeasurementInstance; | ||
} // namespace | ||
|
||
Instance * SoilMeasurement::GetInstance() | ||
{ | ||
return gSoilMeasurementInstance.get(); | ||
} | ||
|
||
void SoilMeasurement::Shutdown() | ||
{ | ||
VerifyOrDie(gSoilMeasurementInstance); | ||
gSoilMeasurementInstance->Shutdown(); | ||
gSoilMeasurementInstance.reset(nullptr); | ||
} | ||
|
||
void emberAfSoilMeasurementClusterInitCallback(EndpointId endpointId) | ||
{ | ||
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1. | ||
ReneJosefsen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
VerifyOrDie(!gSoilMeasurementInstance); | ||
|
||
gSoilMeasurementInstance = std::make_unique<Instance>(endpointId); | ||
if (gSoilMeasurementInstance) | ||
{ | ||
gSoilMeasurementInstance->Init(kDefaultSoilMoistureMeasurementLimits); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) 2025 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
group("soil-measurement-server") { | ||
} |
21 changes: 21 additions & 0 deletions
21
src/app/clusters/soil-measurement-server/app_config_dependent_sources.cmake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (c) 2025 Project CHIP Authors | ||
ReneJosefsen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# This is the equivalent to app_config_dependent_sources.gni | ||
TARGET_SOURCES( | ||
${APP_TARGET} | ||
PRIVATE | ||
"${CLUSTER_DIR}/soil-measurement-server.cpp" | ||
"${CLUSTER_DIR}/soil-measurement-server.h" | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.