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