3 * Copyright (c) 2021 Project CHIP Authors
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 // THIS FILE IS GENERATED BY ZAP
23 #include "af-structs.h"
24 #include "app/util/util.h"
25 #include "call-command-handler.h"
27 #include "cluster-id.h"
28 #include "command-id.h"
30 #include <app/InteractionModelEngine.h>
32 // Currently we need some work to keep compatible with ember lib.
33 #include <util/ember-compatibility-functions.h>
38 // Cluster specific command parsing
44 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
49 case ZCL_CLEAR_ALL_PINS_RESPONSE_COMMAND_ID: {
50 CHIP_ERROR TLVError = CHIP_NO_ERROR;
53 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
55 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
58 TLVError = dataTlv.Get(status);
61 // Unsupported tag, ignore it.
62 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
65 if (TLVError != CHIP_NO_ERROR)
67 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
68 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
71 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
72 emberAfDoorLockClusterClearAllPinsResponseCallback(status);
75 case ZCL_CLEAR_ALL_RFIDS_RESPONSE_COMMAND_ID: {
76 CHIP_ERROR TLVError = CHIP_NO_ERROR;
79 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
81 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
84 TLVError = dataTlv.Get(status);
87 // Unsupported tag, ignore it.
88 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
91 if (TLVError != CHIP_NO_ERROR)
93 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
94 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
97 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
98 emberAfDoorLockClusterClearAllRfidsResponseCallback(status);
101 case ZCL_CLEAR_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
102 CHIP_ERROR TLVError = CHIP_NO_ERROR;
105 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
107 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
110 TLVError = dataTlv.Get(status);
113 // Unsupported tag, ignore it.
114 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
117 if (TLVError != CHIP_NO_ERROR)
119 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
120 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
123 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
124 emberAfDoorLockClusterClearHolidayScheduleResponseCallback(status);
127 case ZCL_CLEAR_PIN_RESPONSE_COMMAND_ID: {
128 CHIP_ERROR TLVError = CHIP_NO_ERROR;
131 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
133 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
136 TLVError = dataTlv.Get(status);
139 // Unsupported tag, ignore it.
140 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
143 if (TLVError != CHIP_NO_ERROR)
145 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
146 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
149 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
150 emberAfDoorLockClusterClearPinResponseCallback(status);
153 case ZCL_CLEAR_RFID_RESPONSE_COMMAND_ID: {
154 CHIP_ERROR TLVError = CHIP_NO_ERROR;
157 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
159 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
162 TLVError = dataTlv.Get(status);
165 // Unsupported tag, ignore it.
166 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
169 if (TLVError != CHIP_NO_ERROR)
171 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
172 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
175 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
176 emberAfDoorLockClusterClearRfidResponseCallback(status);
179 case ZCL_CLEAR_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
180 CHIP_ERROR TLVError = CHIP_NO_ERROR;
183 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
185 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
188 TLVError = dataTlv.Get(status);
191 // Unsupported tag, ignore it.
192 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
195 if (TLVError != CHIP_NO_ERROR)
197 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
198 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
201 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
202 emberAfDoorLockClusterClearWeekdayScheduleResponseCallback(status);
205 case ZCL_CLEAR_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
206 CHIP_ERROR TLVError = CHIP_NO_ERROR;
209 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
211 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
214 TLVError = dataTlv.Get(status);
217 // Unsupported tag, ignore it.
218 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
221 if (TLVError != CHIP_NO_ERROR)
223 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
224 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
227 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
228 emberAfDoorLockClusterClearYeardayScheduleResponseCallback(status);
231 case ZCL_GET_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
232 CHIP_ERROR TLVError = CHIP_NO_ERROR;
235 uint32_t localStartTime;
236 uint32_t localEndTime;
237 uint8_t operatingModeDuringHoliday;
239 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
241 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
244 TLVError = dataTlv.Get(scheduleId);
247 TLVError = dataTlv.Get(status);
250 TLVError = dataTlv.Get(localStartTime);
253 TLVError = dataTlv.Get(localEndTime);
256 TLVError = dataTlv.Get(operatingModeDuringHoliday);
259 // Unsupported tag, ignore it.
260 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
263 if (TLVError != CHIP_NO_ERROR)
265 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
266 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
269 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
270 emberAfDoorLockClusterGetHolidayScheduleResponseCallback(scheduleId, status, localStartTime, localEndTime,
271 operatingModeDuringHoliday);
274 case ZCL_GET_LOG_RECORD_RESPONSE_COMMAND_ID: {
275 CHIP_ERROR TLVError = CHIP_NO_ERROR;
280 uint8_t eventIdOrAlarmCode;
284 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
286 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
289 TLVError = dataTlv.Get(logEntryId);
292 TLVError = dataTlv.Get(timestamp);
295 TLVError = dataTlv.Get(eventType);
298 TLVError = dataTlv.Get(source);
301 TLVError = dataTlv.Get(eventIdOrAlarmCode);
304 TLVError = dataTlv.Get(userId);
307 TLVError = dataTlv.GetDataPtr(pin);
310 // Unsupported tag, ignore it.
311 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
314 if (TLVError != CHIP_NO_ERROR)
316 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
317 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
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));
325 case ZCL_GET_PIN_RESPONSE_COMMAND_ID: {
326 CHIP_ERROR TLVError = CHIP_NO_ERROR;
332 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
334 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
337 TLVError = dataTlv.Get(userId);
340 TLVError = dataTlv.Get(userStatus);
343 TLVError = dataTlv.Get(userType);
346 TLVError = dataTlv.GetDataPtr(pin);
349 // Unsupported tag, ignore it.
350 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
353 if (TLVError != CHIP_NO_ERROR)
355 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
356 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
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));
363 case ZCL_GET_RFID_RESPONSE_COMMAND_ID: {
364 CHIP_ERROR TLVError = CHIP_NO_ERROR;
368 const uint8_t * rfid;
370 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
372 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
375 TLVError = dataTlv.Get(userId);
378 TLVError = dataTlv.Get(userStatus);
381 TLVError = dataTlv.Get(userType);
384 TLVError = dataTlv.GetDataPtr(rfid);
387 // Unsupported tag, ignore it.
388 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
391 if (TLVError != CHIP_NO_ERROR)
393 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
394 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
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));
401 case ZCL_GET_USER_TYPE_RESPONSE_COMMAND_ID: {
402 CHIP_ERROR TLVError = CHIP_NO_ERROR;
406 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
408 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
411 TLVError = dataTlv.Get(userId);
414 TLVError = dataTlv.Get(userType);
417 // Unsupported tag, ignore it.
418 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
421 if (TLVError != CHIP_NO_ERROR)
423 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
424 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
427 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
428 emberAfDoorLockClusterGetUserTypeResponseCallback(userId, userType);
431 case ZCL_GET_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
432 CHIP_ERROR TLVError = CHIP_NO_ERROR;
442 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
444 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
447 TLVError = dataTlv.Get(scheduleId);
450 TLVError = dataTlv.Get(userId);
453 TLVError = dataTlv.Get(status);
456 TLVError = dataTlv.Get(daysMask);
459 TLVError = dataTlv.Get(startHour);
462 TLVError = dataTlv.Get(startMinute);
465 TLVError = dataTlv.Get(endHour);
468 TLVError = dataTlv.Get(endMinute);
471 // Unsupported tag, ignore it.
472 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
475 if (TLVError != CHIP_NO_ERROR)
477 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
478 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
481 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
482 emberAfDoorLockClusterGetWeekdayScheduleResponseCallback(scheduleId, userId, status, daysMask, startHour, startMinute,
486 case ZCL_GET_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
487 CHIP_ERROR TLVError = CHIP_NO_ERROR;
491 uint32_t localStartTime;
492 uint32_t localEndTime;
494 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
496 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
499 TLVError = dataTlv.Get(scheduleId);
502 TLVError = dataTlv.Get(userId);
505 TLVError = dataTlv.Get(status);
508 TLVError = dataTlv.Get(localStartTime);
511 TLVError = dataTlv.Get(localEndTime);
514 // Unsupported tag, ignore it.
515 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
518 if (TLVError != CHIP_NO_ERROR)
520 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
521 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
524 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
525 emberAfDoorLockClusterGetYeardayScheduleResponseCallback(scheduleId, userId, status, localStartTime, localEndTime);
528 case ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID: {
529 CHIP_ERROR TLVError = CHIP_NO_ERROR;
532 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
534 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
537 TLVError = dataTlv.Get(status);
540 // Unsupported tag, ignore it.
541 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
544 if (TLVError != CHIP_NO_ERROR)
546 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
547 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
550 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
551 emberAfDoorLockClusterLockDoorResponseCallback(status);
554 case ZCL_SET_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
555 CHIP_ERROR TLVError = CHIP_NO_ERROR;
558 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
560 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
563 TLVError = dataTlv.Get(status);
566 // Unsupported tag, ignore it.
567 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
570 if (TLVError != CHIP_NO_ERROR)
572 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
573 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
576 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
577 emberAfDoorLockClusterSetHolidayScheduleResponseCallback(status);
580 case ZCL_SET_PIN_RESPONSE_COMMAND_ID: {
581 CHIP_ERROR TLVError = CHIP_NO_ERROR;
584 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
586 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
589 TLVError = dataTlv.Get(status);
592 // Unsupported tag, ignore it.
593 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
596 if (TLVError != CHIP_NO_ERROR)
598 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
599 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
602 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
603 emberAfDoorLockClusterSetPinResponseCallback(status);
606 case ZCL_SET_RFID_RESPONSE_COMMAND_ID: {
607 CHIP_ERROR TLVError = CHIP_NO_ERROR;
610 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
612 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
615 TLVError = dataTlv.Get(status);
618 // Unsupported tag, ignore it.
619 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
622 if (TLVError != CHIP_NO_ERROR)
624 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
625 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
628 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
629 emberAfDoorLockClusterSetRfidResponseCallback(status);
632 case ZCL_SET_USER_TYPE_RESPONSE_COMMAND_ID: {
633 CHIP_ERROR TLVError = CHIP_NO_ERROR;
636 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
638 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
641 TLVError = dataTlv.Get(status);
644 // Unsupported tag, ignore it.
645 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
648 if (TLVError != CHIP_NO_ERROR)
650 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
651 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
654 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
655 emberAfDoorLockClusterSetUserTypeResponseCallback(status);
658 case ZCL_SET_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
659 CHIP_ERROR TLVError = CHIP_NO_ERROR;
662 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
664 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
667 TLVError = dataTlv.Get(status);
670 // Unsupported tag, ignore it.
671 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
674 if (TLVError != CHIP_NO_ERROR)
676 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
677 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
680 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
681 emberAfDoorLockClusterSetWeekdayScheduleResponseCallback(status);
684 case ZCL_SET_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID: {
685 CHIP_ERROR TLVError = CHIP_NO_ERROR;
688 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
690 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
693 TLVError = dataTlv.Get(status);
696 // Unsupported tag, ignore it.
697 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
700 if (TLVError != CHIP_NO_ERROR)
702 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
703 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
706 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
707 emberAfDoorLockClusterSetYeardayScheduleResponseCallback(status);
710 case ZCL_UNLOCK_DOOR_RESPONSE_COMMAND_ID: {
711 CHIP_ERROR TLVError = CHIP_NO_ERROR;
714 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
716 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
719 TLVError = dataTlv.Get(status);
722 // Unsupported tag, ignore it.
723 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
726 if (TLVError != CHIP_NO_ERROR)
728 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
729 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
732 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
733 emberAfDoorLockClusterUnlockDoorResponseCallback(status);
736 case ZCL_UNLOCK_WITH_TIMEOUT_RESPONSE_COMMAND_ID: {
737 CHIP_ERROR TLVError = CHIP_NO_ERROR;
740 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
742 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
745 TLVError = dataTlv.Get(status);
748 // Unsupported tag, ignore it.
749 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
752 if (TLVError != CHIP_NO_ERROR)
754 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
755 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
758 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
759 emberAfDoorLockClusterUnlockWithTimeoutResponseCallback(status);
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);
772 } // namespace DoorLock
774 namespace GeneralCommissioning {
776 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
781 case ZCL_ARM_FAIL_SAFE_RESPONSE_COMMAND_ID: {
782 CHIP_ERROR TLVError = CHIP_NO_ERROR;
784 const uint8_t * debugText;
786 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
788 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
791 TLVError = dataTlv.Get(errorCode);
794 TLVError = dataTlv.GetDataPtr(debugText);
797 // Unsupported tag, ignore it.
798 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
801 if (TLVError != CHIP_NO_ERROR)
803 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
804 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
807 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
808 emberAfGeneralCommissioningClusterArmFailSafeResponseCallback(errorCode, const_cast<uint8_t *>(debugText));
811 case ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID: {
812 CHIP_ERROR TLVError = CHIP_NO_ERROR;
814 const uint8_t * debugText;
816 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
818 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
821 TLVError = dataTlv.Get(errorCode);
824 TLVError = dataTlv.GetDataPtr(debugText);
827 // Unsupported tag, ignore it.
828 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
831 if (TLVError != CHIP_NO_ERROR)
833 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
834 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
837 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
838 emberAfGeneralCommissioningClusterCommissioningCompleteResponseCallback(errorCode, const_cast<uint8_t *>(debugText));
841 case ZCL_SET_FABRIC_RESPONSE_COMMAND_ID: {
842 CHIP_ERROR TLVError = CHIP_NO_ERROR;
844 const uint8_t * debugText;
846 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
848 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
851 TLVError = dataTlv.Get(errorCode);
854 TLVError = dataTlv.GetDataPtr(debugText);
857 // Unsupported tag, ignore it.
858 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
861 if (TLVError != CHIP_NO_ERROR)
863 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
864 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
867 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
868 emberAfGeneralCommissioningClusterSetFabricResponseCallback(errorCode, const_cast<uint8_t *>(debugText));
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);
881 } // namespace GeneralCommissioning
885 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
890 case ZCL_ADD_GROUP_RESPONSE_COMMAND_ID: {
891 CHIP_ERROR TLVError = CHIP_NO_ERROR;
895 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
897 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
900 TLVError = dataTlv.Get(status);
903 TLVError = dataTlv.Get(groupId);
906 // Unsupported tag, ignore it.
907 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
910 if (TLVError != CHIP_NO_ERROR)
912 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
913 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
916 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
917 emberAfGroupsClusterAddGroupResponseCallback(status, groupId);
920 case ZCL_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID: {
921 CHIP_ERROR TLVError = CHIP_NO_ERROR;
924 /* TYPE WARNING: array array defaults to */ uint8_t * groupList;
926 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
928 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
931 TLVError = dataTlv.Get(capacity);
934 TLVError = dataTlv.Get(groupCount);
937 // Just for compatibility, we will add array type support in IM later.
938 TLVError = dataTlv.GetDataPtr(const_cast<const uint8_t *&>(groupList));
941 // Unsupported tag, ignore it.
942 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
945 if (TLVError != CHIP_NO_ERROR)
947 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
948 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
951 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
952 emberAfGroupsClusterGetGroupMembershipResponseCallback(capacity, groupCount, groupList);
955 case ZCL_REMOVE_GROUP_RESPONSE_COMMAND_ID: {
956 CHIP_ERROR TLVError = CHIP_NO_ERROR;
960 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
962 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
965 TLVError = dataTlv.Get(status);
968 TLVError = dataTlv.Get(groupId);
971 // Unsupported tag, ignore it.
972 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
975 if (TLVError != CHIP_NO_ERROR)
977 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
978 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
981 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
982 emberAfGroupsClusterRemoveGroupResponseCallback(status, groupId);
985 case ZCL_VIEW_GROUP_RESPONSE_COMMAND_ID: {
986 CHIP_ERROR TLVError = CHIP_NO_ERROR;
989 const uint8_t * groupName;
991 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
993 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
996 TLVError = dataTlv.Get(status);
999 TLVError = dataTlv.Get(groupId);
1002 TLVError = dataTlv.GetDataPtr(groupName);
1005 // Unsupported tag, ignore it.
1006 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1009 if (TLVError != CHIP_NO_ERROR)
1011 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1012 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1015 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1016 emberAfGroupsClusterViewGroupResponseCallback(status, groupId, const_cast<uint8_t *>(groupName));
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);
1029 } // namespace Groups
1031 namespace Identify {
1033 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
1038 case ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID: {
1039 CHIP_ERROR TLVError = CHIP_NO_ERROR;
1042 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1044 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1047 TLVError = dataTlv.Get(timeout);
1050 // Unsupported tag, ignore it.
1051 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1054 if (TLVError != CHIP_NO_ERROR)
1056 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1057 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1060 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1061 emberAfIdentifyClusterIdentifyQueryResponseCallback(timeout);
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);
1074 } // namespace Identify
1078 void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
1083 case ZCL_ADD_SCENE_RESPONSE_COMMAND_ID: {
1084 CHIP_ERROR TLVError = CHIP_NO_ERROR;
1089 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1091 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1094 TLVError = dataTlv.Get(status);
1097 TLVError = dataTlv.Get(groupId);
1100 TLVError = dataTlv.Get(sceneId);
1103 // Unsupported tag, ignore it.
1104 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1107 if (TLVError != CHIP_NO_ERROR)
1109 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1110 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1113 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1114 emberAfScenesClusterAddSceneResponseCallback(status, groupId, sceneId);
1117 case ZCL_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID: {
1118 CHIP_ERROR TLVError = CHIP_NO_ERROR;
1123 /* TYPE WARNING: array array defaults to */ uint8_t * sceneList;
1125 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1127 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1130 TLVError = dataTlv.Get(status);
1133 TLVError = dataTlv.Get(capacity);
1136 TLVError = dataTlv.Get(groupId);
1139 TLVError = dataTlv.Get(sceneCount);
1142 // Just for compatibility, we will add array type support in IM later.
1143 TLVError = dataTlv.GetDataPtr(const_cast<const uint8_t *&>(sceneList));
1146 // Unsupported tag, ignore it.
1147 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1150 if (TLVError != CHIP_NO_ERROR)
1152 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1153 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1156 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1157 emberAfScenesClusterGetSceneMembershipResponseCallback(status, capacity, groupId, sceneCount, sceneList);
1160 case ZCL_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID: {
1161 CHIP_ERROR TLVError = CHIP_NO_ERROR;
1165 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1167 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1170 TLVError = dataTlv.Get(status);
1173 TLVError = dataTlv.Get(groupId);
1176 // Unsupported tag, ignore it.
1177 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1180 if (TLVError != CHIP_NO_ERROR)
1182 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1183 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1186 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1187 emberAfScenesClusterRemoveAllScenesResponseCallback(status, groupId);
1190 case ZCL_REMOVE_SCENE_RESPONSE_COMMAND_ID: {
1191 CHIP_ERROR TLVError = CHIP_NO_ERROR;
1196 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1198 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1201 TLVError = dataTlv.Get(status);
1204 TLVError = dataTlv.Get(groupId);
1207 TLVError = dataTlv.Get(sceneId);
1210 // Unsupported tag, ignore it.
1211 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1214 if (TLVError != CHIP_NO_ERROR)
1216 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1217 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1220 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1221 emberAfScenesClusterRemoveSceneResponseCallback(status, groupId, sceneId);
1224 case ZCL_STORE_SCENE_RESPONSE_COMMAND_ID: {
1225 CHIP_ERROR TLVError = CHIP_NO_ERROR;
1230 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1232 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1235 TLVError = dataTlv.Get(status);
1238 TLVError = dataTlv.Get(groupId);
1241 TLVError = dataTlv.Get(sceneId);
1244 // Unsupported tag, ignore it.
1245 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1248 if (TLVError != CHIP_NO_ERROR)
1250 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1251 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
1254 // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
1255 emberAfScenesClusterStoreSceneResponseCallback(status, groupId, sceneId);
1258 case ZCL_VIEW_SCENE_RESPONSE_COMMAND_ID: {
1259 CHIP_ERROR TLVError = CHIP_NO_ERROR;
1263 uint16_t transitionTime;
1264 const uint8_t * sceneName;
1265 /* TYPE WARNING: array array defaults to */ uint8_t * extensionFieldSets;
1267 while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
1269 switch (TLV::TagNumFromTag(dataTlv.GetTag()))
1272 TLVError = dataTlv.Get(status);
1275 TLVError = dataTlv.Get(groupId);
1278 TLVError = dataTlv.Get(sceneId);
1281 TLVError = dataTlv.Get(transitionTime);
1284 TLVError = dataTlv.GetDataPtr(sceneName);
1287 // Just for compatibility, we will add array type support in IM later.
1288 TLVError = dataTlv.GetDataPtr(const_cast<const uint8_t *&>(extensionFieldSets));
1291 // Unsupported tag, ignore it.
1292 ChipLogProgress(Zcl, "Unknown TLV tag during processing.");
1295 if (TLVError != CHIP_NO_ERROR)
1297 ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
1298 TLV::TagNumFromTag(dataTlv.GetTag()), TLVError);
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);
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);
1316 } // namespace Scenes
1318 } // namespace clusters
1320 void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId,
1321 chip::TLV::TLVReader & aReader, Command * apCommandObj)
1323 ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId,
1325 Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId);
1329 // Unrecognized cluster ID, error status will apply.
1330 // TODO: Encode response for Cluster not found
1331 ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId);
1334 Compatibility::ResetEmberAfObjects();