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