Apply Upstream code (2021-03-15)
[platform/upstream/connectedhomeip.git] / src / darwin / Framework / CHIP / 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 ContentLaunch {
43
44 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
45 {
46     {
47         switch (commandId)
48         {
49         case ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID: {
50             CHIP_ERROR TLVError = CHIP_NO_ERROR;
51             uint8_t contentLaunchStatus;
52
53             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
54             {
55                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
56                 {
57                 case 0:
58                     TLVError = dataTlv.Get(contentLaunchStatus);
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             emberAfContentLaunchClusterLaunchContentResponseCallback(contentLaunchStatus);
73             break;
74         }
75         case ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID: {
76             CHIP_ERROR TLVError = CHIP_NO_ERROR;
77             uint8_t contentLaunchStatus;
78
79             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
80             {
81                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
82                 {
83                 case 0:
84                     TLVError = dataTlv.Get(contentLaunchStatus);
85                     break;
86                 default:
87                     // Unsupported tag, ignore it.
88                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
89                     break;
90                 }
91                 if (TLVError != CHIP_NO_ERROR)
92                 {
93                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
94                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
95                 }
96             }
97             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
98             emberAfContentLaunchClusterLaunchURLResponseCallback(contentLaunchStatus);
99             break;
100         }
101         default: {
102             // Unrecognized command ID, error status will apply.
103             // TODO: Encode response for command not found
104             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_CONTENT_LAUNCH_CLUSTER_ID);
105             break;
106         }
107         }
108     }
109 }
110
111 } // namespace ContentLaunch
112
113 namespace DoorLock {
114
115 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
116 {
117     {
118         switch (commandId)
119         {
120         case ZCL_CLEAR_ALL_PINS_RESPONSE_COMMAND_ID: {
121             CHIP_ERROR TLVError = CHIP_NO_ERROR;
122             uint8_t status;
123
124             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
125             {
126                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
127                 {
128                 case 0:
129                     TLVError = dataTlv.Get(status);
130                     break;
131                 default:
132                     // Unsupported tag, ignore it.
133                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
134                     break;
135                 }
136                 if (TLVError != CHIP_NO_ERROR)
137                 {
138                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
139                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
140                 }
141             }
142             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
143             emberAfDoorLockClusterClearAllPinsResponseCallback(status);
144             break;
145         }
146         case ZCL_CLEAR_ALL_RFIDS_RESPONSE_COMMAND_ID: {
147             CHIP_ERROR TLVError = CHIP_NO_ERROR;
148             uint8_t status;
149
150             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
151             {
152                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
153                 {
154                 case 0:
155                     TLVError = dataTlv.Get(status);
156                     break;
157                 default:
158                     // Unsupported tag, ignore it.
159                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
160                     break;
161                 }
162                 if (TLVError != CHIP_NO_ERROR)
163                 {
164                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
165                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
166                 }
167             }
168             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
169             emberAfDoorLockClusterClearAllRfidsResponseCallback(status);
170             break;
171         }
172         case ZCL_CLEAR_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
173             CHIP_ERROR TLVError = CHIP_NO_ERROR;
174             uint8_t status;
175
176             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
177             {
178                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
179                 {
180                 case 0:
181                     TLVError = dataTlv.Get(status);
182                     break;
183                 default:
184                     // Unsupported tag, ignore it.
185                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
186                     break;
187                 }
188                 if (TLVError != CHIP_NO_ERROR)
189                 {
190                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
191                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
192                 }
193             }
194             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
195             emberAfDoorLockClusterClearHolidayScheduleResponseCallback(status);
196             break;
197         }
198         case ZCL_CLEAR_PIN_RESPONSE_COMMAND_ID: {
199             CHIP_ERROR TLVError = CHIP_NO_ERROR;
200             uint8_t status;
201
202             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
203             {
204                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
205                 {
206                 case 0:
207                     TLVError = dataTlv.Get(status);
208                     break;
209                 default:
210                     // Unsupported tag, ignore it.
211                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
212                     break;
213                 }
214                 if (TLVError != CHIP_NO_ERROR)
215                 {
216                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
217                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
218                 }
219             }
220             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
221             emberAfDoorLockClusterClearPinResponseCallback(status);
222             break;
223         }
224         case ZCL_CLEAR_RFID_RESPONSE_COMMAND_ID: {
225             CHIP_ERROR TLVError = CHIP_NO_ERROR;
226             uint8_t status;
227
228             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
229             {
230                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
231                 {
232                 case 0:
233                     TLVError = dataTlv.Get(status);
234                     break;
235                 default:
236                     // Unsupported tag, ignore it.
237                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
238                     break;
239                 }
240                 if (TLVError != CHIP_NO_ERROR)
241                 {
242                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
243                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
244                 }
245             }
246             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
247             emberAfDoorLockClusterClearRfidResponseCallback(status);
248             break;
249         }
250         case ZCL_CLEAR_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
251             CHIP_ERROR TLVError = CHIP_NO_ERROR;
252             uint8_t status;
253
254             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
255             {
256                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
257                 {
258                 case 0:
259                     TLVError = dataTlv.Get(status);
260                     break;
261                 default:
262                     // Unsupported tag, ignore it.
263                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
264                     break;
265                 }
266                 if (TLVError != CHIP_NO_ERROR)
267                 {
268                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
269                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
270                 }
271             }
272             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
273             emberAfDoorLockClusterClearWeekdayScheduleResponseCallback(status);
274             break;
275         }
276         case ZCL_CLEAR_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
277             CHIP_ERROR TLVError = CHIP_NO_ERROR;
278             uint8_t status;
279
280             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
281             {
282                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
283                 {
284                 case 0:
285                     TLVError = dataTlv.Get(status);
286                     break;
287                 default:
288                     // Unsupported tag, ignore it.
289                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
290                     break;
291                 }
292                 if (TLVError != CHIP_NO_ERROR)
293                 {
294                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
295                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
296                 }
297             }
298             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
299             emberAfDoorLockClusterClearYeardayScheduleResponseCallback(status);
300             break;
301         }
302         case ZCL_GET_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
303             CHIP_ERROR TLVError = CHIP_NO_ERROR;
304             uint8_t scheduleId;
305             uint8_t status;
306             uint32_t localStartTime;
307             uint32_t localEndTime;
308             uint8_t operatingModeDuringHoliday;
309
310             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
311             {
312                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
313                 {
314                 case 0:
315                     TLVError = dataTlv.Get(scheduleId);
316                     break;
317                 case 1:
318                     TLVError = dataTlv.Get(status);
319                     break;
320                 case 2:
321                     TLVError = dataTlv.Get(localStartTime);
322                     break;
323                 case 3:
324                     TLVError = dataTlv.Get(localEndTime);
325                     break;
326                 case 4:
327                     TLVError = dataTlv.Get(operatingModeDuringHoliday);
328                     break;
329                 default:
330                     // Unsupported tag, ignore it.
331                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
332                     break;
333                 }
334                 if (TLVError != CHIP_NO_ERROR)
335                 {
336                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
337                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
338                 }
339             }
340             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
341             emberAfDoorLockClusterGetHolidayScheduleResponseCallback(scheduleId, status, localStartTime, localEndTime,
342                                                                      operatingModeDuringHoliday);
343             break;
344         }
345         case ZCL_GET_LOG_RECORD_RESPONSE_COMMAND_ID: {
346             CHIP_ERROR TLVError = CHIP_NO_ERROR;
347             uint16_t logEntryId;
348             uint32_t timestamp;
349             uint8_t eventType;
350             uint8_t source;
351             uint8_t eventIdOrAlarmCode;
352             uint16_t userId;
353             const uint8_t * pin;
354
355             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
356             {
357                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
358                 {
359                 case 0:
360                     TLVError = dataTlv.Get(logEntryId);
361                     break;
362                 case 1:
363                     TLVError = dataTlv.Get(timestamp);
364                     break;
365                 case 2:
366                     TLVError = dataTlv.Get(eventType);
367                     break;
368                 case 3:
369                     TLVError = dataTlv.Get(source);
370                     break;
371                 case 4:
372                     TLVError = dataTlv.Get(eventIdOrAlarmCode);
373                     break;
374                 case 5:
375                     TLVError = dataTlv.Get(userId);
376                     break;
377                 case 6:
378                     TLVError = dataTlv.GetDataPtr(pin);
379                     break;
380                 default:
381                     // Unsupported tag, ignore it.
382                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
383                     break;
384                 }
385                 if (TLVError != CHIP_NO_ERROR)
386                 {
387                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
388                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
389                 }
390             }
391             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
392             emberAfDoorLockClusterGetLogRecordResponseCallback(logEntryId, timestamp, eventType, source, eventIdOrAlarmCode, userId,
393                                                                const_cast<uint8_t *>(pin));
394             break;
395         }
396         case ZCL_GET_PIN_RESPONSE_COMMAND_ID: {
397             CHIP_ERROR TLVError = CHIP_NO_ERROR;
398             uint16_t userId;
399             uint8_t userStatus;
400             uint8_t userType;
401             const uint8_t * pin;
402
403             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
404             {
405                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
406                 {
407                 case 0:
408                     TLVError = dataTlv.Get(userId);
409                     break;
410                 case 1:
411                     TLVError = dataTlv.Get(userStatus);
412                     break;
413                 case 2:
414                     TLVError = dataTlv.Get(userType);
415                     break;
416                 case 3:
417                     TLVError = dataTlv.GetDataPtr(pin);
418                     break;
419                 default:
420                     // Unsupported tag, ignore it.
421                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
422                     break;
423                 }
424                 if (TLVError != CHIP_NO_ERROR)
425                 {
426                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
427                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
428                 }
429             }
430             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
431             emberAfDoorLockClusterGetPinResponseCallback(userId, userStatus, userType, const_cast<uint8_t *>(pin));
432             break;
433         }
434         case ZCL_GET_RFID_RESPONSE_COMMAND_ID: {
435             CHIP_ERROR TLVError = CHIP_NO_ERROR;
436             uint16_t userId;
437             uint8_t userStatus;
438             uint8_t userType;
439             const uint8_t * rfid;
440
441             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
442             {
443                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
444                 {
445                 case 0:
446                     TLVError = dataTlv.Get(userId);
447                     break;
448                 case 1:
449                     TLVError = dataTlv.Get(userStatus);
450                     break;
451                 case 2:
452                     TLVError = dataTlv.Get(userType);
453                     break;
454                 case 3:
455                     TLVError = dataTlv.GetDataPtr(rfid);
456                     break;
457                 default:
458                     // Unsupported tag, ignore it.
459                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
460                     break;
461                 }
462                 if (TLVError != CHIP_NO_ERROR)
463                 {
464                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
465                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
466                 }
467             }
468             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
469             emberAfDoorLockClusterGetRfidResponseCallback(userId, userStatus, userType, const_cast<uint8_t *>(rfid));
470             break;
471         }
472         case ZCL_GET_USER_TYPE_RESPONSE_COMMAND_ID: {
473             CHIP_ERROR TLVError = CHIP_NO_ERROR;
474             uint16_t userId;
475             uint8_t userType;
476
477             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
478             {
479                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
480                 {
481                 case 0:
482                     TLVError = dataTlv.Get(userId);
483                     break;
484                 case 1:
485                     TLVError = dataTlv.Get(userType);
486                     break;
487                 default:
488                     // Unsupported tag, ignore it.
489                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
490                     break;
491                 }
492                 if (TLVError != CHIP_NO_ERROR)
493                 {
494                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
495                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
496                 }
497             }
498             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
499             emberAfDoorLockClusterGetUserTypeResponseCallback(userId, userType);
500             break;
501         }
502         case ZCL_GET_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
503             CHIP_ERROR TLVError = CHIP_NO_ERROR;
504             uint8_t scheduleId;
505             uint16_t userId;
506             uint8_t status;
507             uint8_t daysMask;
508             uint8_t startHour;
509             uint8_t startMinute;
510             uint8_t endHour;
511             uint8_t endMinute;
512
513             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
514             {
515                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
516                 {
517                 case 0:
518                     TLVError = dataTlv.Get(scheduleId);
519                     break;
520                 case 1:
521                     TLVError = dataTlv.Get(userId);
522                     break;
523                 case 2:
524                     TLVError = dataTlv.Get(status);
525                     break;
526                 case 3:
527                     TLVError = dataTlv.Get(daysMask);
528                     break;
529                 case 4:
530                     TLVError = dataTlv.Get(startHour);
531                     break;
532                 case 5:
533                     TLVError = dataTlv.Get(startMinute);
534                     break;
535                 case 6:
536                     TLVError = dataTlv.Get(endHour);
537                     break;
538                 case 7:
539                     TLVError = dataTlv.Get(endMinute);
540                     break;
541                 default:
542                     // Unsupported tag, ignore it.
543                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
544                     break;
545                 }
546                 if (TLVError != CHIP_NO_ERROR)
547                 {
548                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
549                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
550                 }
551             }
552             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
553             emberAfDoorLockClusterGetWeekdayScheduleResponseCallback(scheduleId, userId, status, daysMask, startHour, startMinute,
554                                                                      endHour, endMinute);
555             break;
556         }
557         case ZCL_GET_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
558             CHIP_ERROR TLVError = CHIP_NO_ERROR;
559             uint8_t scheduleId;
560             uint16_t userId;
561             uint8_t status;
562             uint32_t localStartTime;
563             uint32_t localEndTime;
564
565             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
566             {
567                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
568                 {
569                 case 0:
570                     TLVError = dataTlv.Get(scheduleId);
571                     break;
572                 case 1:
573                     TLVError = dataTlv.Get(userId);
574                     break;
575                 case 2:
576                     TLVError = dataTlv.Get(status);
577                     break;
578                 case 3:
579                     TLVError = dataTlv.Get(localStartTime);
580                     break;
581                 case 4:
582                     TLVError = dataTlv.Get(localEndTime);
583                     break;
584                 default:
585                     // Unsupported tag, ignore it.
586                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
587                     break;
588                 }
589                 if (TLVError != CHIP_NO_ERROR)
590                 {
591                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
592                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
593                 }
594             }
595             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
596             emberAfDoorLockClusterGetYeardayScheduleResponseCallback(scheduleId, userId, status, localStartTime, localEndTime);
597             break;
598         }
599         case ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID: {
600             CHIP_ERROR TLVError = CHIP_NO_ERROR;
601             uint8_t status;
602
603             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
604             {
605                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
606                 {
607                 case 0:
608                     TLVError = dataTlv.Get(status);
609                     break;
610                 default:
611                     // Unsupported tag, ignore it.
612                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
613                     break;
614                 }
615                 if (TLVError != CHIP_NO_ERROR)
616                 {
617                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
618                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
619                 }
620             }
621             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
622             emberAfDoorLockClusterLockDoorResponseCallback(status);
623             break;
624         }
625         case ZCL_SET_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
626             CHIP_ERROR TLVError = CHIP_NO_ERROR;
627             uint8_t status;
628
629             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
630             {
631                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
632                 {
633                 case 0:
634                     TLVError = dataTlv.Get(status);
635                     break;
636                 default:
637                     // Unsupported tag, ignore it.
638                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
639                     break;
640                 }
641                 if (TLVError != CHIP_NO_ERROR)
642                 {
643                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
644                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
645                 }
646             }
647             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
648             emberAfDoorLockClusterSetHolidayScheduleResponseCallback(status);
649             break;
650         }
651         case ZCL_SET_PIN_RESPONSE_COMMAND_ID: {
652             CHIP_ERROR TLVError = CHIP_NO_ERROR;
653             uint8_t status;
654
655             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
656             {
657                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
658                 {
659                 case 0:
660                     TLVError = dataTlv.Get(status);
661                     break;
662                 default:
663                     // Unsupported tag, ignore it.
664                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
665                     break;
666                 }
667                 if (TLVError != CHIP_NO_ERROR)
668                 {
669                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
670                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
671                 }
672             }
673             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
674             emberAfDoorLockClusterSetPinResponseCallback(status);
675             break;
676         }
677         case ZCL_SET_RFID_RESPONSE_COMMAND_ID: {
678             CHIP_ERROR TLVError = CHIP_NO_ERROR;
679             uint8_t status;
680
681             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
682             {
683                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
684                 {
685                 case 0:
686                     TLVError = dataTlv.Get(status);
687                     break;
688                 default:
689                     // Unsupported tag, ignore it.
690                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
691                     break;
692                 }
693                 if (TLVError != CHIP_NO_ERROR)
694                 {
695                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
696                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
697                 }
698             }
699             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
700             emberAfDoorLockClusterSetRfidResponseCallback(status);
701             break;
702         }
703         case ZCL_SET_USER_TYPE_RESPONSE_COMMAND_ID: {
704             CHIP_ERROR TLVError = CHIP_NO_ERROR;
705             uint8_t status;
706
707             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
708             {
709                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
710                 {
711                 case 0:
712                     TLVError = dataTlv.Get(status);
713                     break;
714                 default:
715                     // Unsupported tag, ignore it.
716                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
717                     break;
718                 }
719                 if (TLVError != CHIP_NO_ERROR)
720                 {
721                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
722                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
723                 }
724             }
725             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
726             emberAfDoorLockClusterSetUserTypeResponseCallback(status);
727             break;
728         }
729         case ZCL_SET_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
730             CHIP_ERROR TLVError = CHIP_NO_ERROR;
731             uint8_t status;
732
733             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
734             {
735                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
736                 {
737                 case 0:
738                     TLVError = dataTlv.Get(status);
739                     break;
740                 default:
741                     // Unsupported tag, ignore it.
742                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
743                     break;
744                 }
745                 if (TLVError != CHIP_NO_ERROR)
746                 {
747                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
748                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
749                 }
750             }
751             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
752             emberAfDoorLockClusterSetWeekdayScheduleResponseCallback(status);
753             break;
754         }
755         case ZCL_SET_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
756             CHIP_ERROR TLVError = CHIP_NO_ERROR;
757             uint8_t status;
758
759             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
760             {
761                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
762                 {
763                 case 0:
764                     TLVError = dataTlv.Get(status);
765                     break;
766                 default:
767                     // Unsupported tag, ignore it.
768                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
769                     break;
770                 }
771                 if (TLVError != CHIP_NO_ERROR)
772                 {
773                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
774                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
775                 }
776             }
777             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
778             emberAfDoorLockClusterSetYeardayScheduleResponseCallback(status);
779             break;
780         }
781         case ZCL_UNLOCK_DOOR_RESPONSE_COMMAND_ID: {
782             CHIP_ERROR TLVError = CHIP_NO_ERROR;
783             uint8_t status;
784
785             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
786             {
787                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
788                 {
789                 case 0:
790                     TLVError = dataTlv.Get(status);
791                     break;
792                 default:
793                     // Unsupported tag, ignore it.
794                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
795                     break;
796                 }
797                 if (TLVError != CHIP_NO_ERROR)
798                 {
799                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
800                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
801                 }
802             }
803             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
804             emberAfDoorLockClusterUnlockDoorResponseCallback(status);
805             break;
806         }
807         case ZCL_UNLOCK_WITH_TIMEOUT_RESPONSE_COMMAND_ID: {
808             CHIP_ERROR TLVError = CHIP_NO_ERROR;
809             uint8_t status;
810
811             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
812             {
813                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
814                 {
815                 case 0:
816                     TLVError = dataTlv.Get(status);
817                     break;
818                 default:
819                     // Unsupported tag, ignore it.
820                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
821                     break;
822                 }
823                 if (TLVError != CHIP_NO_ERROR)
824                 {
825                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
826                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
827                 }
828             }
829             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
830             emberAfDoorLockClusterUnlockWithTimeoutResponseCallback(status);
831             break;
832         }
833         default: {
834             // Unrecognized command ID, error status will apply.
835             // TODO: Encode response for command not found
836             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_DOOR_LOCK_CLUSTER_ID);
837             break;
838         }
839         }
840     }
841 }
842
843 } // namespace DoorLock
844
845 namespace GeneralCommissioning {
846
847 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
848 {
849     {
850         switch (commandId)
851         {
852         case ZCL_ARM_FAIL_SAFE_RESPONSE_COMMAND_ID: {
853             CHIP_ERROR TLVError = CHIP_NO_ERROR;
854             uint8_t errorCode;
855             const uint8_t * debugText;
856
857             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
858             {
859                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
860                 {
861                 case 0:
862                     TLVError = dataTlv.Get(errorCode);
863                     break;
864                 case 1:
865                     TLVError = dataTlv.GetDataPtr(debugText);
866                     break;
867                 default:
868                     // Unsupported tag, ignore it.
869                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
870                     break;
871                 }
872                 if (TLVError != CHIP_NO_ERROR)
873                 {
874                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
875                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
876                 }
877             }
878             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
879             emberAfGeneralCommissioningClusterArmFailSafeResponseCallback(errorCode, const_cast<uint8_t *>(debugText));
880             break;
881         }
882         case ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID: {
883             CHIP_ERROR TLVError = CHIP_NO_ERROR;
884             uint8_t errorCode;
885             const uint8_t * debugText;
886
887             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
888             {
889                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
890                 {
891                 case 0:
892                     TLVError = dataTlv.Get(errorCode);
893                     break;
894                 case 1:
895                     TLVError = dataTlv.GetDataPtr(debugText);
896                     break;
897                 default:
898                     // Unsupported tag, ignore it.
899                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
900                     break;
901                 }
902                 if (TLVError != CHIP_NO_ERROR)
903                 {
904                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
905                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
906                 }
907             }
908             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
909             emberAfGeneralCommissioningClusterCommissioningCompleteResponseCallback(errorCode, const_cast<uint8_t *>(debugText));
910             break;
911         }
912         case ZCL_SET_FABRIC_RESPONSE_COMMAND_ID: {
913             CHIP_ERROR TLVError = CHIP_NO_ERROR;
914             uint8_t errorCode;
915             const uint8_t * debugText;
916
917             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
918             {
919                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
920                 {
921                 case 0:
922                     TLVError = dataTlv.Get(errorCode);
923                     break;
924                 case 1:
925                     TLVError = dataTlv.GetDataPtr(debugText);
926                     break;
927                 default:
928                     // Unsupported tag, ignore it.
929                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
930                     break;
931                 }
932                 if (TLVError != CHIP_NO_ERROR)
933                 {
934                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
935                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
936                 }
937             }
938             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
939             emberAfGeneralCommissioningClusterSetFabricResponseCallback(errorCode, const_cast<uint8_t *>(debugText));
940             break;
941         }
942         default: {
943             // Unrecognized command ID, error status will apply.
944             // TODO: Encode response for command not found
945             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_GENERAL_COMMISSIONING_CLUSTER_ID);
946             break;
947         }
948         }
949     }
950 }
951
952 } // namespace GeneralCommissioning
953
954 namespace Groups {
955
956 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
957 {
958     {
959         switch (commandId)
960         {
961         case ZCL_ADD_GROUP_RESPONSE_COMMAND_ID: {
962             CHIP_ERROR TLVError = CHIP_NO_ERROR;
963             uint8_t status;
964             uint16_t groupId;
965
966             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
967             {
968                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
969                 {
970                 case 0:
971                     TLVError = dataTlv.Get(status);
972                     break;
973                 case 1:
974                     TLVError = dataTlv.Get(groupId);
975                     break;
976                 default:
977                     // Unsupported tag, ignore it.
978                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
979                     break;
980                 }
981                 if (TLVError != CHIP_NO_ERROR)
982                 {
983                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
984                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
985                 }
986             }
987             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
988             emberAfGroupsClusterAddGroupResponseCallback(status, groupId);
989             break;
990         }
991         case ZCL_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID: {
992             CHIP_ERROR TLVError = CHIP_NO_ERROR;
993             uint8_t capacity;
994             uint8_t groupCount;
995             /* TYPE WARNING: array array defaults to */ uint8_t * groupList;
996
997             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
998             {
999                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1000                 {
1001                 case 0:
1002                     TLVError = dataTlv.Get(capacity);
1003                     break;
1004                 case 1:
1005                     TLVError = dataTlv.Get(groupCount);
1006                     break;
1007                 case 2:
1008                     // Just for compatibility, we will add array type support in IM later.
1009                     TLVError = dataTlv.GetDataPtr(const_cast<const uint8_t *&>(groupList));
1010                     break;
1011                 default:
1012                     // Unsupported tag, ignore it.
1013                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1014                     break;
1015                 }
1016                 if (TLVError != CHIP_NO_ERROR)
1017                 {
1018                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1019                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1020                 }
1021             }
1022             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1023             emberAfGroupsClusterGetGroupMembershipResponseCallback(capacity, groupCount, groupList);
1024             break;
1025         }
1026         case ZCL_REMOVE_GROUP_RESPONSE_COMMAND_ID: {
1027             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1028             uint8_t status;
1029             uint16_t groupId;
1030
1031             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1032             {
1033                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1034                 {
1035                 case 0:
1036                     TLVError = dataTlv.Get(status);
1037                     break;
1038                 case 1:
1039                     TLVError = dataTlv.Get(groupId);
1040                     break;
1041                 default:
1042                     // Unsupported tag, ignore it.
1043                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1044                     break;
1045                 }
1046                 if (TLVError != CHIP_NO_ERROR)
1047                 {
1048                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1049                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1050                 }
1051             }
1052             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1053             emberAfGroupsClusterRemoveGroupResponseCallback(status, groupId);
1054             break;
1055         }
1056         case ZCL_VIEW_GROUP_RESPONSE_COMMAND_ID: {
1057             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1058             uint8_t status;
1059             uint16_t groupId;
1060             const uint8_t * groupName;
1061
1062             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1063             {
1064                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1065                 {
1066                 case 0:
1067                     TLVError = dataTlv.Get(status);
1068                     break;
1069                 case 1:
1070                     TLVError = dataTlv.Get(groupId);
1071                     break;
1072                 case 2:
1073                     TLVError = dataTlv.GetDataPtr(groupName);
1074                     break;
1075                 default:
1076                     // Unsupported tag, ignore it.
1077                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1078                     break;
1079                 }
1080                 if (TLVError != CHIP_NO_ERROR)
1081                 {
1082                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1083                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1084                 }
1085             }
1086             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1087             emberAfGroupsClusterViewGroupResponseCallback(status, groupId, const_cast<uint8_t *>(groupName));
1088             break;
1089         }
1090         default: {
1091             // Unrecognized command ID, error status will apply.
1092             // TODO: Encode response for command not found
1093             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_GROUPS_CLUSTER_ID);
1094             break;
1095         }
1096         }
1097     }
1098 }
1099
1100 } // namespace Groups
1101
1102 namespace Identify {
1103
1104 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
1105 {
1106     {
1107         switch (commandId)
1108         {
1109         case ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID: {
1110             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1111             uint16_t timeout;
1112
1113             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1114             {
1115                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1116                 {
1117                 case 0:
1118                     TLVError = dataTlv.Get(timeout);
1119                     break;
1120                 default:
1121                     // Unsupported tag, ignore it.
1122                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1123                     break;
1124                 }
1125                 if (TLVError != CHIP_NO_ERROR)
1126                 {
1127                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1128                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1129                 }
1130             }
1131             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1132             emberAfIdentifyClusterIdentifyQueryResponseCallback(timeout);
1133             break;
1134         }
1135         default: {
1136             // Unrecognized command ID, error status will apply.
1137             // TODO: Encode response for command not found
1138             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_IDENTIFY_CLUSTER_ID);
1139             break;
1140         }
1141         }
1142     }
1143 }
1144
1145 } // namespace Identify
1146
1147 namespace MediaPlayback {
1148
1149 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
1150 {
1151     {
1152         switch (commandId)
1153         {
1154         case ZCL_PLAYBACK_COMMAND_ID: {
1155             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1156             emberAfMediaPlaybackClusterPlaybackCallback();
1157             break;
1158         }
1159         default: {
1160             // Unrecognized command ID, error status will apply.
1161             // TODO: Encode response for command not found
1162             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_MEDIA_PLAYBACK_CLUSTER_ID);
1163             break;
1164         }
1165         }
1166     }
1167 }
1168
1169 } // namespace MediaPlayback
1170
1171 namespace Scenes {
1172
1173 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
1174 {
1175     {
1176         switch (commandId)
1177         {
1178         case ZCL_ADD_SCENE_RESPONSE_COMMAND_ID: {
1179             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1180             uint8_t status;
1181             uint16_t groupId;
1182             uint8_t sceneId;
1183
1184             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1185             {
1186                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1187                 {
1188                 case 0:
1189                     TLVError = dataTlv.Get(status);
1190                     break;
1191                 case 1:
1192                     TLVError = dataTlv.Get(groupId);
1193                     break;
1194                 case 2:
1195                     TLVError = dataTlv.Get(sceneId);
1196                     break;
1197                 default:
1198                     // Unsupported tag, ignore it.
1199                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1200                     break;
1201                 }
1202                 if (TLVError != CHIP_NO_ERROR)
1203                 {
1204                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1205                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1206                 }
1207             }
1208             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1209             emberAfScenesClusterAddSceneResponseCallback(status, groupId, sceneId);
1210             break;
1211         }
1212         case ZCL_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID: {
1213             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1214             uint8_t status;
1215             uint8_t capacity;
1216             uint16_t groupId;
1217             uint8_t sceneCount;
1218             /* TYPE WARNING: array array defaults to */ uint8_t * sceneList;
1219
1220             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1221             {
1222                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1223                 {
1224                 case 0:
1225                     TLVError = dataTlv.Get(status);
1226                     break;
1227                 case 1:
1228                     TLVError = dataTlv.Get(capacity);
1229                     break;
1230                 case 2:
1231                     TLVError = dataTlv.Get(groupId);
1232                     break;
1233                 case 3:
1234                     TLVError = dataTlv.Get(sceneCount);
1235                     break;
1236                 case 4:
1237                     // Just for compatibility, we will add array type support in IM later.
1238                     TLVError = dataTlv.GetDataPtr(const_cast<const uint8_t *&>(sceneList));
1239                     break;
1240                 default:
1241                     // Unsupported tag, ignore it.
1242                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1243                     break;
1244                 }
1245                 if (TLVError != CHIP_NO_ERROR)
1246                 {
1247                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1248                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1249                 }
1250             }
1251             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1252             emberAfScenesClusterGetSceneMembershipResponseCallback(status, capacity, groupId, sceneCount, sceneList);
1253             break;
1254         }
1255         case ZCL_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID: {
1256             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1257             uint8_t status;
1258             uint16_t groupId;
1259
1260             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1261             {
1262                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1263                 {
1264                 case 0:
1265                     TLVError = dataTlv.Get(status);
1266                     break;
1267                 case 1:
1268                     TLVError = dataTlv.Get(groupId);
1269                     break;
1270                 default:
1271                     // Unsupported tag, ignore it.
1272                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1273                     break;
1274                 }
1275                 if (TLVError != CHIP_NO_ERROR)
1276                 {
1277                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1278                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1279                 }
1280             }
1281             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1282             emberAfScenesClusterRemoveAllScenesResponseCallback(status, groupId);
1283             break;
1284         }
1285         case ZCL_REMOVE_SCENE_RESPONSE_COMMAND_ID: {
1286             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1287             uint8_t status;
1288             uint16_t groupId;
1289             uint8_t sceneId;
1290
1291             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1292             {
1293                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1294                 {
1295                 case 0:
1296                     TLVError = dataTlv.Get(status);
1297                     break;
1298                 case 1:
1299                     TLVError = dataTlv.Get(groupId);
1300                     break;
1301                 case 2:
1302                     TLVError = dataTlv.Get(sceneId);
1303                     break;
1304                 default:
1305                     // Unsupported tag, ignore it.
1306                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1307                     break;
1308                 }
1309                 if (TLVError != CHIP_NO_ERROR)
1310                 {
1311                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1312                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1313                 }
1314             }
1315             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1316             emberAfScenesClusterRemoveSceneResponseCallback(status, groupId, sceneId);
1317             break;
1318         }
1319         case ZCL_STORE_SCENE_RESPONSE_COMMAND_ID: {
1320             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1321             uint8_t status;
1322             uint16_t groupId;
1323             uint8_t sceneId;
1324
1325             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1326             {
1327                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1328                 {
1329                 case 0:
1330                     TLVError = dataTlv.Get(status);
1331                     break;
1332                 case 1:
1333                     TLVError = dataTlv.Get(groupId);
1334                     break;
1335                 case 2:
1336                     TLVError = dataTlv.Get(sceneId);
1337                     break;
1338                 default:
1339                     // Unsupported tag, ignore it.
1340                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1341                     break;
1342                 }
1343                 if (TLVError != CHIP_NO_ERROR)
1344                 {
1345                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1346                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1347                 }
1348             }
1349             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1350             emberAfScenesClusterStoreSceneResponseCallback(status, groupId, sceneId);
1351             break;
1352         }
1353         case ZCL_VIEW_SCENE_RESPONSE_COMMAND_ID: {
1354             CHIP_ERROR TLVError = CHIP_NO_ERROR;
1355             uint8_t status;
1356             uint16_t groupId;
1357             uint8_t sceneId;
1358             uint16_t transitionTime;
1359             const uint8_t * sceneName;
1360             /* TYPE WARNING: array array defaults to */ uint8_t * extensionFieldSets;
1361
1362             while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1363             {
1364                 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1365                 {
1366                 case 0:
1367                     TLVError = dataTlv.Get(status);
1368                     break;
1369                 case 1:
1370                     TLVError = dataTlv.Get(groupId);
1371                     break;
1372                 case 2:
1373                     TLVError = dataTlv.Get(sceneId);
1374                     break;
1375                 case 3:
1376                     TLVError = dataTlv.Get(transitionTime);
1377                     break;
1378                 case 4:
1379                     TLVError = dataTlv.GetDataPtr(sceneName);
1380                     break;
1381                 case 5:
1382                     // Just for compatibility, we will add array type support in IM later.
1383                     TLVError = dataTlv.GetDataPtr(const_cast<const uint8_t *&>(extensionFieldSets));
1384                     break;
1385                 default:
1386                     // Unsupported tag, ignore it.
1387                     ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1388                     break;
1389                 }
1390                 if (TLVError != CHIP_NO_ERROR)
1391                 {
1392                     ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1393                                     TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1394                 }
1395             }
1396             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1397             emberAfScenesClusterViewSceneResponseCallback(status, groupId, sceneId, transitionTime,
1398                                                           const_cast<uint8_t *>(sceneName), extensionFieldSets);
1399             break;
1400         }
1401         default: {
1402             // Unrecognized command ID, error status will apply.
1403             // TODO: Encode response for command not found
1404             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_SCENES_CLUSTER_ID);
1405             break;
1406         }
1407         }
1408     }
1409 }
1410
1411 } // namespace Scenes
1412
1413 } // namespace clusters
1414
1415 void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId,
1416                                   chip::TLV::TLVReader & aReader, Command * apCommandObj)
1417 {
1418     ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId,
1419                   aEndPointId);
1420     Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId);
1421     switch (aClusterId)
1422     {
1423     default:
1424         // Unrecognized cluster ID, error status will apply.
1425         // TODO: Encode response for Cluster not found
1426         ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId);
1427         break;
1428     }
1429     Compatibility::ResetEmberAfObjects();
1430 }
1431
1432 } // namespace app
1433 } // namespace chip