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