Skip to content

Commit cea7fd8

Browse files
Fixes for the color control quiet reporting (project-chip#34820)
* MarkAttributeDirty::kYes instead of kIfChanged for QuietReporting to insure the value is reported. Fix Start Or End of transition Quiet report to only report if the attribute value changed since the last quiet report * apply same tweak for start/end of transition to the lvl control. * re-enable the disabled tc_cc_2_2 steps * Restyled by autopep8 * address comments --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 587665d commit cea7fd8

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

src/app/clusters/color-control-server/color-control-server.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -3113,15 +3113,15 @@ void ColorControlServer::levelControlColorTempChangeCommand(EndpointId endpoint)
31133113
* - When it changes from null to any other value and vice versa. (Implicit to the QuieterReportingAttribute class)
31143114
*
31153115
* The QuietReportAttribute class is updated with the new value and when the report conditions are met,
3116-
* this function will return MarkAttributeDirty::kIfChanged.
3116+
* this function will return MarkAttributeDirty::kYes.
31173117
* It is expected that the user will use this return value to trigger a reporting mechanism for the attribute with the new value
31183118
* (Which was updated in the quietReporter)
31193119
*
31203120
* @param quietReporter: The QuieterReportingAttribute<TYPE> object for the attribute to update.
31213121
* @param newValue: Value to update the attribute with
31223122
* @param isStartOrEndOfTransition: Boolean that indicatse whether the update is occurring at the start or end of a level transition
3123-
* @return MarkAttributeDirty::kIfChanged when the attribute must be maredk dirty and be reported. MarkAttributeDirty::kNo when it
3124-
* when it no report is needed.
3123+
* @return MarkAttributeDirty::kYes when the attribute must be marked dirty and be reported. MarkAttributeDirty::kNo when
3124+
* no report is needed.
31253125
*/
31263126
template <typename Q, typename V>
31273127
MarkAttributeDirty ColorControlServer::SetQuietReportAttribute(QuieterReportingAttribute<Q> & quietReporter, V newValue,
@@ -3132,7 +3132,7 @@ MarkAttributeDirty ColorControlServer::SetQuietReportAttribute(QuieterReportingA
31323132

31333133
if (isStartOrEndOfTransition)
31343134
{
3135-
// At the start or end of the movement/transition we must report
3135+
// At the start or end of the movement/transition we must report if the value changed
31363136
auto predicate = [](const typename QuieterReportingAttribute<Q>::SufficientChangePredicateCandidate &) -> bool {
31373137
return true;
31383138
};
@@ -3155,7 +3155,7 @@ MarkAttributeDirty ColorControlServer::SetQuietReportAttribute(QuieterReportingA
31553155
dirtyState = quietReporter.SetValue(newValue, now, predicate);
31563156
}
31573157

3158-
return (dirtyState == AttributeDirtyState::kMustReport) ? MarkAttributeDirty::kIfChanged : MarkAttributeDirty::kNo;
3158+
return (dirtyState == AttributeDirtyState::kMustReport) ? MarkAttributeDirty::kYes : MarkAttributeDirty::kNo;
31593159
}
31603160

31613161
/*
@@ -3180,7 +3180,7 @@ Status ColorControlServer::SetQuietReportRemainingTime(EndpointId endpoint, uint
31803180
// - kMarkDirtyOnIncrement : When the value increases.
31813181
if (quietRemainingTime[epIndex].SetValue(newRemainingTime, now) == AttributeDirtyState::kMustReport)
31823182
{
3183-
markDirty = MarkAttributeDirty::kIfChanged;
3183+
markDirty = MarkAttributeDirty::kYes;
31843184
}
31853185

31863186
return Attributes::RemainingTime::Set(endpoint, quietRemainingTime[epIndex].value().Value(), markDirty);

src/app/clusters/level-control/level-control.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static void writeRemainingTime(EndpointId endpoint, uint16_t remainingTimeMs)
545545
markDirty = MarkAttributeDirty::kYes;
546546
}
547547

548-
Attributes::RemainingTime::Set(endpoint, state->quietRemainingTime.value().ValueOr(0), markDirty);
548+
Attributes::RemainingTime::Set(endpoint, state->quietRemainingTime.value().Value(), markDirty);
549549
}
550550
#endif // IGNORE_LEVEL_CONTROL_CLUSTER_LEVEL_CONTROL_REMAINING_TIME
551551
}

src/python_testing/TC_CC_2_2.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ def accumulate_reports():
160160

161161
def check_report_counts(attr: ClusterObjects.ClusterAttributeDescriptor):
162162
count = sub_handler.attribute_report_counts[attr]
163-
# TODO: should be 12 - see issue #34646
164-
# asserts.assert_less_equal(count, 12, "More than 12 reports received")
163+
asserts.assert_less_equal(count, 12, "More than 12 reports received")
165164
asserts.assert_less_equal(count, gather_time, f"More than {gather_time} reports received")
166165

167166
self.step(9)
@@ -270,17 +269,16 @@ def check_report_counts(attr: ClusterObjects.ClusterAttributeDescriptor):
270269
time.sleep(20)
271270

272271
self.step(34)
273-
# TODO: Re-enable checks 34, 36 when #34643 is addressed
274272
logging.info(f'received reports: {sub_handler.attribute_reports[cc.Attributes.RemainingTime]}')
275-
# count = sub_handler.attribute_report_counts[cc.Attributes.RemainingTime]
276-
# asserts.assert_equal(count, 3, "Unexpected number of reports received")
273+
count = sub_handler.attribute_report_counts[cc.Attributes.RemainingTime]
274+
asserts.assert_equal(count, 3, "Unexpected number of reports received")
277275

278276
self.step(35)
279277
asserts.assert_equal(sub_handler.attribute_reports[cc.Attributes.RemainingTime][0].value, 100, "Unexpected first report")
280278

281279
self.step(36)
282-
# asserts.assert_almost_equal(
283-
# sub_handler.attribute_reports[cc.Attributes.RemainingTime][1].value, 0, delta=10, msg="Unexpected second report")
280+
asserts.assert_almost_equal(
281+
sub_handler.attribute_reports[cc.Attributes.RemainingTime][1].value, 150, delta=10, msg="Unexpected second report")
284282

285283
self.step(37)
286284
asserts.assert_equal(sub_handler.attribute_reports[cc.Attributes.RemainingTime][-1].value, 0, "Unexpected last report")

0 commit comments

Comments
 (0)