Skip to content
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

Add a way to force reporting when setting attr value in ember store. #34521

Merged
merged 1 commit into from
Jul 30, 2024
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
10 changes: 5 additions & 5 deletions src/app/clusters/level-control/level-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ static void reallyUpdateCoupledColorTemp(EndpointId endpoint)
/*
* @brief
* This function is used to update the current level attribute
* while respecting it's defined quiet reporting quality:
* while respecting its defined quiet reporting quality:
* The attribute will be reported:
* - At most once per second, or
* - At the start of the movement/transition, or
Expand All @@ -389,8 +389,7 @@ static Status SetCurrentLevelQuietReport(EndpointId endpoint, EmberAfLevelContro
DataModel::Nullable<uint8_t> newValue, bool isStartOrEndOfTransition)
{
AttributeDirtyState dirtyState;
MarkAttributeDirty markDirty = MarkAttributeDirty::kNo;
auto now = System::SystemClock().GetMonotonicTimestamp();
auto now = System::SystemClock().GetMonotonicTimestamp();

if (isStartOrEndOfTransition)
{
Expand All @@ -409,9 +408,10 @@ static Status SetCurrentLevelQuietReport(EndpointId endpoint, EmberAfLevelContro
dirtyState = state->quietCurrentLevel.SetValue(newValue, now, predicate);
}

MarkAttributeDirty markDirty = MarkAttributeDirty::kNo;
if (dirtyState == AttributeDirtyState::kMustReport)
{
markDirty = MarkAttributeDirty::kIfChanged;
markDirty = MarkAttributeDirty::kYes;
}
return Attributes::CurrentLevel::Set(endpoint, state->quietCurrentLevel.value(), markDirty);
}
Expand Down Expand Up @@ -545,7 +545,7 @@ static void writeRemainingTime(EndpointId endpoint, uint16_t remainingTimeMs)
// - kMarkDirtyOnIncrement : When the value increases.
if (state->quietRemainingTime.SetValue(remainingTimeDs, now) == AttributeDirtyState::kMustReport)
{
markDirty = MarkAttributeDirty::kIfChanged;
markDirty = MarkAttributeDirty::kYes;
}

Attributes::RemainingTime::Set(endpoint, state->quietRemainingTime.value().ValueOr(0), markDirty);
Expand Down
5 changes: 5 additions & 0 deletions src/app/util/af-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ enum class MarkAttributeDirty
{
kIfChanged,
kNo,
// kYes might need to be used if the attribute value was previously changed
// without reporting, and now is being set in a situation where we know
// reporting needs to be triggered (e.g. because QuieterReportingAttribute
// indicated that).
kYes,
};

} // namespace app
Expand Down
7 changes: 6 additions & 1 deletion src/app/util/attribute-table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,12 @@ Status emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId at

if (!valueChanging)
{
// Just do nothing.
// Just do nothing, except triggering reporting if forced.
if (markDirty == MarkAttributeDirty::kYes)
{
MatterReportingAttributeChangeCallback(endpoint, cluster, attributeID);
}

return Status::Success;
}

Expand Down
Loading