22
22
#include < app/ConcreteAttributePath.h>
23
23
#include < app/InteractionModelEngine.h>
24
24
#include < app/util/attribute-storage.h>
25
-
25
+
26
26
using namespace chip ;
27
27
using namespace chip ::app;
28
28
using namespace chip ::app::DataModel;
31
31
using namespace chip ::app::Clusters::ClosureControl::Attributes;
32
32
using namespace chip ::app::Clusters::ClosureControl::Commands;
33
33
using chip::Protocols::InteractionModel::Status;
34
-
34
+
35
35
namespace chip {
36
36
namespace app {
37
37
namespace Clusters {
38
38
namespace ClosureControl {
39
-
39
+
40
40
CHIP_ERROR Instance::Init ()
41
41
{
42
42
ReturnErrorOnFailure (CommandHandlerInterfaceRegistry::Instance ().RegisterCommandHandler (this ));
43
43
VerifyOrReturnError (AttributeAccessInterfaceRegistry::Instance ().Register (this ), CHIP_ERROR_INCORRECT_STATE);
44
-
44
+
45
45
return CHIP_NO_ERROR;
46
46
}
47
-
47
+
48
48
void Instance::Shutdown ()
49
49
{
50
50
CommandHandlerInterfaceRegistry::Instance ().UnregisterCommandHandler (this );
51
51
AttributeAccessInterfaceRegistry::Instance ().Unregister (this );
52
52
}
53
-
53
+
54
54
bool Instance::HasFeature (Feature aFeature) const
55
55
{
56
56
return mFeature .Has (aFeature);
57
57
}
58
-
58
+
59
59
bool Instance::SupportsOptAttr (OptionalAttributes aOptionalAttrs) const
60
60
{
61
61
return mOptionalAttrs .Has (aOptionalAttrs);
62
62
}
63
-
63
+
64
64
// AttributeAccessInterface
65
65
CHIP_ERROR Instance::Read (const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder)
66
66
{
67
67
VerifyOrDie (aPath.mClusterId == ClosureControl::Id);
68
-
68
+
69
69
switch (aPath.mAttributeId )
70
70
{
71
71
case CountdownTime::Id:
72
72
if (SupportsOptAttr (OptionalAttributes::kCountdownTime ))
73
73
{
74
- return aEncoder.Encode (mDelegate .GetCountdownTime ());
74
+ return aEncoder.Encode (mDelegate .GetCountdownTime ());
75
75
}
76
76
return CHIP_IM_GLOBAL_STATUS (UnsupportedAttribute);
77
77
case MainState::Id:
120
120
/* Allow all other unhandled attributes to fall through to Ember */
121
121
return CHIP_NO_ERROR;
122
122
}
123
-
123
+
124
124
CHIP_ERROR Instance::EncodeCurrentErrorList (const AttributeValueEncoder::ListEncodeHelper & encoder)
125
125
{
126
126
CHIP_ERROR err = CHIP_NO_ERROR;
127
-
127
+
128
128
ReturnErrorOnFailure (mDelegate .StartCurrentErrorListRead ());
129
129
for (size_t i = 0 ; true ; i++)
130
130
{
131
131
ClosureErrorEnum error;
132
-
132
+
133
133
err = mDelegate .GetCurrentErrorListAtIndex (i, error);
134
134
if (err == CHIP_ERROR_PROVIDER_LIST_EXHAUSTED)
135
135
{
136
136
// Convert end of list to CHIP_NO_ERROR
137
137
err = CHIP_NO_ERROR;
138
138
goto exit ;
139
139
}
140
-
140
+
141
141
// Check if another error occurred before trying to encode
142
142
SuccessOrExit (err);
143
-
143
+
144
144
err = encoder.Encode (error);
145
145
SuccessOrExit (err);
146
146
}
147
-
147
+
148
148
exit :
149
149
// Tell the delegate the read is complete
150
150
err = mDelegate .EndCurrentErrorListRead ();
151
151
return err;
152
152
}
153
-
153
+
154
154
CHIP_ERROR Instance::Write (const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder)
155
155
{
156
156
switch (aPath.mAttributeId )
162
162
return CHIP_IM_GLOBAL_STATUS (UnsupportedAttribute);
163
163
}
164
164
}
165
-
165
+
166
166
// CommandHandlerInterface
167
167
void Instance::InvokeCommand (HandlerContext & handlerContext)
168
168
{
169
169
using namespace Commands ;
170
-
170
+
171
171
switch (handlerContext.mRequestPath .mCommandId )
172
172
{
173
173
case Stop::Id:
174
174
if (!HasFeature (Feature::kInstantaneous ))
175
175
{
176
176
HandleCommand<Stop::DecodableType>(
177
- handlerContext, [this ](HandlerContext & ctx, const auto & commandData) { HandleStop (ctx, commandData); });
177
+ handlerContext, [this ](HandlerContext & ctx, const auto & commandData) { HandleStop (ctx, commandData); });
178
178
}
179
179
else
180
180
{
220
220
return ;
221
221
}
222
222
}
223
-
223
+
224
224
void Instance::HandleStop (HandlerContext & ctx, const Commands::Stop::DecodableType & commandData)
225
225
{
226
226
// No parameters for this command
227
227
// Call the delegate
228
228
Status status = mDelegate .Stop ();
229
-
229
+
230
230
ctx.mCommandHandler .AddStatus (ctx.mRequestPath , status);
231
231
}
232
-
232
+
233
233
void Instance::HandleMoveTo (HandlerContext & ctx, const Commands::MoveTo::DecodableType & commandData)
234
234
{
235
235
const Optional<TagPositionEnum> tag = commandData.tag ;
236
236
const Optional<TagLatchEnum> latch = commandData.latch ;
237
237
const Optional<Globals::ThreeLevelAutoEnum> speed = commandData.speed ;
238
-
238
+
239
239
// Call the delegate
240
240
Status status = mDelegate .MoveTo (tag, latch, speed);
241
-
241
+
242
242
ctx.mCommandHandler .AddStatus (ctx.mRequestPath , status);
243
243
}
244
-
244
+
245
245
void Instance::HandleCalibrate (HandlerContext & ctx, const Commands::Calibrate::DecodableType & commandData)
246
246
{
247
247
// No parameters for this command
248
248
// Call the delegate
249
249
Status status = mDelegate .Calibrate ();
250
-
250
+
251
251
ctx.mCommandHandler .AddStatus (ctx.mRequestPath , status);
252
252
}
253
-
253
+
254
254
void Instance::HandleConfigureFallback (HandlerContext & ctx, const Commands::ConfigureFallback::DecodableType & commandData)
255
255
{
256
256
const Optional<RestingProcedureEnum> restingProcedure = commandData.restingProcedure ;
257
257
const Optional<TriggerConditionEnum> triggerCondition = commandData.triggerCondition ;
258
258
const Optional<TriggerPositionEnum> triggerPosition = commandData.triggerPosition ;
259
259
const Optional<uint32_t > waitingDelay = commandData.waitingDelay ;
260
-
260
+
261
261
// Call the delegate
262
262
Status status = mDelegate .ConfigureFallback (restingProcedure, triggerCondition, triggerPosition, waitingDelay);
263
-
263
+
264
264
ctx.mCommandHandler .AddStatus (ctx.mRequestPath , status);
265
265
}
266
-
266
+
267
267
void Instance::HandleCancelFallback (HandlerContext & ctx, const Commands::CancelFallback::DecodableType & commandData)
268
268
{
269
269
// No parameters for this command
270
270
// Call the delegate
271
271
Status status = mDelegate .CancelFallback ();
272
-
272
+
273
273
ctx.mCommandHandler .AddStatus (ctx.mRequestPath , status);
274
274
}
275
-
275
+
276
276
} // namespace ClosureControl
277
277
} // namespace Clusters
278
278
} // namespace app
279
279
} // namespace chip
280
-
280
+
281
281
// -----------------------------------------------------------------------------
282
282
// Plugin initialization
283
-
284
- void MatterClosureControlPluginServerInitCallback () {}
283
+
284
+ void MatterClosureControlPluginServerInitCallback () {}
0 commit comments