419f6f93e19f5388e2c3096c7b2f3b20a8e5b90e
[platform/upstream/connectedhomeip.git] / examples / all-clusters-app / all-clusters-common / gen / IMClusterCommandHandler.cpp
1 /*
2  *
3  *    Copyright (c) 2021 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 // THIS FILE IS GENERATED BY ZAP
19
20 #include <cinttypes>
21 #include <cstdint>
22
23 #include "af-structs.h"
24 #include "call-command-handler.h"
25 #include "callback.h"
26 #include "cluster-id.h"
27 #include "command-id.h"
28 #include "util.h"
29
30 #include <app/InteractionModelEngine.h>
31
32 // Currently we need some work to keep compatible with ember lib.
33 #include <util/ember-compatibility-functions.h>
34
35 namespace chip {
36 namespace app {
37
38 // Cluster specific command parsing
39
40 namespace clusters {
41
42 namespace BarrierControl {
43
44 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
45 {
46     {
47         switch (commandId)
48         {
49         case ZCL_BARRIER_CONTROL_GO_TO_PERCENT_COMMAND_ID: {
50             CHIP_ERROR TLVError = CHIP_NO_ERROR;
51             uint8_t percentOpen;
52
53             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
54             {
55                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
56                 {
57                 case 0:
58                     TLVError = dataTlv.Get(percentOpen);
59                     break;
60                 default:
61                     // Unsupported tag, ignore it.
62                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
63                     break;
64                 }
65                 if (TLVError != CHIP_NO_ERROR)
66                 {
67                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
68                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
69                 }
70             }
71             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
72             emberAfBarrierControlClusterBarrierControlGoToPercentCallback(percentOpen);
73             break;
74         }
75         case ZCL_BARRIER_CONTROL_STOP_COMMAND_ID: {
76             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
77             emberAfBarrierControlClusterBarrierControlStopCallback();
78             break;
79         }
80         default: {
81             // Unrecognized command ID, error status will apply.
82             // TODO: Encode response for command not found
83             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_BARRIER_CONTROL_CLUSTER_ID);
84             break;
85         }
86         }
87     }
88 }
89
90 } // namespace BarrierControl
91
92 namespace Basic {
93
94 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
95 {
96     {
97         switch (commandId)
98         {
99         case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: {
100             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
101             emberAfBasicClusterResetToFactoryDefaultsCallback();
102             break;
103         }
104         default: {
105             // Unrecognized command ID, error status will apply.
106             // TODO: Encode response for command not found
107             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_BASIC_CLUSTER_ID);
108             break;
109         }
110         }
111     }
112 }
113
114 } // namespace Basic
115
116 namespace Binding {
117
118 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
119 {
120     {
121         switch (commandId)
122         {
123         case ZCL_BIND_COMMAND_ID: {
124             CHIP_ERROR TLVError = CHIP_NO_ERROR;
125             chip::NodeId nodeId;
126             chip::GroupId groupId;
127             chip::EndpointId endpointId;
128             chip::ClusterId clusterId;
129
130             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
131             {
132                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
133                 {
134                 case 0:
135                     TLVError = dataTlv.Get(nodeId);
136                     break;
137                 case 1:
138                     TLVError = dataTlv.Get(groupId);
139                     break;
140                 case 2:
141                     TLVError = dataTlv.Get(endpointId);
142                     break;
143                 case 3:
144                     TLVError = dataTlv.Get(clusterId);
145                     break;
146                 default:
147                     // Unsupported tag, ignore it.
148                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
149                     break;
150                 }
151                 if (TLVError != CHIP_NO_ERROR)
152                 {
153                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
154                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
155                 }
156             }
157             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
158             emberAfBindingClusterBindCallback(nodeId, groupId, endpointId, clusterId);
159             break;
160         }
161         case ZCL_UNBIND_COMMAND_ID: {
162             CHIP_ERROR TLVError = CHIP_NO_ERROR;
163             chip::NodeId nodeId;
164             chip::GroupId groupId;
165             chip::EndpointId endpointId;
166             chip::ClusterId clusterId;
167
168             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
169             {
170                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
171                 {
172                 case 0:
173                     TLVError = dataTlv.Get(nodeId);
174                     break;
175                 case 1:
176                     TLVError = dataTlv.Get(groupId);
177                     break;
178                 case 2:
179                     TLVError = dataTlv.Get(endpointId);
180                     break;
181                 case 3:
182                     TLVError = dataTlv.Get(clusterId);
183                     break;
184                 default:
185                     // Unsupported tag, ignore it.
186                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
187                     break;
188                 }
189                 if (TLVError != CHIP_NO_ERROR)
190                 {
191                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
192                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
193                 }
194             }
195             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
196             emberAfBindingClusterUnbindCallback(nodeId, groupId, endpointId, clusterId);
197             break;
198         }
199         default: {
200             // Unrecognized command ID, error status will apply.
201             // TODO: Encode response for command not found
202             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_BINDING_CLUSTER_ID);
203             break;
204         }
205         }
206     }
207 }
208
209 } // namespace Binding
210
211 namespace ColorControl {
212
213 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
214 {
215     {
216         switch (commandId)
217         {
218         case ZCL_MOVE_COLOR_COMMAND_ID: {
219             CHIP_ERROR TLVError = CHIP_NO_ERROR;
220             int16_t rateX;
221             int16_t rateY;
222             uint8_t optionsMask;
223             uint8_t optionsOverride;
224
225             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
226             {
227                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
228                 {
229                 case 0:
230                     TLVError = dataTlv.Get(rateX);
231                     break;
232                 case 1:
233                     TLVError = dataTlv.Get(rateY);
234                     break;
235                 case 2:
236                     TLVError = dataTlv.Get(optionsMask);
237                     break;
238                 case 3:
239                     TLVError = dataTlv.Get(optionsOverride);
240                     break;
241                 default:
242                     // Unsupported tag, ignore it.
243                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
244                     break;
245                 }
246                 if (TLVError != CHIP_NO_ERROR)
247                 {
248                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
249                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
250                 }
251             }
252             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
253             emberAfColorControlClusterMoveColorCallback(rateX, rateY, optionsMask, optionsOverride);
254             break;
255         }
256         case ZCL_MOVE_COLOR_TEMPERATURE_COMMAND_ID: {
257             CHIP_ERROR TLVError = CHIP_NO_ERROR;
258             uint8_t moveMode;
259             uint16_t rate;
260             uint16_t colorTemperatureMinimum;
261             uint16_t colorTemperatureMaximum;
262             uint8_t optionsMask;
263             uint8_t optionsOverride;
264
265             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
266             {
267                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
268                 {
269                 case 0:
270                     TLVError = dataTlv.Get(moveMode);
271                     break;
272                 case 1:
273                     TLVError = dataTlv.Get(rate);
274                     break;
275                 case 2:
276                     TLVError = dataTlv.Get(colorTemperatureMinimum);
277                     break;
278                 case 3:
279                     TLVError = dataTlv.Get(colorTemperatureMaximum);
280                     break;
281                 case 4:
282                     TLVError = dataTlv.Get(optionsMask);
283                     break;
284                 case 5:
285                     TLVError = dataTlv.Get(optionsOverride);
286                     break;
287                 default:
288                     // Unsupported tag, ignore it.
289                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
290                     break;
291                 }
292                 if (TLVError != CHIP_NO_ERROR)
293                 {
294                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
295                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
296                 }
297             }
298             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
299             emberAfColorControlClusterMoveColorTemperatureCallback(moveMode, rate, colorTemperatureMinimum, colorTemperatureMaximum,
300                                                                    optionsMask, optionsOverride);
301             break;
302         }
303         case ZCL_MOVE_HUE_COMMAND_ID: {
304             CHIP_ERROR TLVError = CHIP_NO_ERROR;
305             uint8_t moveMode;
306             uint8_t rate;
307             uint8_t optionsMask;
308             uint8_t optionsOverride;
309
310             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
311             {
312                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
313                 {
314                 case 0:
315                     TLVError = dataTlv.Get(moveMode);
316                     break;
317                 case 1:
318                     TLVError = dataTlv.Get(rate);
319                     break;
320                 case 2:
321                     TLVError = dataTlv.Get(optionsMask);
322                     break;
323                 case 3:
324                     TLVError = dataTlv.Get(optionsOverride);
325                     break;
326                 default:
327                     // Unsupported tag, ignore it.
328                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
329                     break;
330                 }
331                 if (TLVError != CHIP_NO_ERROR)
332                 {
333                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
334                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
335                 }
336             }
337             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
338             emberAfColorControlClusterMoveHueCallback(moveMode, rate, optionsMask, optionsOverride);
339             break;
340         }
341         case ZCL_MOVE_SATURATION_COMMAND_ID: {
342             CHIP_ERROR TLVError = CHIP_NO_ERROR;
343             uint8_t moveMode;
344             uint8_t rate;
345             uint8_t optionsMask;
346             uint8_t optionsOverride;
347
348             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
349             {
350                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
351                 {
352                 case 0:
353                     TLVError = dataTlv.Get(moveMode);
354                     break;
355                 case 1:
356                     TLVError = dataTlv.Get(rate);
357                     break;
358                 case 2:
359                     TLVError = dataTlv.Get(optionsMask);
360                     break;
361                 case 3:
362                     TLVError = dataTlv.Get(optionsOverride);
363                     break;
364                 default:
365                     // Unsupported tag, ignore it.
366                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
367                     break;
368                 }
369                 if (TLVError != CHIP_NO_ERROR)
370                 {
371                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
372                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
373                 }
374             }
375             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
376             emberAfColorControlClusterMoveSaturationCallback(moveMode, rate, optionsMask, optionsOverride);
377             break;
378         }
379         case ZCL_MOVE_TO_COLOR_COMMAND_ID: {
380             CHIP_ERROR TLVError = CHIP_NO_ERROR;
381             uint16_t colorX;
382             uint16_t colorY;
383             uint16_t transitionTime;
384             uint8_t optionsMask;
385             uint8_t optionsOverride;
386
387             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
388             {
389                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
390                 {
391                 case 0:
392                     TLVError = dataTlv.Get(colorX);
393                     break;
394                 case 1:
395                     TLVError = dataTlv.Get(colorY);
396                     break;
397                 case 2:
398                     TLVError = dataTlv.Get(transitionTime);
399                     break;
400                 case 3:
401                     TLVError = dataTlv.Get(optionsMask);
402                     break;
403                 case 4:
404                     TLVError = dataTlv.Get(optionsOverride);
405                     break;
406                 default:
407                     // Unsupported tag, ignore it.
408                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
409                     break;
410                 }
411                 if (TLVError != CHIP_NO_ERROR)
412                 {
413                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
414                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
415                 }
416             }
417             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
418             emberAfColorControlClusterMoveToColorCallback(colorX, colorY, transitionTime, optionsMask, optionsOverride);
419             break;
420         }
421         case ZCL_MOVE_TO_COLOR_TEMPERATURE_COMMAND_ID: {
422             CHIP_ERROR TLVError = CHIP_NO_ERROR;
423             uint16_t colorTemperature;
424             uint16_t transitionTime;
425             uint8_t optionsMask;
426             uint8_t optionsOverride;
427
428             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
429             {
430                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
431                 {
432                 case 0:
433                     TLVError = dataTlv.Get(colorTemperature);
434                     break;
435                 case 1:
436                     TLVError = dataTlv.Get(transitionTime);
437                     break;
438                 case 2:
439                     TLVError = dataTlv.Get(optionsMask);
440                     break;
441                 case 3:
442                     TLVError = dataTlv.Get(optionsOverride);
443                     break;
444                 default:
445                     // Unsupported tag, ignore it.
446                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
447                     break;
448                 }
449                 if (TLVError != CHIP_NO_ERROR)
450                 {
451                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
452                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
453                 }
454             }
455             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
456             emberAfColorControlClusterMoveToColorTemperatureCallback(colorTemperature, transitionTime, optionsMask,
457                                                                      optionsOverride);
458             break;
459         }
460         case ZCL_MOVE_TO_HUE_COMMAND_ID: {
461             CHIP_ERROR TLVError = CHIP_NO_ERROR;
462             uint8_t hue;
463             uint8_t direction;
464             uint16_t transitionTime;
465             uint8_t optionsMask;
466             uint8_t optionsOverride;
467
468             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
469             {
470                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
471                 {
472                 case 0:
473                     TLVError = dataTlv.Get(hue);
474                     break;
475                 case 1:
476                     TLVError = dataTlv.Get(direction);
477                     break;
478                 case 2:
479                     TLVError = dataTlv.Get(transitionTime);
480                     break;
481                 case 3:
482                     TLVError = dataTlv.Get(optionsMask);
483                     break;
484                 case 4:
485                     TLVError = dataTlv.Get(optionsOverride);
486                     break;
487                 default:
488                     // Unsupported tag, ignore it.
489                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
490                     break;
491                 }
492                 if (TLVError != CHIP_NO_ERROR)
493                 {
494                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
495                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
496                 }
497             }
498             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
499             emberAfColorControlClusterMoveToHueCallback(hue, direction, transitionTime, optionsMask, optionsOverride);
500             break;
501         }
502         case ZCL_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID: {
503             CHIP_ERROR TLVError = CHIP_NO_ERROR;
504             uint8_t hue;
505             uint8_t saturation;
506             uint16_t transitionTime;
507             uint8_t optionsMask;
508             uint8_t optionsOverride;
509
510             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
511             {
512                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
513                 {
514                 case 0:
515                     TLVError = dataTlv.Get(hue);
516                     break;
517                 case 1:
518                     TLVError = dataTlv.Get(saturation);
519                     break;
520                 case 2:
521                     TLVError = dataTlv.Get(transitionTime);
522                     break;
523                 case 3:
524                     TLVError = dataTlv.Get(optionsMask);
525                     break;
526                 case 4:
527                     TLVError = dataTlv.Get(optionsOverride);
528                     break;
529                 default:
530                     // Unsupported tag, ignore it.
531                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
532                     break;
533                 }
534                 if (TLVError != CHIP_NO_ERROR)
535                 {
536                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
537                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
538                 }
539             }
540             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
541             emberAfColorControlClusterMoveToHueAndSaturationCallback(hue, saturation, transitionTime, optionsMask, optionsOverride);
542             break;
543         }
544         case ZCL_MOVE_TO_SATURATION_COMMAND_ID: {
545             CHIP_ERROR TLVError = CHIP_NO_ERROR;
546             uint8_t saturation;
547             uint16_t transitionTime;
548             uint8_t optionsMask;
549             uint8_t optionsOverride;
550
551             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
552             {
553                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
554                 {
555                 case 0:
556                     TLVError = dataTlv.Get(saturation);
557                     break;
558                 case 1:
559                     TLVError = dataTlv.Get(transitionTime);
560                     break;
561                 case 2:
562                     TLVError = dataTlv.Get(optionsMask);
563                     break;
564                 case 3:
565                     TLVError = dataTlv.Get(optionsOverride);
566                     break;
567                 default:
568                     // Unsupported tag, ignore it.
569                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
570                     break;
571                 }
572                 if (TLVError != CHIP_NO_ERROR)
573                 {
574                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
575                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
576                 }
577             }
578             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
579             emberAfColorControlClusterMoveToSaturationCallback(saturation, transitionTime, optionsMask, optionsOverride);
580             break;
581         }
582         case ZCL_STEP_COLOR_COMMAND_ID: {
583             CHIP_ERROR TLVError = CHIP_NO_ERROR;
584             int16_t stepX;
585             int16_t stepY;
586             uint16_t transitionTime;
587             uint8_t optionsMask;
588             uint8_t optionsOverride;
589
590             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
591             {
592                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
593                 {
594                 case 0:
595                     TLVError = dataTlv.Get(stepX);
596                     break;
597                 case 1:
598                     TLVError = dataTlv.Get(stepY);
599                     break;
600                 case 2:
601                     TLVError = dataTlv.Get(transitionTime);
602                     break;
603                 case 3:
604                     TLVError = dataTlv.Get(optionsMask);
605                     break;
606                 case 4:
607                     TLVError = dataTlv.Get(optionsOverride);
608                     break;
609                 default:
610                     // Unsupported tag, ignore it.
611                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
612                     break;
613                 }
614                 if (TLVError != CHIP_NO_ERROR)
615                 {
616                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
617                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
618                 }
619             }
620             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
621             emberAfColorControlClusterStepColorCallback(stepX, stepY, transitionTime, optionsMask, optionsOverride);
622             break;
623         }
624         case ZCL_STEP_COLOR_TEMPERATURE_COMMAND_ID: {
625             CHIP_ERROR TLVError = CHIP_NO_ERROR;
626             uint8_t stepMode;
627             uint16_t stepSize;
628             uint16_t transitionTime;
629             uint16_t colorTemperatureMinimum;
630             uint16_t colorTemperatureMaximum;
631             uint8_t optionsMask;
632             uint8_t optionsOverride;
633
634             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
635             {
636                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
637                 {
638                 case 0:
639                     TLVError = dataTlv.Get(stepMode);
640                     break;
641                 case 1:
642                     TLVError = dataTlv.Get(stepSize);
643                     break;
644                 case 2:
645                     TLVError = dataTlv.Get(transitionTime);
646                     break;
647                 case 3:
648                     TLVError = dataTlv.Get(colorTemperatureMinimum);
649                     break;
650                 case 4:
651                     TLVError = dataTlv.Get(colorTemperatureMaximum);
652                     break;
653                 case 5:
654                     TLVError = dataTlv.Get(optionsMask);
655                     break;
656                 case 6:
657                     TLVError = dataTlv.Get(optionsOverride);
658                     break;
659                 default:
660                     // Unsupported tag, ignore it.
661                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
662                     break;
663                 }
664                 if (TLVError != CHIP_NO_ERROR)
665                 {
666                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
667                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
668                 }
669             }
670             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
671             emberAfColorControlClusterStepColorTemperatureCallback(stepMode, stepSize, transitionTime, colorTemperatureMinimum,
672                                                                    colorTemperatureMaximum, optionsMask, optionsOverride);
673             break;
674         }
675         case ZCL_STEP_HUE_COMMAND_ID: {
676             CHIP_ERROR TLVError = CHIP_NO_ERROR;
677             uint8_t stepMode;
678             uint8_t stepSize;
679             uint8_t transitionTime;
680             uint8_t optionsMask;
681             uint8_t optionsOverride;
682
683             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
684             {
685                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
686                 {
687                 case 0:
688                     TLVError = dataTlv.Get(stepMode);
689                     break;
690                 case 1:
691                     TLVError = dataTlv.Get(stepSize);
692                     break;
693                 case 2:
694                     TLVError = dataTlv.Get(transitionTime);
695                     break;
696                 case 3:
697                     TLVError = dataTlv.Get(optionsMask);
698                     break;
699                 case 4:
700                     TLVError = dataTlv.Get(optionsOverride);
701                     break;
702                 default:
703                     // Unsupported tag, ignore it.
704                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
705                     break;
706                 }
707                 if (TLVError != CHIP_NO_ERROR)
708                 {
709                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
710                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
711                 }
712             }
713             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
714             emberAfColorControlClusterStepHueCallback(stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
715             break;
716         }
717         case ZCL_STEP_SATURATION_COMMAND_ID: {
718             CHIP_ERROR TLVError = CHIP_NO_ERROR;
719             uint8_t stepMode;
720             uint8_t stepSize;
721             uint8_t transitionTime;
722             uint8_t optionsMask;
723             uint8_t optionsOverride;
724
725             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
726             {
727                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
728                 {
729                 case 0:
730                     TLVError = dataTlv.Get(stepMode);
731                     break;
732                 case 1:
733                     TLVError = dataTlv.Get(stepSize);
734                     break;
735                 case 2:
736                     TLVError = dataTlv.Get(transitionTime);
737                     break;
738                 case 3:
739                     TLVError = dataTlv.Get(optionsMask);
740                     break;
741                 case 4:
742                     TLVError = dataTlv.Get(optionsOverride);
743                     break;
744                 default:
745                     // Unsupported tag, ignore it.
746                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
747                     break;
748                 }
749                 if (TLVError != CHIP_NO_ERROR)
750                 {
751                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
752                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
753                 }
754             }
755             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
756             emberAfColorControlClusterStepSaturationCallback(stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
757             break;
758         }
759         case ZCL_STOP_MOVE_STEP_COMMAND_ID: {
760             CHIP_ERROR TLVError = CHIP_NO_ERROR;
761             uint8_t optionsMask;
762             uint8_t optionsOverride;
763
764             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
765             {
766                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
767                 {
768                 case 0:
769                     TLVError = dataTlv.Get(optionsMask);
770                     break;
771                 case 1:
772                     TLVError = dataTlv.Get(optionsOverride);
773                     break;
774                 default:
775                     // Unsupported tag, ignore it.
776                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
777                     break;
778                 }
779                 if (TLVError != CHIP_NO_ERROR)
780                 {
781                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
782                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
783                 }
784             }
785             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
786             emberAfColorControlClusterStopMoveStepCallback(optionsMask, optionsOverride);
787             break;
788         }
789         default: {
790             // Unrecognized command ID, error status will apply.
791             // TODO: Encode response for command not found
792             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_COLOR_CONTROL_CLUSTER_ID);
793             break;
794         }
795         }
796     }
797 }
798
799 } // namespace ColorControl
800
801 namespace ContentLaunch {
802
803 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
804 {
805     {
806         switch (commandId)
807         {
808         case ZCL_LAUNCH_CONTENT_COMMAND_ID: {
809             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
810             emberAfContentLaunchClusterLaunchContentCallback();
811             break;
812         }
813         case ZCL_LAUNCH_URL_COMMAND_ID: {
814             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
815             emberAfContentLaunchClusterLaunchURLCallback();
816             break;
817         }
818         default: {
819             // Unrecognized command ID, error status will apply.
820             // TODO: Encode response for command not found
821             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_CONTENT_LAUNCH_CLUSTER_ID);
822             break;
823         }
824         }
825     }
826 }
827
828 } // namespace ContentLaunch
829
830 namespace DoorLock {
831
832 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
833 {
834     {
835         switch (commandId)
836         {
837         case ZCL_CLEAR_ALL_PINS_COMMAND_ID: {
838             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
839             emberAfDoorLockClusterClearAllPinsCallback();
840             break;
841         }
842         case ZCL_CLEAR_ALL_RFIDS_COMMAND_ID: {
843             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
844             emberAfDoorLockClusterClearAllRfidsCallback();
845             break;
846         }
847         case ZCL_CLEAR_HOLIDAY_SCHEDULE_COMMAND_ID: {
848             CHIP_ERROR TLVError = CHIP_NO_ERROR;
849             uint8_t scheduleId;
850
851             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
852             {
853                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
854                 {
855                 case 0:
856                     TLVError = dataTlv.Get(scheduleId);
857                     break;
858                 default:
859                     // Unsupported tag, ignore it.
860                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
861                     break;
862                 }
863                 if (TLVError != CHIP_NO_ERROR)
864                 {
865                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
866                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
867                 }
868             }
869             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
870             emberAfDoorLockClusterClearHolidayScheduleCallback(scheduleId);
871             break;
872         }
873         case ZCL_CLEAR_PIN_COMMAND_ID: {
874             CHIP_ERROR TLVError = CHIP_NO_ERROR;
875             uint16_t userId;
876
877             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
878             {
879                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
880                 {
881                 case 0:
882                     TLVError = dataTlv.Get(userId);
883                     break;
884                 default:
885                     // Unsupported tag, ignore it.
886                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
887                     break;
888                 }
889                 if (TLVError != CHIP_NO_ERROR)
890                 {
891                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
892                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
893                 }
894             }
895             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
896             emberAfDoorLockClusterClearPinCallback(userId);
897             break;
898         }
899         case ZCL_CLEAR_RFID_COMMAND_ID: {
900             CHIP_ERROR TLVError = CHIP_NO_ERROR;
901             uint16_t userId;
902
903             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
904             {
905                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
906                 {
907                 case 0:
908                     TLVError = dataTlv.Get(userId);
909                     break;
910                 default:
911                     // Unsupported tag, ignore it.
912                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
913                     break;
914                 }
915                 if (TLVError != CHIP_NO_ERROR)
916                 {
917                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
918                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
919                 }
920             }
921             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
922             emberAfDoorLockClusterClearRfidCallback(userId);
923             break;
924         }
925         case ZCL_CLEAR_WEEKDAY_SCHEDULE_COMMAND_ID: {
926             CHIP_ERROR TLVError = CHIP_NO_ERROR;
927             uint8_t scheduleId;
928             uint16_t userId;
929
930             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
931             {
932                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
933                 {
934                 case 0:
935                     TLVError = dataTlv.Get(scheduleId);
936                     break;
937                 case 1:
938                     TLVError = dataTlv.Get(userId);
939                     break;
940                 default:
941                     // Unsupported tag, ignore it.
942                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
943                     break;
944                 }
945                 if (TLVError != CHIP_NO_ERROR)
946                 {
947                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
948                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
949                 }
950             }
951             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
952             emberAfDoorLockClusterClearWeekdayScheduleCallback(scheduleId, userId);
953             break;
954         }
955         case ZCL_CLEAR_YEARDAY_SCHEDULE_COMMAND_ID: {
956             CHIP_ERROR TLVError = CHIP_NO_ERROR;
957             uint8_t scheduleId;
958             uint16_t userId;
959
960             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
961             {
962                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
963                 {
964                 case 0:
965                     TLVError = dataTlv.Get(scheduleId);
966                     break;
967                 case 1:
968                     TLVError = dataTlv.Get(userId);
969                     break;
970                 default:
971                     // Unsupported tag, ignore it.
972                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
973                     break;
974                 }
975                 if (TLVError != CHIP_NO_ERROR)
976                 {
977                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
978                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
979                 }
980             }
981             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
982             emberAfDoorLockClusterClearYeardayScheduleCallback(scheduleId, userId);
983             break;
984         }
985         case ZCL_GET_HOLIDAY_SCHEDULE_COMMAND_ID: {
986             CHIP_ERROR TLVError = CHIP_NO_ERROR;
987             uint8_t scheduleId;
988
989             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
990             {
991                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
992                 {
993                 case 0:
994                     TLVError = dataTlv.Get(scheduleId);
995                     break;
996                 default:
997                     // Unsupported tag, ignore it.
998                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
999                     break;
1000                 }
1001                 if (TLVError != CHIP_NO_ERROR)
1002                 {
1003                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1004                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1005                 }
1006             }
1007             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1008             emberAfDoorLockClusterGetHolidayScheduleCallback(scheduleId);
1009             break;
1010         }
1011         case ZCL_GET_LOG_RECORD_COMMAND_ID: {
1012             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1013             uint16_t logIndex;
1014
1015             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1016             {
1017                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1018                 {
1019                 case 0:
1020                     TLVError = dataTlv.Get(logIndex);
1021                     break;
1022                 default:
1023                     // Unsupported tag, ignore it.
1024                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1025                     break;
1026                 }
1027                 if (TLVError != CHIP_NO_ERROR)
1028                 {
1029                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1030                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1031                 }
1032             }
1033             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1034             emberAfDoorLockClusterGetLogRecordCallback(logIndex);
1035             break;
1036         }
1037         case ZCL_GET_PIN_COMMAND_ID: {
1038             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1039             uint16_t userId;
1040
1041             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1042             {
1043                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1044                 {
1045                 case 0:
1046                     TLVError = dataTlv.Get(userId);
1047                     break;
1048                 default:
1049                     // Unsupported tag, ignore it.
1050                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1051                     break;
1052                 }
1053                 if (TLVError != CHIP_NO_ERROR)
1054                 {
1055                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1056                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1057                 }
1058             }
1059             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1060             emberAfDoorLockClusterGetPinCallback(userId);
1061             break;
1062         }
1063         case ZCL_GET_RFID_COMMAND_ID: {
1064             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1065             uint16_t userId;
1066
1067             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1068             {
1069                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1070                 {
1071                 case 0:
1072                     TLVError = dataTlv.Get(userId);
1073                     break;
1074                 default:
1075                     // Unsupported tag, ignore it.
1076                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1077                     break;
1078                 }
1079                 if (TLVError != CHIP_NO_ERROR)
1080                 {
1081                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1082                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1083                 }
1084             }
1085             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1086             emberAfDoorLockClusterGetRfidCallback(userId);
1087             break;
1088         }
1089         case ZCL_GET_USER_TYPE_COMMAND_ID: {
1090             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1091             uint16_t userId;
1092
1093             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1094             {
1095                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1096                 {
1097                 case 0:
1098                     TLVError = dataTlv.Get(userId);
1099                     break;
1100                 default:
1101                     // Unsupported tag, ignore it.
1102                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1103                     break;
1104                 }
1105                 if (TLVError != CHIP_NO_ERROR)
1106                 {
1107                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1108                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1109                 }
1110             }
1111             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1112             emberAfDoorLockClusterGetUserTypeCallback(userId);
1113             break;
1114         }
1115         case ZCL_GET_WEEKDAY_SCHEDULE_COMMAND_ID: {
1116             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1117             uint8_t scheduleId;
1118             uint16_t userId;
1119
1120             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1121             {
1122                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1123                 {
1124                 case 0:
1125                     TLVError = dataTlv.Get(scheduleId);
1126                     break;
1127                 case 1:
1128                     TLVError = dataTlv.Get(userId);
1129                     break;
1130                 default:
1131                     // Unsupported tag, ignore it.
1132                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1133                     break;
1134                 }
1135                 if (TLVError != CHIP_NO_ERROR)
1136                 {
1137                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1138                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1139                 }
1140             }
1141             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1142             emberAfDoorLockClusterGetWeekdayScheduleCallback(scheduleId, userId);
1143             break;
1144         }
1145         case ZCL_GET_YEARDAY_SCHEDULE_COMMAND_ID: {
1146             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1147             uint8_t scheduleId;
1148             uint16_t userId;
1149
1150             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1151             {
1152                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1153                 {
1154                 case 0:
1155                     TLVError = dataTlv.Get(scheduleId);
1156                     break;
1157                 case 1:
1158                     TLVError = dataTlv.Get(userId);
1159                     break;
1160                 default:
1161                     // Unsupported tag, ignore it.
1162                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1163                     break;
1164                 }
1165                 if (TLVError != CHIP_NO_ERROR)
1166                 {
1167                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1168                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1169                 }
1170             }
1171             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1172             emberAfDoorLockClusterGetYeardayScheduleCallback(scheduleId, userId);
1173             break;
1174         }
1175         case ZCL_LOCK_DOOR_COMMAND_ID: {
1176             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1177             const uint8_t * PIN;
1178
1179             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1180             {
1181                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1182                 {
1183                 case 0:
1184                     TLVError = dataTlv.GetDataPtr(PIN);
1185                     break;
1186                 default:
1187                     // Unsupported tag, ignore it.
1188                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1189                     break;
1190                 }
1191                 if (TLVError != CHIP_NO_ERROR)
1192                 {
1193                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1194                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1195                 }
1196             }
1197             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1198             emberAfDoorLockClusterLockDoorCallback(const_cast<uint8_t *>(PIN));
1199             break;
1200         }
1201         case ZCL_SET_HOLIDAY_SCHEDULE_COMMAND_ID: {
1202             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1203             uint8_t scheduleId;
1204             uint32_t localStartTime;
1205             uint32_t localEndTime;
1206             uint8_t operatingModeDuringHoliday;
1207
1208             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1209             {
1210                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1211                 {
1212                 case 0:
1213                     TLVError = dataTlv.Get(scheduleId);
1214                     break;
1215                 case 1:
1216                     TLVError = dataTlv.Get(localStartTime);
1217                     break;
1218                 case 2:
1219                     TLVError = dataTlv.Get(localEndTime);
1220                     break;
1221                 case 3:
1222                     TLVError = dataTlv.Get(operatingModeDuringHoliday);
1223                     break;
1224                 default:
1225                     // Unsupported tag, ignore it.
1226                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1227                     break;
1228                 }
1229                 if (TLVError != CHIP_NO_ERROR)
1230                 {
1231                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1232                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1233                 }
1234             }
1235             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1236             emberAfDoorLockClusterSetHolidayScheduleCallback(scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday);
1237             break;
1238         }
1239         case ZCL_SET_PIN_COMMAND_ID: {
1240             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1241             uint16_t userId;
1242             uint8_t userStatus;
1243             uint8_t userType;
1244             const uint8_t * pin;
1245
1246             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1247             {
1248                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1249                 {
1250                 case 0:
1251                     TLVError = dataTlv.Get(userId);
1252                     break;
1253                 case 1:
1254                     TLVError = dataTlv.Get(userStatus);
1255                     break;
1256                 case 2:
1257                     TLVError = dataTlv.Get(userType);
1258                     break;
1259                 case 3:
1260                     TLVError = dataTlv.GetDataPtr(pin);
1261                     break;
1262                 default:
1263                     // Unsupported tag, ignore it.
1264                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1265                     break;
1266                 }
1267                 if (TLVError != CHIP_NO_ERROR)
1268                 {
1269                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1270                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1271                 }
1272             }
1273             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1274             emberAfDoorLockClusterSetPinCallback(userId, userStatus, userType, const_cast<uint8_t *>(pin));
1275             break;
1276         }
1277         case ZCL_SET_RFID_COMMAND_ID: {
1278             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1279             uint16_t userId;
1280             uint8_t userStatus;
1281             uint8_t userType;
1282             const uint8_t * id;
1283
1284             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1285             {
1286                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1287                 {
1288                 case 0:
1289                     TLVError = dataTlv.Get(userId);
1290                     break;
1291                 case 1:
1292                     TLVError = dataTlv.Get(userStatus);
1293                     break;
1294                 case 2:
1295                     TLVError = dataTlv.Get(userType);
1296                     break;
1297                 case 3:
1298                     TLVError = dataTlv.GetDataPtr(id);
1299                     break;
1300                 default:
1301                     // Unsupported tag, ignore it.
1302                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1303                     break;
1304                 }
1305                 if (TLVError != CHIP_NO_ERROR)
1306                 {
1307                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1308                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1309                 }
1310             }
1311             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1312             emberAfDoorLockClusterSetRfidCallback(userId, userStatus, userType, const_cast<uint8_t *>(id));
1313             break;
1314         }
1315         case ZCL_SET_USER_TYPE_COMMAND_ID: {
1316             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1317             uint16_t userId;
1318             uint8_t userType;
1319
1320             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1321             {
1322                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1323                 {
1324                 case 0:
1325                     TLVError = dataTlv.Get(userId);
1326                     break;
1327                 case 1:
1328                     TLVError = dataTlv.Get(userType);
1329                     break;
1330                 default:
1331                     // Unsupported tag, ignore it.
1332                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1333                     break;
1334                 }
1335                 if (TLVError != CHIP_NO_ERROR)
1336                 {
1337                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1338                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1339                 }
1340             }
1341             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1342             emberAfDoorLockClusterSetUserTypeCallback(userId, userType);
1343             break;
1344         }
1345         case ZCL_SET_WEEKDAY_SCHEDULE_COMMAND_ID: {
1346             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1347             uint8_t scheduleId;
1348             uint16_t userId;
1349             uint8_t daysMask;
1350             uint8_t startHour;
1351             uint8_t startMinute;
1352             uint8_t endHour;
1353             uint8_t endMinute;
1354
1355             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1356             {
1357                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1358                 {
1359                 case 0:
1360                     TLVError = dataTlv.Get(scheduleId);
1361                     break;
1362                 case 1:
1363                     TLVError = dataTlv.Get(userId);
1364                     break;
1365                 case 2:
1366                     TLVError = dataTlv.Get(daysMask);
1367                     break;
1368                 case 3:
1369                     TLVError = dataTlv.Get(startHour);
1370                     break;
1371                 case 4:
1372                     TLVError = dataTlv.Get(startMinute);
1373                     break;
1374                 case 5:
1375                     TLVError = dataTlv.Get(endHour);
1376                     break;
1377                 case 6:
1378                     TLVError = dataTlv.Get(endMinute);
1379                     break;
1380                 default:
1381                     // Unsupported tag, ignore it.
1382                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1383                     break;
1384                 }
1385                 if (TLVError != CHIP_NO_ERROR)
1386                 {
1387                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1388                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1389                 }
1390             }
1391             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1392             emberAfDoorLockClusterSetWeekdayScheduleCallback(scheduleId, userId, daysMask, startHour, startMinute, endHour,
1393                                                              endMinute);
1394             break;
1395         }
1396         case ZCL_SET_YEARDAY_SCHEDULE_COMMAND_ID: {
1397             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1398             uint8_t scheduleId;
1399             uint16_t userId;
1400             uint32_t localStartTime;
1401             uint32_t localEndTime;
1402
1403             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1404             {
1405                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1406                 {
1407                 case 0:
1408                     TLVError = dataTlv.Get(scheduleId);
1409                     break;
1410                 case 1:
1411                     TLVError = dataTlv.Get(userId);
1412                     break;
1413                 case 2:
1414                     TLVError = dataTlv.Get(localStartTime);
1415                     break;
1416                 case 3:
1417                     TLVError = dataTlv.Get(localEndTime);
1418                     break;
1419                 default:
1420                     // Unsupported tag, ignore it.
1421                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1422                     break;
1423                 }
1424                 if (TLVError != CHIP_NO_ERROR)
1425                 {
1426                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1427                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1428                 }
1429             }
1430             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1431             emberAfDoorLockClusterSetYeardayScheduleCallback(scheduleId, userId, localStartTime, localEndTime);
1432             break;
1433         }
1434         case ZCL_UNLOCK_DOOR_COMMAND_ID: {
1435             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1436             const uint8_t * PIN;
1437
1438             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1439             {
1440                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1441                 {
1442                 case 0:
1443                     TLVError = dataTlv.GetDataPtr(PIN);
1444                     break;
1445                 default:
1446                     // Unsupported tag, ignore it.
1447                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1448                     break;
1449                 }
1450                 if (TLVError != CHIP_NO_ERROR)
1451                 {
1452                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1453                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1454                 }
1455             }
1456             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1457             emberAfDoorLockClusterUnlockDoorCallback(const_cast<uint8_t *>(PIN));
1458             break;
1459         }
1460         case ZCL_UNLOCK_WITH_TIMEOUT_COMMAND_ID: {
1461             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1462             uint16_t timeoutInSeconds;
1463             const uint8_t * pin;
1464
1465             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1466             {
1467                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1468                 {
1469                 case 0:
1470                     TLVError = dataTlv.Get(timeoutInSeconds);
1471                     break;
1472                 case 1:
1473                     TLVError = dataTlv.GetDataPtr(pin);
1474                     break;
1475                 default:
1476                     // Unsupported tag, ignore it.
1477                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1478                     break;
1479                 }
1480                 if (TLVError != CHIP_NO_ERROR)
1481                 {
1482                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1483                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1484                 }
1485             }
1486             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1487             emberAfDoorLockClusterUnlockWithTimeoutCallback(timeoutInSeconds, const_cast<uint8_t *>(pin));
1488             break;
1489         }
1490         default: {
1491             // Unrecognized command ID, error status will apply.
1492             // TODO: Encode response for command not found
1493             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_DOOR_LOCK_CLUSTER_ID);
1494             break;
1495         }
1496         }
1497     }
1498 }
1499
1500 } // namespace DoorLock
1501
1502 namespace GeneralCommissioning {
1503
1504 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
1505 {
1506     {
1507         switch (commandId)
1508         {
1509         case ZCL_ARM_FAIL_SAFE_COMMAND_ID: {
1510             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1511             uint16_t expiryLengthSeconds;
1512             uint64_t breadcrumb;
1513             uint32_t timeoutMs;
1514
1515             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1516             {
1517                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1518                 {
1519                 case 0:
1520                     TLVError = dataTlv.Get(expiryLengthSeconds);
1521                     break;
1522                 case 1:
1523                     TLVError = dataTlv.Get(breadcrumb);
1524                     break;
1525                 case 2:
1526                     TLVError = dataTlv.Get(timeoutMs);
1527                     break;
1528                 default:
1529                     // Unsupported tag, ignore it.
1530                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1531                     break;
1532                 }
1533                 if (TLVError != CHIP_NO_ERROR)
1534                 {
1535                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1536                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1537                 }
1538             }
1539             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1540             emberAfGeneralCommissioningClusterArmFailSafeCallback(expiryLengthSeconds, breadcrumb, timeoutMs);
1541             break;
1542         }
1543         case ZCL_COMMISSIONING_COMPLETE_COMMAND_ID: {
1544             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1545             emberAfGeneralCommissioningClusterCommissioningCompleteCallback();
1546             break;
1547         }
1548         case ZCL_SET_FABRIC_COMMAND_ID: {
1549             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1550             const uint8_t * fabricId;
1551             const uint8_t * fabricSecret;
1552             uint64_t breadcrumb;
1553             uint32_t timeoutMs;
1554
1555             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1556             {
1557                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1558                 {
1559                 case 0:
1560                     TLVError = dataTlv.GetDataPtr(fabricId);
1561                     break;
1562                 case 1:
1563                     TLVError = dataTlv.GetDataPtr(fabricSecret);
1564                     break;
1565                 case 2:
1566                     TLVError = dataTlv.Get(breadcrumb);
1567                     break;
1568                 case 3:
1569                     TLVError = dataTlv.Get(timeoutMs);
1570                     break;
1571                 default:
1572                     // Unsupported tag, ignore it.
1573                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1574                     break;
1575                 }
1576                 if (TLVError != CHIP_NO_ERROR)
1577                 {
1578                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1579                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1580                 }
1581             }
1582             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1583             emberAfGeneralCommissioningClusterSetFabricCallback(const_cast<uint8_t *>(fabricId),
1584                                                                 const_cast<uint8_t *>(fabricSecret), breadcrumb, timeoutMs);
1585             break;
1586         }
1587         default: {
1588             // Unrecognized command ID, error status will apply.
1589             // TODO: Encode response for command not found
1590             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_GENERAL_COMMISSIONING_CLUSTER_ID);
1591             break;
1592         }
1593         }
1594     }
1595 }
1596
1597 } // namespace GeneralCommissioning
1598
1599 namespace Groups {
1600
1601 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
1602 {
1603     {
1604         switch (commandId)
1605         {
1606         case ZCL_ADD_GROUP_COMMAND_ID: {
1607             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1608             uint16_t groupId;
1609             const uint8_t * groupName;
1610
1611             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1612             {
1613                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1614                 {
1615                 case 0:
1616                     TLVError = dataTlv.Get(groupId);
1617                     break;
1618                 case 1:
1619                     TLVError = dataTlv.GetDataPtr(groupName);
1620                     break;
1621                 default:
1622                     // Unsupported tag, ignore it.
1623                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1624                     break;
1625                 }
1626                 if (TLVError != CHIP_NO_ERROR)
1627                 {
1628                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1629                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1630                 }
1631             }
1632             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1633             emberAfGroupsClusterAddGroupCallback(groupId, const_cast<uint8_t *>(groupName));
1634             break;
1635         }
1636         case ZCL_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID: {
1637             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1638             uint16_t groupId;
1639             const uint8_t * groupName;
1640
1641             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1642             {
1643                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1644                 {
1645                 case 0:
1646                     TLVError = dataTlv.Get(groupId);
1647                     break;
1648                 case 1:
1649                     TLVError = dataTlv.GetDataPtr(groupName);
1650                     break;
1651                 default:
1652                     // Unsupported tag, ignore it.
1653                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1654                     break;
1655                 }
1656                 if (TLVError != CHIP_NO_ERROR)
1657                 {
1658                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1659                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1660                 }
1661             }
1662             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1663             emberAfGroupsClusterAddGroupIfIdentifyingCallback(groupId, const_cast<uint8_t *>(groupName));
1664             break;
1665         }
1666         case ZCL_GET_GROUP_MEMBERSHIP_COMMAND_ID: {
1667             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1668             uint8_t groupCount;
1669             /* TYPE WARNING: array array defaults to */ uint8_t * groupList;
1670
1671             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1672             {
1673                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1674                 {
1675                 case 0:
1676                     TLVError = dataTlv.Get(groupCount);
1677                     break;
1678                 case 1:
1679                     // Just for compatibility, we will add array type support in IM later.
1680                     TLVError = dataTlv.GetDataPtr(const_cast<const uint8_t *&>(groupList));
1681                     break;
1682                 default:
1683                     // Unsupported tag, ignore it.
1684                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1685                     break;
1686                 }
1687                 if (TLVError != CHIP_NO_ERROR)
1688                 {
1689                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1690                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1691                 }
1692             }
1693             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1694             emberAfGroupsClusterGetGroupMembershipCallback(groupCount, groupList);
1695             break;
1696         }
1697         case ZCL_REMOVE_ALL_GROUPS_COMMAND_ID: {
1698             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1699             emberAfGroupsClusterRemoveAllGroupsCallback();
1700             break;
1701         }
1702         case ZCL_REMOVE_GROUP_COMMAND_ID: {
1703             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1704             uint16_t groupId;
1705
1706             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1707             {
1708                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1709                 {
1710                 case 0:
1711                     TLVError = dataTlv.Get(groupId);
1712                     break;
1713                 default:
1714                     // Unsupported tag, ignore it.
1715                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1716                     break;
1717                 }
1718                 if (TLVError != CHIP_NO_ERROR)
1719                 {
1720                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1721                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1722                 }
1723             }
1724             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1725             emberAfGroupsClusterRemoveGroupCallback(groupId);
1726             break;
1727         }
1728         case ZCL_VIEW_GROUP_COMMAND_ID: {
1729             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1730             uint16_t groupId;
1731
1732             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1733             {
1734                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1735                 {
1736                 case 0:
1737                     TLVError = dataTlv.Get(groupId);
1738                     break;
1739                 default:
1740                     // Unsupported tag, ignore it.
1741                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1742                     break;
1743                 }
1744                 if (TLVError != CHIP_NO_ERROR)
1745                 {
1746                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1747                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1748                 }
1749             }
1750             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1751             emberAfGroupsClusterViewGroupCallback(groupId);
1752             break;
1753         }
1754         default: {
1755             // Unrecognized command ID, error status will apply.
1756             // TODO: Encode response for command not found
1757             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_GROUPS_CLUSTER_ID);
1758             break;
1759         }
1760         }
1761     }
1762 }
1763
1764 } // namespace Groups
1765
1766 namespace IasZone {
1767
1768 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
1769 {
1770     {
1771         switch (commandId)
1772         {
1773         case ZCL_ZONE_ENROLL_RESPONSE_COMMAND_ID: {
1774             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1775             uint8_t enrollResponseCode;
1776             uint8_t zoneId;
1777
1778             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1779             {
1780                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1781                 {
1782                 case 0:
1783                     TLVError = dataTlv.Get(enrollResponseCode);
1784                     break;
1785                 case 1:
1786                     TLVError = dataTlv.Get(zoneId);
1787                     break;
1788                 default:
1789                     // Unsupported tag, ignore it.
1790                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1791                     break;
1792                 }
1793                 if (TLVError != CHIP_NO_ERROR)
1794                 {
1795                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1796                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1797                 }
1798             }
1799             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1800             emberAfIasZoneClusterZoneEnrollResponseCallback(enrollResponseCode, zoneId);
1801             break;
1802         }
1803         default: {
1804             // Unrecognized command ID, error status will apply.
1805             // TODO: Encode response for command not found
1806             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_IAS_ZONE_CLUSTER_ID);
1807             break;
1808         }
1809         }
1810     }
1811 }
1812
1813 } // namespace IasZone
1814
1815 namespace Identify {
1816
1817 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
1818 {
1819     {
1820         switch (commandId)
1821         {
1822         case ZCL_IDENTIFY_COMMAND_ID: {
1823             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1824             uint16_t identifyTime;
1825
1826             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1827             {
1828                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1829                 {
1830                 case 0:
1831                     TLVError = dataTlv.Get(identifyTime);
1832                     break;
1833                 default:
1834                     // Unsupported tag, ignore it.
1835                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1836                     break;
1837                 }
1838                 if (TLVError != CHIP_NO_ERROR)
1839                 {
1840                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1841                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1842                 }
1843             }
1844             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1845             emberAfIdentifyClusterIdentifyCallback(identifyTime);
1846             break;
1847         }
1848         case ZCL_IDENTIFY_QUERY_COMMAND_ID: {
1849             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1850             emberAfIdentifyClusterIdentifyQueryCallback();
1851             break;
1852         }
1853         default: {
1854             // Unrecognized command ID, error status will apply.
1855             // TODO: Encode response for command not found
1856             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_IDENTIFY_CLUSTER_ID);
1857             break;
1858         }
1859         }
1860     }
1861 }
1862
1863 } // namespace Identify
1864
1865 namespace LevelControl {
1866
1867 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
1868 {
1869     {
1870         switch (commandId)
1871         {
1872         case ZCL_MOVE_COMMAND_ID: {
1873             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1874             uint8_t moveMode;
1875             uint8_t rate;
1876             uint8_t optionMask;
1877             uint8_t optionOverride;
1878
1879             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1880             {
1881                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1882                 {
1883                 case 0:
1884                     TLVError = dataTlv.Get(moveMode);
1885                     break;
1886                 case 1:
1887                     TLVError = dataTlv.Get(rate);
1888                     break;
1889                 case 2:
1890                     TLVError = dataTlv.Get(optionMask);
1891                     break;
1892                 case 3:
1893                     TLVError = dataTlv.Get(optionOverride);
1894                     break;
1895                 default:
1896                     // Unsupported tag, ignore it.
1897                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1898                     break;
1899                 }
1900                 if (TLVError != CHIP_NO_ERROR)
1901                 {
1902                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1903                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1904                 }
1905             }
1906             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1907             emberAfLevelControlClusterMoveCallback(moveMode, rate, optionMask, optionOverride);
1908             break;
1909         }
1910         case ZCL_MOVE_TO_LEVEL_COMMAND_ID: {
1911             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1912             uint8_t level;
1913             uint16_t transitionTime;
1914             uint8_t optionMask;
1915             uint8_t optionOverride;
1916
1917             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1918             {
1919                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1920                 {
1921                 case 0:
1922                     TLVError = dataTlv.Get(level);
1923                     break;
1924                 case 1:
1925                     TLVError = dataTlv.Get(transitionTime);
1926                     break;
1927                 case 2:
1928                     TLVError = dataTlv.Get(optionMask);
1929                     break;
1930                 case 3:
1931                     TLVError = dataTlv.Get(optionOverride);
1932                     break;
1933                 default:
1934                     // Unsupported tag, ignore it.
1935                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1936                     break;
1937                 }
1938                 if (TLVError != CHIP_NO_ERROR)
1939                 {
1940                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1941                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1942                 }
1943             }
1944             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1945             emberAfLevelControlClusterMoveToLevelCallback(level, transitionTime, optionMask, optionOverride);
1946             break;
1947         }
1948         case ZCL_MOVE_TO_LEVEL_WITH_ON_OFF_COMMAND_ID: {
1949             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1950             uint8_t level;
1951             uint16_t transitionTime;
1952
1953             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1954             {
1955                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1956                 {
1957                 case 0:
1958                     TLVError = dataTlv.Get(level);
1959                     break;
1960                 case 1:
1961                     TLVError = dataTlv.Get(transitionTime);
1962                     break;
1963                 default:
1964                     // Unsupported tag, ignore it.
1965                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1966                     break;
1967                 }
1968                 if (TLVError != CHIP_NO_ERROR)
1969                 {
1970                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1971                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1972                 }
1973             }
1974             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1975             emberAfLevelControlClusterMoveToLevelWithOnOffCallback(level, transitionTime);
1976             break;
1977         }
1978         case ZCL_MOVE_WITH_ON_OFF_COMMAND_ID: {
1979             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1980             uint8_t moveMode;
1981             uint8_t rate;
1982
1983             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1984             {
1985                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1986                 {
1987                 case 0:
1988                     TLVError = dataTlv.Get(moveMode);
1989                     break;
1990                 case 1:
1991                     TLVError = dataTlv.Get(rate);
1992                     break;
1993                 default:
1994                     // Unsupported tag, ignore it.
1995                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1996                     break;
1997                 }
1998                 if (TLVError != CHIP_NO_ERROR)
1999                 {
2000                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2001                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2002                 }
2003             }
2004             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2005             emberAfLevelControlClusterMoveWithOnOffCallback(moveMode, rate);
2006             break;
2007         }
2008         case ZCL_STEP_COMMAND_ID: {
2009             CHIP_ERROR TLVError = CHIP_NO_ERROR;
2010             uint8_t stepMode;
2011             uint8_t stepSize;
2012             uint16_t transitionTime;
2013             uint8_t optionMask;
2014             uint8_t optionOverride;
2015
2016             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
2017             {
2018                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
2019                 {
2020                 case 0:
2021                     TLVError = dataTlv.Get(stepMode);
2022                     break;
2023                 case 1:
2024                     TLVError = dataTlv.Get(stepSize);
2025                     break;
2026                 case 2:
2027                     TLVError = dataTlv.Get(transitionTime);
2028                     break;
2029                 case 3:
2030                     TLVError = dataTlv.Get(optionMask);
2031                     break;
2032                 case 4:
2033                     TLVError = dataTlv.Get(optionOverride);
2034                     break;
2035                 default:
2036                     // Unsupported tag, ignore it.
2037                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
2038                     break;
2039                 }
2040                 if (TLVError != CHIP_NO_ERROR)
2041                 {
2042                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2043                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2044                 }
2045             }
2046             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2047             emberAfLevelControlClusterStepCallback(stepMode, stepSize, transitionTime, optionMask, optionOverride);
2048             break;
2049         }
2050         case ZCL_STEP_WITH_ON_OFF_COMMAND_ID: {
2051             CHIP_ERROR TLVError = CHIP_NO_ERROR;
2052             uint8_t stepMode;
2053             uint8_t stepSize;
2054             uint16_t transitionTime;
2055
2056             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
2057             {
2058                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
2059                 {
2060                 case 0:
2061                     TLVError = dataTlv.Get(stepMode);
2062                     break;
2063                 case 1:
2064                     TLVError = dataTlv.Get(stepSize);
2065                     break;
2066                 case 2:
2067                     TLVError = dataTlv.Get(transitionTime);
2068                     break;
2069                 default:
2070                     // Unsupported tag, ignore it.
2071                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
2072                     break;
2073                 }
2074                 if (TLVError != CHIP_NO_ERROR)
2075                 {
2076                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2077                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2078                 }
2079             }
2080             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2081             emberAfLevelControlClusterStepWithOnOffCallback(stepMode, stepSize, transitionTime);
2082             break;
2083         }
2084         case ZCL_STOP_COMMAND_ID: {
2085             CHIP_ERROR TLVError = CHIP_NO_ERROR;
2086             uint8_t optionMask;
2087             uint8_t optionOverride;
2088
2089             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
2090             {
2091                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
2092                 {
2093                 case 0:
2094                     TLVError = dataTlv.Get(optionMask);
2095                     break;
2096                 case 1:
2097                     TLVError = dataTlv.Get(optionOverride);
2098                     break;
2099                 default:
2100                     // Unsupported tag, ignore it.
2101                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
2102                     break;
2103                 }
2104                 if (TLVError != CHIP_NO_ERROR)
2105                 {
2106                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2107                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2108                 }
2109             }
2110             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2111             emberAfLevelControlClusterStopCallback(optionMask, optionOverride);
2112             break;
2113         }
2114         case ZCL_STOP_WITH_ON_OFF_COMMAND_ID: {
2115             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2116             emberAfLevelControlClusterStopWithOnOffCallback();
2117             break;
2118         }
2119         default: {
2120             // Unrecognized command ID, error status will apply.
2121             // TODO: Encode response for command not found
2122             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_LEVEL_CONTROL_CLUSTER_ID);
2123             break;
2124         }
2125         }
2126     }
2127 }
2128
2129 } // namespace LevelControl
2130
2131 namespace LowPower {
2132
2133 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
2134 {
2135     {
2136         switch (commandId)
2137         {
2138         case ZCL_SLEEP_COMMAND_ID: {
2139             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2140             emberAfLowPowerClusterSleepCallback();
2141             break;
2142         }
2143         default: {
2144             // Unrecognized command ID, error status will apply.
2145             // TODO: Encode response for command not found
2146             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_LOW_POWER_CLUSTER_ID);
2147             break;
2148         }
2149         }
2150     }
2151 }
2152
2153 } // namespace LowPower
2154
2155 namespace MediaPlayback {
2156
2157 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
2158 {
2159     {
2160         switch (commandId)
2161         {
2162         case ZCL_FAST_FORWARD_REQUEST_COMMAND_ID: {
2163             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2164             emberAfMediaPlaybackClusterFastForwardRequestCallback();
2165             break;
2166         }
2167         case ZCL_NEXT_REQUEST_COMMAND_ID: {
2168             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2169             emberAfMediaPlaybackClusterNextRequestCallback();
2170             break;
2171         }
2172         case ZCL_PAUSE_REQUEST_COMMAND_ID: {
2173             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2174             emberAfMediaPlaybackClusterPauseRequestCallback();
2175             break;
2176         }
2177         case ZCL_PLAY_REQUEST_COMMAND_ID: {
2178             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2179             emberAfMediaPlaybackClusterPlayRequestCallback();
2180             break;
2181         }
2182         case ZCL_PREVIOUS_REQUEST_COMMAND_ID: {
2183             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2184             emberAfMediaPlaybackClusterPreviousRequestCallback();
2185             break;
2186         }
2187         case ZCL_REWIND_REQUEST_COMMAND_ID: {
2188             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2189             emberAfMediaPlaybackClusterRewindRequestCallback();
2190             break;
2191         }
2192         case ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID: {
2193             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2194             emberAfMediaPlaybackClusterSkipBackwardRequestCallback();
2195             break;
2196         }
2197         case ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID: {
2198             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2199             emberAfMediaPlaybackClusterSkipForwardRequestCallback();
2200             break;
2201         }
2202         case ZCL_START_OVER_REQUEST_COMMAND_ID: {
2203             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2204             emberAfMediaPlaybackClusterStartOverRequestCallback();
2205             break;
2206         }
2207         case ZCL_STOP_REQUEST_COMMAND_ID: {
2208             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2209             emberAfMediaPlaybackClusterStopRequestCallback();
2210             break;
2211         }
2212         default: {
2213             // Unrecognized command ID, error status will apply.
2214             // TODO: Encode response for command not found
2215             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_MEDIA_PLAYBACK_CLUSTER_ID);
2216             break;
2217         }
2218         }
2219     }
2220 }
2221
2222 } // namespace MediaPlayback
2223
2224 namespace OnOff {
2225
2226 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
2227 {
2228     {
2229         switch (commandId)
2230         {
2231         case ZCL_OFF_COMMAND_ID: {
2232             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2233             emberAfOnOffClusterOffCallback();
2234             break;
2235         }
2236         case ZCL_ON_COMMAND_ID: {
2237             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2238             emberAfOnOffClusterOnCallback();
2239             break;
2240         }
2241         case ZCL_TOGGLE_COMMAND_ID: {
2242             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2243             emberAfOnOffClusterToggleCallback();
2244             break;
2245         }
2246         default: {
2247             // Unrecognized command ID, error status will apply.
2248             // TODO: Encode response for command not found
2249             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_ON_OFF_CLUSTER_ID);
2250             break;
2251         }
2252         }
2253     }
2254 }
2255
2256 } // namespace OnOff
2257
2258 namespace Scenes {
2259
2260 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
2261 {
2262     {
2263         switch (commandId)
2264         {
2265         case ZCL_ADD_SCENE_COMMAND_ID: {
2266             CHIP_ERROR TLVError = CHIP_NO_ERROR;
2267             uint16_t groupId;
2268             uint8_t sceneId;
2269             uint16_t transitionTime;
2270             const uint8_t * sceneName;
2271             /* TYPE WARNING: array array defaults to */ uint8_t * extensionFieldSets;
2272
2273             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
2274             {
2275                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
2276                 {
2277                 case 0:
2278                     TLVError = dataTlv.Get(groupId);
2279                     break;
2280                 case 1:
2281                     TLVError = dataTlv.Get(sceneId);
2282                     break;
2283                 case 2:
2284                     TLVError = dataTlv.Get(transitionTime);
2285                     break;
2286                 case 3:
2287                     TLVError = dataTlv.GetDataPtr(sceneName);
2288                     break;
2289                 case 4:
2290                     // Just for compatibility, we will add array type support in IM later.
2291                     TLVError = dataTlv.GetDataPtr(const_cast<const uint8_t *&>(extensionFieldSets));
2292                     break;
2293                 default:
2294                     // Unsupported tag, ignore it.
2295                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
2296                     break;
2297                 }
2298                 if (TLVError != CHIP_NO_ERROR)
2299                 {
2300                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2301                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2302                 }
2303             }
2304             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2305             emberAfScenesClusterAddSceneCallback(groupId, sceneId, transitionTime, const_cast<uint8_t *>(sceneName),
2306                                                  extensionFieldSets);
2307             break;
2308         }
2309         case ZCL_GET_SCENE_MEMBERSHIP_COMMAND_ID: {
2310             CHIP_ERROR TLVError = CHIP_NO_ERROR;
2311             uint16_t groupId;
2312
2313             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
2314             {
2315                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
2316                 {
2317                 case 0:
2318                     TLVError = dataTlv.Get(groupId);
2319                     break;
2320                 default:
2321                     // Unsupported tag, ignore it.
2322                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
2323                     break;
2324                 }
2325                 if (TLVError != CHIP_NO_ERROR)
2326                 {
2327                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2328                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2329                 }
2330             }
2331             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2332             emberAfScenesClusterGetSceneMembershipCallback(groupId);
2333             break;
2334         }
2335         case ZCL_RECALL_SCENE_COMMAND_ID: {
2336             CHIP_ERROR TLVError = CHIP_NO_ERROR;
2337             uint16_t groupId;
2338             uint8_t sceneId;
2339             uint16_t transitionTime;
2340
2341             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
2342             {
2343                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
2344                 {
2345                 case 0:
2346                     TLVError = dataTlv.Get(groupId);
2347                     break;
2348                 case 1:
2349                     TLVError = dataTlv.Get(sceneId);
2350                     break;
2351                 case 2:
2352                     TLVError = dataTlv.Get(transitionTime);
2353                     break;
2354                 default:
2355                     // Unsupported tag, ignore it.
2356                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
2357                     break;
2358                 }
2359                 if (TLVError != CHIP_NO_ERROR)
2360                 {
2361                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2362                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2363                 }
2364             }
2365             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2366             emberAfScenesClusterRecallSceneCallback(groupId, sceneId, transitionTime);
2367             break;
2368         }
2369         case ZCL_REMOVE_ALL_SCENES_COMMAND_ID: {
2370             CHIP_ERROR TLVError = CHIP_NO_ERROR;
2371             uint16_t groupId;
2372
2373             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
2374             {
2375                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
2376                 {
2377                 case 0:
2378                     TLVError = dataTlv.Get(groupId);
2379                     break;
2380                 default:
2381                     // Unsupported tag, ignore it.
2382                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
2383                     break;
2384                 }
2385                 if (TLVError != CHIP_NO_ERROR)
2386                 {
2387                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2388                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2389                 }
2390             }
2391             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2392             emberAfScenesClusterRemoveAllScenesCallback(groupId);
2393             break;
2394         }
2395         case ZCL_REMOVE_SCENE_COMMAND_ID: {
2396             CHIP_ERROR TLVError = CHIP_NO_ERROR;
2397             uint16_t groupId;
2398             uint8_t sceneId;
2399
2400             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
2401             {
2402                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
2403                 {
2404                 case 0:
2405                     TLVError = dataTlv.Get(groupId);
2406                     break;
2407                 case 1:
2408                     TLVError = dataTlv.Get(sceneId);
2409                     break;
2410                 default:
2411                     // Unsupported tag, ignore it.
2412                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
2413                     break;
2414                 }
2415                 if (TLVError != CHIP_NO_ERROR)
2416                 {
2417                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2418                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2419                 }
2420             }
2421             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2422             emberAfScenesClusterRemoveSceneCallback(groupId, sceneId);
2423             break;
2424         }
2425         case ZCL_STORE_SCENE_COMMAND_ID: {
2426             CHIP_ERROR TLVError = CHIP_NO_ERROR;
2427             uint16_t groupId;
2428             uint8_t sceneId;
2429
2430             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
2431             {
2432                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
2433                 {
2434                 case 0:
2435                     TLVError = dataTlv.Get(groupId);
2436                     break;
2437                 case 1:
2438                     TLVError = dataTlv.Get(sceneId);
2439                     break;
2440                 default:
2441                     // Unsupported tag, ignore it.
2442                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
2443                     break;
2444                 }
2445                 if (TLVError != CHIP_NO_ERROR)
2446                 {
2447                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2448                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2449                 }
2450             }
2451             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2452             emberAfScenesClusterStoreSceneCallback(groupId, sceneId);
2453             break;
2454         }
2455         case ZCL_VIEW_SCENE_COMMAND_ID: {
2456             CHIP_ERROR TLVError = CHIP_NO_ERROR;
2457             uint16_t groupId;
2458             uint8_t sceneId;
2459
2460             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
2461             {
2462                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
2463                 {
2464                 case 0:
2465                     TLVError = dataTlv.Get(groupId);
2466                     break;
2467                 case 1:
2468                     TLVError = dataTlv.Get(sceneId);
2469                     break;
2470                 default:
2471                     // Unsupported tag, ignore it.
2472                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
2473                     break;
2474                 }
2475                 if (TLVError != CHIP_NO_ERROR)
2476                 {
2477                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
2478                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
2479                 }
2480             }
2481             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
2482             emberAfScenesClusterViewSceneCallback(groupId, sceneId);
2483             break;
2484         }
2485         default: {
2486             // Unrecognized command ID, error status will apply.
2487             // TODO: Encode response for command not found
2488             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_SCENES_CLUSTER_ID);
2489             break;
2490         }
2491         }
2492     }
2493 }
2494
2495 } // namespace Scenes
2496
2497 } // namespace clusters
2498
2499 void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId,
2500                                   chip::TLV::TLVReader & aReader, Command * apCommandObj)
2501 {
2502     ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId,
2503                   aEndPointId);
2504     Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId);
2505     switch (aClusterId)
2506     {
2507     case ZCL_BARRIER_CONTROL_CLUSTER_ID:
2508         clusters::BarrierControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2509         break;
2510     case ZCL_BASIC_CLUSTER_ID:
2511         clusters::Basic::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2512         break;
2513     case ZCL_BINDING_CLUSTER_ID:
2514         clusters::Binding::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2515         break;
2516     case ZCL_COLOR_CONTROL_CLUSTER_ID:
2517         clusters::ColorControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2518         break;
2519     case ZCL_CONTENT_LAUNCH_CLUSTER_ID:
2520         clusters::ContentLaunch::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2521         break;
2522     case ZCL_DOOR_LOCK_CLUSTER_ID:
2523         clusters::DoorLock::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2524         break;
2525     case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID:
2526         clusters::GeneralCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2527         break;
2528     case ZCL_GROUPS_CLUSTER_ID:
2529         clusters::Groups::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2530         break;
2531     case ZCL_IAS_ZONE_CLUSTER_ID:
2532         clusters::IasZone::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2533         break;
2534     case ZCL_IDENTIFY_CLUSTER_ID:
2535         clusters::Identify::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2536         break;
2537     case ZCL_LEVEL_CONTROL_CLUSTER_ID:
2538         clusters::LevelControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2539         break;
2540     case ZCL_LOW_POWER_CLUSTER_ID:
2541         clusters::LowPower::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2542         break;
2543     case ZCL_MEDIA_PLAYBACK_CLUSTER_ID:
2544         clusters::MediaPlayback::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2545         break;
2546     case ZCL_ON_OFF_CLUSTER_ID:
2547         clusters::OnOff::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2548         break;
2549     case ZCL_SCENES_CLUSTER_ID:
2550         clusters::Scenes::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
2551         break;
2552     default:
2553         // Unrecognized cluster ID, error status will apply.
2554         // TODO: Encode response for Cluster not found
2555         ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId);
2556         break;
2557     }
2558     Compatibility::ResetEmberAfObjects();
2559 }
2560
2561 } // namespace app
2562 } // namespace chip