28
28
#include < app/util/attribute-storage.h>
29
29
#include < lib/core/CHIPError.h>
30
30
#include < protocols/interaction_model/StatusCode.h>
31
+ #include < app/cluster-building-blocks/QuieterReporting.h>
31
32
32
33
namespace chip {
33
34
namespace app {
@@ -60,7 +61,6 @@ class Delegate
60
61
// ------------------------------------------------------------------
61
62
// Get attribute methods
62
63
virtual DataModel::Nullable<uint32_t > GetCountdownTime () = 0;
63
- virtual MainStateEnum GetMainState () = 0;
64
64
virtual DataModel::Nullable<Structs::OverallStateStruct::Type> GetOverallState () = 0;
65
65
virtual DataModel::Nullable<Structs::OverallTargetStruct::Type> GetOverallTarget () = 0;
66
66
virtual RestingProcedureEnum GetRestingProcedure () = 0;
@@ -91,9 +91,9 @@ enum class OptionalAttributes : uint32_t
91
91
class Instance : public AttributeAccessInterface , public CommandHandlerInterface
92
92
{
93
93
public:
94
- Instance (EndpointId aEndpointId, Delegate & aDelegate, Feature aFeature, OptionalAttributes aOptionalAttrs) :
94
+ Instance (EndpointId aEndpointId, Delegate & aDelegate, Feature aFeature, OptionalAttributes aOptionalAttrs, ClusterId aClusterId ) :
95
95
AttributeAccessInterface (MakeOptional(aEndpointId), Id), CommandHandlerInterface(MakeOptional(aEndpointId), Id),
96
- mDelegate (aDelegate), mFeature (aFeature), mOptionalAttrs (aOptionalAttrs)
96
+ mDelegate (aDelegate), mClusterId (aClusterId), mFeature (aFeature), mOptionalAttrs (aOptionalAttrs)
97
97
{
98
98
/* set the base class delegates endpointId */
99
99
mDelegate .SetEndpointId (aEndpointId);
@@ -105,11 +105,55 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface
105
105
106
106
bool HasFeature (Feature aFeature) const ;
107
107
bool SupportsOptAttr (OptionalAttributes aOptionalAttrs) const ;
108
+
109
+ // Attribute setters
110
+ /* *
111
+ * Set Main State.
112
+ * @param aMainState The Main state that should now be the current one.
113
+ * @return CHIP_NO_ERROR if set was successful.
114
+ */
115
+ CHIP_ERROR SetMainState (const MainStateEnum & aMainState);
116
+
117
+ // Attribute getters
118
+ /* *
119
+ * Get Main State.
120
+ * @return The Main State.
121
+ */
122
+ MainStateEnum GetMainState () const ;
123
+
124
+ /* *
125
+ * @brief Whenever application delegate wants to possibly report a new updated time,
126
+ * call this method. The `GetCountdownTime()` method will be called on the delegate.
127
+ */
128
+ void UpdateCountdownTimeFromDelegate () { UpdateCountdownTime (/* fromDelegate = */ true ); }
129
+
130
+ /* *
131
+ * This function returns true if the phase value given exists in the PhaseList attribute, otherwise it returns false.
132
+ */
133
+ bool IsSupportedState (MainStateEnum aMainState);
134
+
135
+ protected:
136
+ /* *
137
+ * Causes reporting/udpating of CountdownTime attribute from driver if sufficient changes have
138
+ * occurred (based on Q quality definition for operational state). Calls the Delegate::GetCountdownTime() method.
139
+ *
140
+ * @param fromDelegate true if the change notice was triggered by the delegate, false if internal to cluster logic.
141
+ */
142
+ void UpdateCountdownTime (bool fromDelegate);
143
+
144
+ /* *
145
+ * @brief Whenever the cluster logic thinks time should be updated, call this.
146
+ */
147
+ void UpdateCountdownTimeFromClusterLogic () { UpdateCountdownTime (/* fromDelegate=*/ false ); }
108
148
109
149
private:
110
150
Delegate & mDelegate ;
151
+ const ClusterId mClusterId ;
152
+
111
153
BitMask<Feature> mFeature ;
112
154
BitMask<OptionalAttributes> mOptionalAttrs ;
155
+ MainStateEnum mMainState ;
156
+ app::QuieterReportingAttribute<uint32_t > mCountdownTime { DataModel::NullNullable };
113
157
114
158
// AttributeAccessInterface
115
159
CHIP_ERROR Read (const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override ;
0 commit comments