8000 [Closures] Closure Control SecureState event generation code by sabollim-silabs · Pull Request #39899 · project-chip/connectedhomeip · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Closures] Closure Control SecureState event generation code #39899

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
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions examples/closure-app/closure-common/src/ClosureControlEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,25 @@ void ClosureControlEndpoint::UpdateCurrentStateFromTargetState()
overallCurrentState.Value().speed.SetValue(overallTargetState.Value().speed.Value());
}

bool isClosureInSecureState = true;

// First, check if the closure is fully closed and has positioning feature.
if (mLogic.GetConformance().FeatureMap().Has(Feature::kPositioning))
{
isClosureInSecureState &= overallCurrentState.Value().position.HasValue() &&
!overallCurrentState.Value().position.Value().IsNull() &&
overallCurrentState.Value().position.Value().Value() == CurrentPositionEnum::kFullyClosed;
}

// Next, check if motion latching is enabled and latch is true.
if (mLogic.GetConformance().FeatureMap().Has(Feature::kMotionLatching))
{
isClosureInSecureState &= overallCurrentState.Value().latch.HasValue() &&
!overallCurrentState.Value().latch.Value().IsNull() && overallCurrentState.Value().latch.Value().Value() == true;
}

overallCurrentState.Value().secureState.SetValue(MakeNullable(isClosureInSecureState));

mLogic.SetOverallCurrentState(overallCurrentState);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,29 @@ CHIP_ERROR ClusterLogic::SetOverallCurrentState(const DataModel::Nullable<Generi
// supported by the closure. If the Speed feature is not supported, return an error.
VerifyOrReturnError(mConformance.HasFeature(Feature::kPositioning) || mConformance.HasFeature(Feature::kMotionLatching),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);

if (!incomingOverallCurrentState.secureState.Value().IsNull())
{
// SecureStateChanged event SHALL be generated when the SecureState field in the OverallCurrentState attribute
// changes
if (mState.mOverallCurrentState.IsNull() || !mState.mOverallCurrentState.Value().secureState.HasValue() ||
mState.mOverallCurrentState.Value().secureState.Value().IsNull())
{
// As secureState field is not set in present current state and incoming current state has value, we generate
// the event
GenerateSecureStateChangedEvent(incomingOverallCurrentState.secureState.Value().Value());
}
else
{
// If the secureState field is set in both present and incoming current state, we generate the event only if the
// value has changed.
if (mState.mOverallCurrentState.Value().secureState.Value().Value() !=
incomingOverallCurrentState.secureState.Value().Value())
{
GenerateSecureStateChangedEvent(incomingOverallCurrentState.secureState.Value().Value());
}
}
}
}
}

Expand Down
Loading
0