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