@@ -91,7 +91,28 @@ CHIP_ERROR Instance::SetMainState(const MainStateEnum & aMainState)
91
91
if (mMainState != oldMainState)
92
92
{
93
93
MatterReportingAttributeChangeCallback (mDelegate .GetEndpointId (), mClusterId , Attributes::MainState::Id);
94
- UpdateCountdownTimeFromClusterLogic ();
94
+ }
95
+ return CHIP_NO_ERROR;
96
+ }
97
+
98
+ CHIP_ERROR Instance::SetOverallState (const DataModel::Nullable<Structs::OverallStateStruct::Type> & aOverallState)
99
+ {
100
+ DataModel::Nullable<Structs::OverallStateStruct::Type> oldOverallState = mOverallState ;
101
+ mOverallState = aOverallState;
102
+ if (mOverallState != oldOverallState)
103
+ {
104
+ MatterReportingAttributeChangeCallback (mDelegate .GetEndpointId (), mClusterId , Attributes::OverallState::Id);
105
+ }
106
+ return CHIP_NO_ERROR;
107
+ }
108
+
109
+ CHIP_ERROR Instance::SetOverallTarget (const DataModel::Nullable<Structs::OverallTargetStruct::Type> & aOverallTarget)
110
+ {
111
+ DataModel::Nullable<Structs::OverallTargetStruct::Type> oldOverallTarget = mOverallTarget ;
112
+ mOverallTarget = aOverallTarget;
113
+ if (mOverallTarget != oldOverallTarget)
114
+ {
115
+ MatterReportingAttributeChangeCallback (mDelegate .GetEndpointId (), mClusterId , Attributes::OverallTarget::Id);
95
116
}
96
117
return CHIP_NO_ERROR;
97
118
}
@@ -101,6 +122,16 @@ MainStateEnum Instance::GetMainState() const
101
122
return mMainState ;
102
123
}
103
124
125
+ DataModel::Nullable<Structs::OverallStateStruct::Type> Instance::GetOverallState () const
126
+ {
127
+ return mOverallState ;
128
+ }
129
+
130
+ DataModel::Nullable<Structs::OverallTargetStruct::Type> Instance::GetOverallTarget () const
131
+ {
132
+ return mOverallTarget ;
133
+ }
134
+
104
135
void Instance::UpdateCountdownTime (bool fromDelegate)
105
136
{
106
137
app::DataModel::Nullable<uint32_t > newCountdownTime = mDelegate .GetCountdownTime ();
@@ -110,20 +141,11 @@ void Instance::UpdateCountdownTime(bool fromDelegate)
110
141
111
142
if (fromDelegate)
112
143
{
113
- // Updates from delegate are reduce-reported to every 10s max (choice of this implementation), in addition
144
+ // Updates from delegate are reduce-reported to every 1s max (choice of this implementation), in addition
114
145
// to default change-from-null, change-from-zero and increment policy.
115
- auto predicate = [](const decltype (mCountdownTime )::SufficientChangePredicateCandidate & candidate) -> bool {
116
- if (candidate.lastDirtyValue .IsNull () || candidate.newValue .IsNull ())
117
- {
118
- return false ;
119
- }
120
-
121
- uint32_t lastDirtyValue = candidate.lastDirtyValue .Value ();
122
- uint32_t newValue = candidate.newValue .Value ();
123
- uint32_t kNumSecondsDeltaToReport = 10 ;
124
- return (newValue < lastDirtyValue) && ((lastDirtyValue - newValue) > kNumSecondsDeltaToReport );
125
- };
126
- markDirty = (mCountdownTime .SetValue (newCountdownTime, now, predicate) == AttributeDirtyState::kMustReport );
146
+ System::Clock::Milliseconds64 reportInterval = System::Clock::Milliseconds64 (1000 );
147
+ auto predicate = mCountdownTime .GetPredicateForSufficientTimeSinceLastDirty (reportInterval);
148
+ markDirty = (mCountdownTime .SetValue (newCountdownTime, now, predicate) == AttributeDirtyState::kMustReport );
127
149
}
128
150
else
129
151
{
@@ -155,9 +177,9 @@ CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValu
155
177
case CurrentErrorList::Id:
156
178
return aEncoder.EncodeList ([this ](const auto & encoder) -> CHIP_ERROR { return this ->EncodeCurrentErrorList (encoder); });
157
179
case OverallState::Id:
158
- return aEncoder.Encode (mDelegate . GetOverallState ());
180
+ return aEncoder.Encode (GetOverallState ());
159
181
case OverallTarget::Id:
160
- return aEncoder.Encode (mDelegate . GetOverallTarget ());
182
+ return aEncoder.Encode (GetOverallTarget ());
161
183
case RestingProcedure::Id:
162
184
if (HasFeature (Feature::kFallback ))
163
185
{
0 commit comments