From 39115b9945643977e6d0b50a5b18c0c03a78a05d Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 31 Jan 2022 08:24:31 -0500 Subject: [PATCH] Remove CHIPClusters.cpp and various things it called into (#14581) * Remove CHIPClusters.cpp, now that it's not used. * Remove CHIPClientCallbacks.cpp now that it's not used. * Remove DeviceControllerInteractionModelDelegate. * Remove im-client-callbacks.cpp. * Remove the callbacks manager. --- .gitattributes | 1 - config/mbed/CMakeLists.txt | 1 - .../all-clusters-common/BUILD.gn | 1 - .../all-clusters-app/ameba/chip_main.cmake | 2 - examples/all-clusters-app/mbed/CMakeLists.txt | 2 - .../commands/pairing/PairingCommand.h | 1 - examples/lighting-app/ameba/chip_main.cmake | 2 - examples/lighting-app/mbed/CMakeLists.txt | 1 - .../lighting-app/nrfconnect/CMakeLists.txt | 2 - .../ota-requestor-app/ameba/chip_main.cmake | 3 - .../ota-requestor-app/mbed/CMakeLists.txt | 1 - .../ota-requestor-common/BUILD.gn | 2 - examples/tv-app/tv-common/BUILD.gn | 1 - examples/tv-casting-app/linux/main.cpp | 1 - .../tv-casting-app/tv-casting-common/BUILD.gn | 1 - src/app/BUILD.gn | 1 - ...DeviceControllerInteractionModelDelegate.h | 74 - src/app/DeviceProxy.cpp | 22 - src/app/DeviceProxy.h | 12 - src/app/InteractionModelEngine.h | 2 - src/app/OperationalDeviceProxy.h | 4 - src/app/chip_data_model.cmake | 9 +- src/app/chip_data_model.gni | 20 +- src/app/server/Server.cpp | 1 - src/app/tests/BUILD.gn | 2 - src/app/tests/TestCHIPDeviceCallbacksMgr.cpp | 323 - src/app/tests/TestCommandInteraction.cpp | 9 - .../tests/integration/chip_im_initiator.cpp | 17 - .../tests/integration/chip_im_responder.cpp | 9 - src/app/util/BUILD.gn | 14 - src/app/util/CHIPDeviceCallbacksMgr.cpp | 138 - src/app/util/CHIPDeviceCallbacksMgr.h | 154 - src/app/util/im-client-callbacks.cpp | 428 - src/app/util/im-client-callbacks.h | 7 - src/app/zap-templates/app-templates.json | 10 - .../app/CHIPClientCallbacks-src.zapt | 180 - .../templates/app/CHIPClientCallbacks.zapt | 14 +- .../templates/app/CHIPClusters-src.zapt | 82 - .../templates/app/CHIPClusters.zapt | 7 - .../app/im-cluster-command-handler.zapt | 53 +- src/controller/BUILD.gn | 1 - src/controller/CHIPDeviceController.cpp | 10 - src/controller/CHIPDeviceController.h | 1 - .../CHIPDeviceControllerFactory.cpp | 12 - src/controller/CHIPDeviceControllerFactory.h | 1 - .../CHIPDeviceControllerSystemState.h | 7 +- src/controller/CommissioneeDeviceProxy.h | 9 - src/controller/data_model/BUILD.gn | 1 - .../ChipDeviceController-ScriptBinding.cpp | 1 - .../chip/interaction_model/Delegate.cpp | 68 +- .../python/chip/interaction_model/Delegate.h | 30 - .../Framework/CHIP.xcodeproj/project.pbxproj | 12 - .../zap-generated/CHIPClientCallbacks.cpp | 147 - .../zap-generated/CHIPClientCallbacks.h | 8 - .../zap-generated/CHIPClusters.cpp | 188 - .../zap-generated/CHIPClusters.h | 10 - .../zap-generated/IMClusterCommandHandler.cpp | 223 - .../zap-generated/CHIPClientCallbacks.cpp | 18 - .../zap-generated/CHIPClientCallbacks.h | 2 - .../bridge-app/zap-generated/CHIPClusters.cpp | 18 - .../zap-generated/IMClusterCommandHandler.cpp | 47 - .../zap-generated/CHIPClientCallbacks.cpp | 3116 ------- .../zap-generated/CHIPClientCallbacks.h | 90 - .../zap-generated/CHIPClusters.cpp | 7879 ----------------- .../zap-generated/CHIPClusters.h | 401 - .../zap-generated/IMClusterCommandHandler.cpp | 3980 --------- .../zap-generated/CHIPClientCallbacks.cpp | 18 - .../zap-generated/CHIPClientCallbacks.h | 2 - .../zap-generated/CHIPClusters.cpp | 18 - .../zap-generated/IMClusterCommandHandler.cpp | 43 - .../zap-generated/CHIPClientCallbacks.cpp | 258 - .../zap-generated/CHIPClientCallbacks.h | 11 - .../zap-generated/CHIPClusters.cpp | 989 --- .../zap-generated/CHIPClusters.h | 49 - .../zap-generated/IMClusterCommandHandler.cpp | 268 - .../zap-generated/CHIPClientCallbacks.cpp | 174 - .../zap-generated/CHIPClientCallbacks.h | 11 - .../zap-generated/CHIPClusters.cpp | 190 - .../lighting-app/zap-generated/CHIPClusters.h | 10 - .../zap-generated/IMClusterCommandHandler.cpp | 271 - .../zap-generated/CHIPClientCallbacks.cpp | 18 - .../zap-generated/CHIPClientCallbacks.h | 2 - .../lock-app/zap-generated/CHIPClusters.cpp | 18 - .../zap-generated/IMClusterCommandHandler.cpp | 43 - .../zap-generated/CHIPClientCallbacks.cpp | 132 - .../zap-generated/CHIPClientCallbacks.h | 6 - .../zap-generated/CHIPClusters.cpp | 40 - .../zap-generated/IMClusterCommandHandler.cpp | 35 - .../zap-generated/CHIPClientCallbacks.cpp | 18 - .../zap-generated/CHIPClientCallbacks.h | 2 - .../zap-generated/CHIPClusters.cpp | 18 - .../zap-generated/IMClusterCommandHandler.cpp | 35 - .../zap-generated/CHIPClientCallbacks.cpp | 174 - .../zap-generated/CHIPClientCallbacks.h | 11 - .../zap-generated/CHIPClusters.cpp | 188 - .../zap-generated/CHIPClusters.h | 10 - .../zap-generated/IMClusterCommandHandler.cpp | 227 - .../zap-generated/CHIPClientCallbacks.cpp | 199 - .../app1/zap-generated/CHIPClientCallbacks.h | 6 - .../app1/zap-generated/CHIPClusters.cpp | 568 -- .../app1/zap-generated/CHIPClusters.h | 27 - .../zap-generated/IMClusterCommandHandler.cpp | 55 - .../zap-generated/CHIPClientCallbacks.cpp | 199 - .../app2/zap-generated/CHIPClientCallbacks.h | 6 - .../app2/zap-generated/CHIPClusters.cpp | 568 -- .../app2/zap-generated/CHIPClusters.h | 27 - .../zap-generated/IMClusterCommandHandler.cpp | 55 - .../zap-generated/CHIPClientCallbacks.cpp | 132 - .../zap-generated/CHIPClientCallbacks.h | 6 - .../pump-app/zap-generated/CHIPClusters.cpp | 44 - .../zap-generated/IMClusterCommandHandler.cpp | 47 - .../zap-generated/CHIPClientCallbacks.cpp | 132 - .../zap-generated/CHIPClientCallbacks.h | 6 - .../zap-generated/CHIPClusters.cpp | 519 -- .../zap-generated/CHIPClusters.h | 22 - .../zap-generated/IMClusterCommandHandler.cpp | 39 - .../zap-generated/CHIPClientCallbacks.cpp | 18 - .../zap-generated/CHIPClientCallbacks.h | 2 - .../zap-generated/CHIPClusters.cpp | 18 - .../zap-generated/IMClusterCommandHandler.cpp | 39 - .../zap-generated/CHIPClientCallbacks.cpp | 145 - .../zap-generated/CHIPClientCallbacks.h | 7 - .../thermostat/zap-generated/CHIPClusters.cpp | 118 - .../thermostat/zap-generated/CHIPClusters.h | 4 - .../zap-generated/IMClusterCommandHandler.cpp | 162 - .../zap-generated/CHIPClientCallbacks.cpp | 397 - .../zap-generated/CHIPClientCallbacks.h | 26 - .../tv-app/zap-generated/CHIPClusters.cpp | 848 -- .../tv-app/zap-generated/CHIPClusters.h | 43 - .../zap-generated/IMClusterCommandHandler.cpp | 862 -- .../zap-generated/CHIPClientCallbacks.cpp | 260 - .../zap-generated/CHIPClientCallbacks.h | 6 - .../zap-generated/CHIPClusters.cpp | 1285 --- .../zap-generated/CHIPClusters.h | 65 - .../zap-generated/IMClusterCommandHandler.cpp | 87 - .../zap-generated/CHIPClientCallbacks.cpp | 18 - .../zap-generated/CHIPClientCallbacks.h | 2 - .../window-app/zap-generated/CHIPClusters.cpp | 18 - .../zap-generated/IMClusterCommandHandler.cpp | 43 - 139 files changed, 13 insertions(+), 28300 deletions(-) delete mode 100644 src/app/DeviceControllerInteractionModelDelegate.h delete mode 100644 src/app/tests/TestCHIPDeviceCallbacksMgr.cpp delete mode 100644 src/app/util/CHIPDeviceCallbacksMgr.cpp delete mode 100644 src/app/util/CHIPDeviceCallbacksMgr.h delete mode 100644 src/app/util/im-client-callbacks.cpp delete mode 100644 src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt delete mode 100644 src/app/zap-templates/templates/app/CHIPClusters-src.zapt delete mode 100644 zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/all-clusters-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/bridge-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/bridge-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/door-lock-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/door-lock-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/light-switch-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/lock-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/lock-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/log-source-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/log-source-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/ota-provider-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/ota-provider-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/placeholder/app1/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/placeholder/app1/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/placeholder/app2/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/placeholder/app2/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/pump-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/pump-controller-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/temperature-measurement-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/temperature-measurement-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/thermostat/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/tv-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/tv-casting-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/tv-casting-app/zap-generated/CHIPClusters.cpp delete mode 100644 zzz_generated/window-app/zap-generated/CHIPClientCallbacks.cpp delete mode 100644 zzz_generated/window-app/zap-generated/CHIPClusters.cpp diff --git a/.gitattributes b/.gitattributes index 01e7c0e597cea2..7bba4013a0af6f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,7 +3,6 @@ # Same for files in zap-generated folders **/zap-generated/** linguist-generated # And some specific generated files -src/controller/python/chip/clusters/CHIPClusters.cpp linguist-generated src/controller/python/chip/clusters/CHIPClusters.py linguist-generated src/controller/python/chip/clusters/Objects.py linguist-generated src/darwin/Framework/CHIPTests/CHIPClustersTests.m linguist-generated diff --git a/config/mbed/CMakeLists.txt b/config/mbed/CMakeLists.txt index feae8df84b8802..5e7a6fa8bbc517 100644 --- a/config/mbed/CMakeLists.txt +++ b/config/mbed/CMakeLists.txt @@ -463,7 +463,6 @@ if (CONFIG_CHIP_OTA_REQUESTOR) target_sources(${APP_TARGET} PRIVATE ${CHIP_ROOT}/zzz_generated/ota-requestor-app/zap-generated/callback-stub.cpp - ${CHIP_ROOT}/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp ${CHIP_ROOT}/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp ${CHIP_ROOT}/src/app/clusters/ota-requestor/OTARequestor.cpp diff --git a/examples/all-clusters-app/all-clusters-common/BUILD.gn b/examples/all-clusters-app/all-clusters-common/BUILD.gn index 90751a8106cea9..0210fcedb2c646 100644 --- a/examples/all-clusters-app/all-clusters-common/BUILD.gn +++ b/examples/all-clusters-app/all-clusters-common/BUILD.gn @@ -22,5 +22,4 @@ chip_data_model("all-clusters-common") { zap_pregenerated_dir = "${chip_root}/zzz_generated/all-clusters-app/zap-generated" is_server = true - use_default_client_callbacks = true } diff --git a/examples/all-clusters-app/ameba/chip_main.cmake b/examples/all-clusters-app/ameba/chip_main.cmake index 752571498d2a8e..b549aab9af32a2 100755 --- a/examples/all-clusters-app/ameba/chip_main.cmake +++ b/examples/all-clusters-app/ameba/chip_main.cmake @@ -125,10 +125,8 @@ endif (matter_enable_ota_requestor) list( APPEND ${list_chip_main_sources} - ${chip_dir}/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp ${chip_dir}/zzz_generated/all-clusters-app/zap-generated/callback-stub.cpp ${chip_dir}/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp - ${chip_dir}/zzz_generated/all-clusters-app/zap-generated/CHIPClusters.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index 7d18414b2fb274..ea0aaa8e96753f 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -54,8 +54,6 @@ target_sources(${APP_TARGET} PRIVATE ${MBED_COMMON}/util/LEDWidget.cpp ${GEN_DIR}/all-clusters-app/zap-generated/callback-stub.cpp - ${GEN_DIR}/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp - ${GEN_DIR}/all-clusters-app/zap-generated/CHIPClusters.cpp ${GEN_DIR}/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp ${GEN_DIR}/app-common/app-common/zap-generated/attributes/Accessors.cpp ${GEN_DIR}/app-common/app-common/zap-generated/cluster-objects.cpp diff --git a/examples/chip-tool/commands/pairing/PairingCommand.h b/examples/chip-tool/commands/pairing/PairingCommand.h index 6d2e98fb36636a..94d55969e9a0ea 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -20,7 +20,6 @@ #include "../common/CHIPCommand.h" #include -#include #include #include diff --git a/examples/lighting-app/ameba/chip_main.cmake b/examples/lighting-app/ameba/chip_main.cmake index 31731d1a34d354..67328f0dfeb4dc 100755 --- a/examples/lighting-app/ameba/chip_main.cmake +++ b/examples/lighting-app/ameba/chip_main.cmake @@ -23,10 +23,8 @@ endif (matter_enable_ota_requestor) list( APPEND ${list_chip_main_sources} - ${chip_dir}/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp ${chip_dir}/zzz_generated/lighting-app/zap-generated/callback-stub.cpp ${chip_dir}/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp - ${chip_dir}/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp ${chip_dir}/examples/lighting-app/lighting-common/color_format/color_format.cpp diff --git a/examples/lighting-app/mbed/CMakeLists.txt b/examples/lighting-app/mbed/CMakeLists.txt index c0965aeca4f35c..e4734238239a72 100644 --- a/examples/lighting-app/mbed/CMakeLists.txt +++ b/examples/lighting-app/mbed/CMakeLists.txt @@ -54,7 +54,6 @@ target_sources(${APP_TARGET} PRIVATE ) chip_configure_data_model(${APP_TARGET} - INCLUDE_CLIENT_CALLBACKS INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../lighting-common/lighting-app.zap GEN_DIR ${GEN_DIR}/lighting-app/zap-generated diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 1931b7c950d2fd..c02a3901afd693 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -88,7 +88,6 @@ target_sources(app PRIVATE main/main.cpp main/ZclCallbacks.cpp ${GEN_DIR}/lighting-app/zap-generated/callback-stub.cpp - ${GEN_DIR}/lighting-app/zap-generated/CHIPClusters.cpp ${GEN_DIR}/lighting-app/zap-generated/IMClusterCommandHandler.cpp ${NRFCONNECT_COMMON}/util/LEDWidget.cpp ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp @@ -96,7 +95,6 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/clusters/ota-requestor/BDXDownloader.cpp) chip_configure_data_model(app - INCLUDE_CLIENT_CALLBACKS INCLUDE_SERVER ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../lighting-common/lighting-app.zap GEN_DIR ${GEN_DIR}/lighting-app/zap-generated diff --git a/examples/ota-requestor-app/ameba/chip_main.cmake b/examples/ota-requestor-app/ameba/chip_main.cmake index eae13963755f71..9f3b556f74e171 100644 --- a/examples/ota-requestor-app/ameba/chip_main.cmake +++ b/examples/ota-requestor-app/ameba/chip_main.cmake @@ -15,8 +15,6 @@ list( ${chip_dir}/zzz_generated/ota-requestor-app/zap-generated/callback-stub.cpp ${chip_dir}/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp - ${chip_dir}/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp - ${chip_dir}/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp ${chip_dir}/examples/ota-requestor-app/ameba/main/chipinterface.cpp ${chip_dir}/examples/ota-requestor-app/ameba/main/Globals.cpp @@ -27,7 +25,6 @@ list( ${chip_dir}/src/app/clusters/ota-requestor/BDXDownloader.cpp ${chip_dir}/src/app/clusters/ota-requestor/OTARequestor.cpp ${chip_dir}/src/app/clusters/ota-requestor/ota-requestor-server.cpp - ${chip_dir}/src/app/util/im-client-callbacks.cpp ) add_library( diff --git a/examples/ota-requestor-app/mbed/CMakeLists.txt b/examples/ota-requestor-app/mbed/CMakeLists.txt index 5e956b4af0fd01..943802cf07245b 100644 --- a/examples/ota-requestor-app/mbed/CMakeLists.txt +++ b/examples/ota-requestor-app/mbed/CMakeLists.txt @@ -59,7 +59,6 @@ target_sources(${APP_TARGET} PRIVATE chip_configure_data_model(${APP_TARGET} INCLUDE_SERVER - INCLUDE_CLIENT_CALLBACKS ZAP_FILE ${CHIP_ROOT}/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap GEN_DIR ${CHIP_ROOT}/zzz_generated/ota-requestor-app/zap-generated ) diff --git a/examples/ota-requestor-app/ota-requestor-common/BUILD.gn b/examples/ota-requestor-app/ota-requestor-common/BUILD.gn index 4ba7b05ddb2b2e..edce1324ea7e1f 100644 --- a/examples/ota-requestor-app/ota-requestor-common/BUILD.gn +++ b/examples/ota-requestor-app/ota-requestor-common/BUILD.gn @@ -26,8 +26,6 @@ chip_data_model("ota-requestor-common") { zap_pregenerated_dir = "${chip_root}/zzz_generated/ota-requestor-app/zap-generated" - use_default_client_callbacks = true - deps = [ "${chip_root}/src/lib" ] public_configs = [ ":config" ] diff --git a/examples/tv-app/tv-common/BUILD.gn b/examples/tv-app/tv-common/BUILD.gn index 181f688fd286bf..f723e6f0db12f1 100644 --- a/examples/tv-app/tv-common/BUILD.gn +++ b/examples/tv-app/tv-common/BUILD.gn @@ -21,5 +21,4 @@ chip_data_model("tv-common") { zap_pregenerated_dir = "${chip_root}/zzz_generated/tv-app/zap-generated" is_server = true - use_default_client_callbacks = true } diff --git a/examples/tv-casting-app/linux/main.cpp b/examples/tv-casting-app/linux/main.cpp index ba8c1c8543ef0f..86dfb92aed7907 100644 --- a/examples/tv-casting-app/linux/main.cpp +++ b/examples/tv-casting-app/linux/main.cpp @@ -230,7 +230,6 @@ void DeviceEventCallback(const DeviceLayer::ChipDeviceEvent * event, intptr_t ar .idAllocator = &(server->GetSessionIDAllocator()), .fabricTable = &(server->GetFabricTable()), .clientPool = &gCASEClientPool, - .imDelegate = chip::Platform::New(), }; PeerId peerID = fabric->GetPeerIdForNode(tvNodeId); diff --git a/examples/tv-casting-app/tv-casting-common/BUILD.gn b/examples/tv-casting-app/tv-casting-common/BUILD.gn index 2c65903dbde9ee..7b88b5a710e901 100644 --- a/examples/tv-casting-app/tv-casting-common/BUILD.gn +++ b/examples/tv-casting-app/tv-casting-common/BUILD.gn @@ -22,5 +22,4 @@ chip_data_model("tv-casting-common") { zap_pregenerated_dir = "${chip_root}/zzz_generated/tv-casting-app/zap-generated" is_server = true - use_default_client_callbacks = true } diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index 26ba877e790c62..8b205f79387f81 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -152,7 +152,6 @@ static_library("app") { public_deps = [ ":app_buildconfig", "${chip_root}/src/access", - "${chip_root}/src/app/util:device_callbacks_manager", "${chip_root}/src/lib/support", "${chip_root}/src/messaging", "${chip_root}/src/protocols/secure_channel", diff --git a/src/app/DeviceControllerInteractionModelDelegate.h b/src/app/DeviceControllerInteractionModelDelegate.h deleted file mode 100644 index 93f0518909c17e..00000000000000 --- a/src/app/DeviceControllerInteractionModelDelegate.h +++ /dev/null @@ -1,74 +0,0 @@ -#pragma once - -#include - -#include -#include -#include -#include -#include - -namespace chip { -namespace Controller { -/** - * @brief - * Used for make current OnSuccessCallback & OnFailureCallback works when interaction model landed, it will be removed - * after #6308 is landed. - * - * TODO:(#8967) Implementation of CommandSender::Callback should be removed after switching to ClusterObjects. - */ -class DeviceControllerInteractionModelDelegate : public chip::app::CommandSender::Callback, public chip::app::WriteClient::Callback -{ -public: - DeviceControllerInteractionModelDelegate() {} - - void OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aPath, - const chip::app::StatusIB & aStatus, TLV::TLVReader * aData) override - { - // Generally IM has more detailed errors than ember library, here we always use the, the actual handling of the - // commands should implement full IMDelegate. - // #6308 By implement app side IM delegate, we should be able to accept detailed error codes. - // Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts - // EmberAfStatus instead of IM status code. - if (aData != nullptr) - { - chip::app::DispatchSingleClusterResponseCommand(aPath, *aData, apCommandSender); - } - else - { - IMDefaultResponseCallback(apCommandSender, EMBER_ZCL_STATUS_SUCCESS); - } - } - - void OnError(const app::CommandSender * apCommandSender, CHIP_ERROR aError) override - { - // The IMDefaultResponseCallback started out life as an Ember function, so it only accepted - // Ember status codes. Consequently, let's convert the error over to a meaningful Ember status before dispatching. - // - // This however, results in loss (non-IM errors and cluster-specific - // status codes are completely discarded). - // - // For now, #10331 tracks this issue. - app::StatusIB status(aError); - IMDefaultResponseCallback(apCommandSender, app::ToEmberAfStatus(status.mStatus)); - } - - void OnDone(app::CommandSender * apCommandSender) override { return chip::Platform::Delete(apCommandSender); } - - void OnResponse(const app::WriteClient * apWriteClient, const app::ConcreteAttributePath & aPath, - app::StatusIB attributeStatus) override - { - IMWriteResponseCallback(apWriteClient, attributeStatus.mStatus); - } - - void OnError(const app::WriteClient * apWriteClient, CHIP_ERROR aError) override - { - app::StatusIB status(aError); - IMWriteResponseCallback(apWriteClient, status.mStatus); - } - - void OnDone(app::WriteClient * apWriteClient) override {} -}; - -} // namespace Controller -} // namespace chip diff --git a/src/app/DeviceProxy.cpp b/src/app/DeviceProxy.cpp index 3134c2156b23db..8488e78f24f9f5 100644 --- a/src/app/DeviceProxy.cpp +++ b/src/app/DeviceProxy.cpp @@ -46,26 +46,4 @@ CHIP_ERROR DeviceProxy::SendCommands(app::CommandSender * commandObj, OptionalSendCommandRequest(GetSecureSession().Value(), timeout); } -void DeviceProxy::AddIMResponseHandler(void * commandObj, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, app::TLVDataFilter tlvDataFilter) -{ - // Interaction model uses the object instead of a sequence number as the identifier of transactions. - // Since the objects can be identified by its pointer which fits into a uint64 value (the type of NodeId), we use it for the - // "node id" field in callback manager. - static_assert(std::is_same::value, "chip::NodeId is not uint64_t"); - chip::NodeId transactionId = reinterpret_cast(commandObj); - mCallbacksMgr.AddResponseCallback(transactionId, 0 /* seqNum, always 0 for IM before #6559 */, onSuccessCallback, - onFailureCallback, tlvDataFilter); -} - -void DeviceProxy::CancelIMResponseHandler(void * commandObj) -{ - // Interaction model uses the object instead of a sequence number as the identifier of transactions. - // Since the objects can be identified by its pointer which fits into a uint64 value (the type of NodeId), we use it for the - // "node id" field in callback manager. - static_assert(std::is_same::value, "chip::NodeId is not uint64_t"); - chip::NodeId transactionId = reinterpret_cast(commandObj); - mCallbacksMgr.CancelResponseCallback(transactionId, 0 /* seqNum, always 0 for IM before #6559 */); -} - } // namespace chip diff --git a/src/app/DeviceProxy.h b/src/app/DeviceProxy.h index aa526e71178d48..6a3e214b89d166 100644 --- a/src/app/DeviceProxy.h +++ b/src/app/DeviceProxy.h @@ -27,9 +27,7 @@ #pragma once #include -#include #include -#include #include #include #include @@ -55,14 +53,6 @@ class DLL_EXPORT DeviceProxy virtual CHIP_ERROR SendCommands(app::CommandSender * commandObj, chip::Optional timeout = NullOptional); - // Interaction model uses the object and callback interface instead of sequence number to mark different transactions. - virtual void AddIMResponseHandler(void * commandObj, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, app::TLVDataFilter tlvDataFilter = nullptr); - - virtual void CancelIMResponseHandler(void * commandObj); - - virtual Controller::DeviceControllerInteractionModelDelegate * GetInteractionModelDelegate() = 0; - virtual Messaging::ExchangeManager * GetExchangeManager() const = 0; virtual chip::Optional GetSecureSession() const = 0; @@ -78,8 +68,6 @@ class DLL_EXPORT DeviceProxy virtual uint8_t GetNextSequenceNumber() = 0; - app::CHIPDeviceCallbacksMgr & mCallbacksMgr = app::CHIPDeviceCallbacksMgr::GetInstance(); - ReliableMessageProtocolConfig mMRPConfig = gDefaultMRPConfig; }; diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index 75fd8d18e97a75..b88eb41f282914 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -304,8 +304,6 @@ class InteractionModelEngine : public Messaging::ExchangeDelegate, public Comman void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip::TLV::TLVReader & aReader, CommandHandler * apCommandObj); -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, chip::TLV::TLVReader & aReader, - CommandSender * apCommandObj); /** * Check whether the given cluster exists on the given endpoint and supports the given command. diff --git a/src/app/OperationalDeviceProxy.h b/src/app/OperationalDeviceProxy.h index 292c58c07728ea..95cca4a8825455 100644 --- a/src/app/OperationalDeviceProxy.h +++ b/src/app/OperationalDeviceProxy.h @@ -55,8 +55,6 @@ struct DeviceProxyInitParams FabricTable * fabricTable = nullptr; CASEClientPoolDelegate * clientPool = nullptr; - Controller::DeviceControllerInteractionModelDelegate * imDelegate = nullptr; - Optional mrpLocalConfig = Optional::Missing(); CHIP_ERROR Validate() const @@ -170,8 +168,6 @@ class DLL_EXPORT OperationalDeviceProxy : public DeviceProxy, SessionReleaseDele CHIP_ERROR ShutdownSubscriptions() override; - Controller::DeviceControllerInteractionModelDelegate * GetInteractionModelDelegate() override { return mInitParams.imDelegate; } - Messaging::ExchangeManager * GetExchangeManager() const override { return mInitParams.exchangeMgr; } chip::Optional GetSecureSession() const override { return mSecureSession.ToOptional(); } diff --git a/src/app/chip_data_model.cmake b/src/app/chip_data_model.cmake index 91f1c77268c45f..df2c52335af0bd 100644 --- a/src/app/chip_data_model.cmake +++ b/src/app/chip_data_model.cmake @@ -54,14 +54,7 @@ endfunction() # supported by the application. # function(chip_configure_data_model APP_TARGET) - cmake_parse_arguments(ARG "INCLUDE_CLIENT_CALLBACKS;INCLUDE_SERVER" "ZAP_FILE;GEN_DIR" "" ${ARGN}) - - if (ARG_INCLUDE_CLIENT_CALLBACKS) - target_sources(${APP_TARGET} PRIVATE - ${CHIP_APP_BASE_DIR}/util/im-client-callbacks.cpp - ${ARG_GEN_DIR}/CHIPClientCallbacks.cpp - ) - endif() + cmake_parse_arguments(ARG "INCLUDE_SERVER" "ZAP_FILE;GEN_DIR" "" ${ARGN}) if (ARG_INCLUDE_SERVER) target_sources(${APP_TARGET} PRIVATE diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 78ff3e3474a6d7..650b375145f69d 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -35,9 +35,6 @@ _zap_cluster_list_script = get_path_info("zap_cluster_list.py", "abspath") # Names of the clusters directories to compile. # Deprecated, specify zap_file instead. # -# use_default_client_callbacks -# Include CHIPClientCallbacks.cpp. -# # Forwards all the remaining variables to the source_set. # template("chip_data_model") { @@ -56,10 +53,6 @@ template("chip_data_model") { _use_tests_apis = defined(invoker.use_tests_apis) && invoker.use_tests_apis - _use_default_client_callbacks = - defined(invoker.use_default_client_callbacks) && - invoker.use_default_client_callbacks - source_set(_data_model_name) { forward_variables_from(invoker, "*", @@ -67,7 +60,6 @@ template("chip_data_model") { "zap_pregenerated_dir", "cluster_sources", "zap_file", - "use_default_client_callbacks", "is_server", ]) @@ -166,17 +158,7 @@ template("chip_data_model") { sources += [ "${invoker.zap_pregenerated_dir}/callback-stub.cpp" ] if (chip_controller) { - sources += [ - "${invoker.zap_pregenerated_dir}/CHIPClusters.cpp", - "${invoker.zap_pregenerated_dir}/CHIPClusters.h", - ] - } - - if (_use_default_client_callbacks) { - sources += [ - "${_app_root}/util/im-client-callbacks.cpp", - "${invoker.zap_pregenerated_dir}/CHIPClientCallbacks.cpp", - ] + sources += [ "${invoker.zap_pregenerated_dir}/CHIPClusters.h" ] } if (_use_default_im_dispatch) { diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index ef854b17920700..0a417b8a468c3d 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -87,7 +87,6 @@ Server::Server() : .idAllocator = &mSessionIDAllocator, .fabricTable = &mFabrics, .clientPool = &mCASEClientPool, - .imDelegate = nullptr, }, .dnsCache = nullptr, .devicePool = &mDevicePool, diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index 0fab92b3a179e5..1b9ae6368d4f19 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -44,7 +44,6 @@ chip_test_suite("tests") { "TestAttributePathExpandIterator.cpp", "TestAttributeValueEncoder.cpp", "TestBuilderParser.cpp", - "TestCHIPDeviceCallbacksMgr.cpp", "TestClusterInfo.cpp", "TestCommandInteraction.cpp", "TestCommandPathParams.cpp", @@ -77,7 +76,6 @@ chip_test_suite("tests") { "${chip_root}/src/app", "${chip_root}/src/app/common:cluster-objects", "${chip_root}/src/app/tests:helpers", - "${chip_root}/src/app/util:device_callbacks_manager", "${chip_root}/src/app/util/mock:mock_ember", "${chip_root}/src/lib/core", "${nlunit_test_root}:nlunit-test", diff --git a/src/app/tests/TestCHIPDeviceCallbacksMgr.cpp b/src/app/tests/TestCHIPDeviceCallbacksMgr.cpp deleted file mode 100644 index a500d79befae11..00000000000000 --- a/src/app/tests/TestCHIPDeviceCallbacksMgr.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -namespace chip { -namespace app { -namespace { - -using SuccessCallback = void (*)(void * context, uint64_t value); -using FailureCallback = void (*)(void * context, CHIP_ERROR error); - -void ShouldGetSingleResponseCallback(nlTestSuite * testSuite, void * apContext) -{ - auto & callbacks = CHIPDeviceCallbacksMgr::GetInstance(); - - static constexpr NodeId kTestNodeId = 0x9b3780f93739918d; - static constexpr uint8_t kTestSequence = 0x8b; - static constexpr uint64_t kTestArgument = 0x973f2e7071e0c12a; - static constexpr CHIP_ERROR kTestError = CHIP_ERROR_INVALID_ARGUMENT; - - struct CallbackContext - { - nlTestSuite * const testSuite; - } callbackContext = { testSuite }; - - const auto onSuccess = [](void * opaqueContext, uint64_t value) { - CallbackContext & context = *static_cast(opaqueContext); - - NL_TEST_ASSERT(context.testSuite, value == kTestArgument); - }; - - const auto onFailure = [](void * opaqueContext, CHIP_ERROR error) { - CallbackContext & context = *static_cast(opaqueContext); - - NL_TEST_ASSERT(context.testSuite, error == kTestError); - }; - - Callback::Callback successCallback{ onSuccess, &callbackContext }; - Callback::Callback failureCallback{ onFailure, &callbackContext }; - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId, kTestSequence, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_ERROR_KEY_NOT_FOUND); - } - - { - CHIP_ERROR error = - callbacks.AddResponseCallback(kTestNodeId, kTestSequence, successCallback.Cancel(), failureCallback.Cancel()); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId, kTestSequence, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - - auto outSuccessCallback = decltype(successCallback)::FromCancelable(successCancelable); - auto outFailureCallback = decltype(failureCallback)::FromCancelable(failureCancelable); - - NL_TEST_ASSERT(testSuite, outSuccessCallback == &successCallback); - NL_TEST_ASSERT(testSuite, outFailureCallback == &failureCallback); - - outSuccessCallback->mCall(outSuccessCallback->mContext, kTestArgument); - outFailureCallback->mCall(outFailureCallback->mContext, kTestError); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId, kTestSequence, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_ERROR_KEY_NOT_FOUND); - } -} - -void ShouldGetMultipleResponseCallbacks(nlTestSuite * testSuite, void * apContext) -{ - auto & callbacks = CHIPDeviceCallbacksMgr::GetInstance(); - - struct CallbackContext - { - nlTestSuite * const testSuite; - } callbackContext = { testSuite }; - - const auto onSuccess = [](void * opaqueContext, uint64_t value) { - CallbackContext & context = *static_cast(opaqueContext); - - // Not called. - NL_TEST_ASSERT(context.testSuite, false); - }; - - const auto onFailure = [](void * opaqueContext, CHIP_ERROR error) { - CallbackContext & context = *static_cast(opaqueContext); - - // Not called. - NL_TEST_ASSERT(context.testSuite, false); - }; - - Callback::Callback successCallback{ onSuccess, &callbackContext }; - Callback::Callback failureCallback{ onFailure, &callbackContext }; - - Callback::Callback successCallback2{ onSuccess, &callbackContext }; - Callback::Callback failureCallback2{ onFailure, &callbackContext }; - - Callback::Callback successCallback3{ onSuccess, &callbackContext }; - Callback::Callback failureCallback3{ onFailure, &callbackContext }; - - static constexpr NodeId kTestNodeId1 = 0x2f699f085d799846; - static constexpr NodeId kTestNodeId2 = 0xc354d359ee0b47f3; - static constexpr uint8_t kTestSequence1 = 0x8b; - static constexpr uint8_t kTestSequence2 = kTestSequence1 + 1; - - { - CHIP_ERROR error = - callbacks.AddResponseCallback(kTestNodeId1, kTestSequence1, successCallback.Cancel(), failureCallback.Cancel()); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId2, kTestSequence1, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_ERROR_KEY_NOT_FOUND); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId1, kTestSequence2, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_ERROR_KEY_NOT_FOUND); - } - - { - CHIP_ERROR error = - callbacks.AddResponseCallback(kTestNodeId1, kTestSequence1, successCallback.Cancel(), failureCallback.Cancel()); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - } - - { - CHIP_ERROR error = - callbacks.AddResponseCallback(kTestNodeId2, kTestSequence1, successCallback2.Cancel(), failureCallback2.Cancel()); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - } - - { - CHIP_ERROR error = - callbacks.AddResponseCallback(kTestNodeId1, kTestSequence2, successCallback3.Cancel(), failureCallback3.Cancel()); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId2, kTestSequence1, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - - auto outSuccessCallback = decltype(successCallback2)::FromCancelable(successCancelable); - auto outFailureCallback = decltype(failureCallback2)::FromCancelable(failureCancelable); - - NL_TEST_ASSERT(testSuite, outSuccessCallback == &successCallback2); - NL_TEST_ASSERT(testSuite, outFailureCallback == &failureCallback2); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId1, kTestSequence2, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - - auto outSuccessCallback = decltype(successCallback2)::FromCancelable(successCancelable); - auto outFailureCallback = decltype(failureCallback2)::FromCancelable(failureCancelable); - - NL_TEST_ASSERT(testSuite, outSuccessCallback == &successCallback3); - NL_TEST_ASSERT(testSuite, outFailureCallback == &failureCallback3); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId1, kTestSequence1, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - - auto outSuccessCallback = decltype(successCallback)::FromCancelable(successCancelable); - auto outFailureCallback = decltype(failureCallback)::FromCancelable(failureCancelable); - - NL_TEST_ASSERT(testSuite, outSuccessCallback == &successCallback); - NL_TEST_ASSERT(testSuite, outFailureCallback == &failureCallback); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId1, kTestSequence1, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_ERROR_KEY_NOT_FOUND); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId1, kTestSequence2, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_ERROR_KEY_NOT_FOUND); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId2, kTestSequence1, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_ERROR_KEY_NOT_FOUND); - } -} - -void ShouldFailGetCanceledResponseCallback(nlTestSuite * testSuite, void * apContext) -{ - auto & callbacks = CHIPDeviceCallbacksMgr::GetInstance(); - - static constexpr NodeId kTestNodeId = 0x9b3780f93739918d; - static constexpr uint8_t kTestSequence = 0x8b; - - struct CallbackContext - { - nlTestSuite * const testSuite; - } callbackContext = { testSuite }; - - const auto onSuccess = [](void * opaqueContext, uint64_t value) { - CallbackContext & context = *static_cast(opaqueContext); - - // Not called. - NL_TEST_ASSERT(context.testSuite, false); - }; - - const auto onFailure = [](void * opaqueContext, CHIP_ERROR error) { - CallbackContext & context = *static_cast(opaqueContext); - - // Not called. - NL_TEST_ASSERT(context.testSuite, false); - }; - - Callback::Callback successCallback{ onSuccess, &callbackContext }; - Callback::Callback failureCallback{ onFailure, &callbackContext }; - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId, kTestSequence, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_ERROR_KEY_NOT_FOUND); - } - - { - CHIP_ERROR error = - callbacks.AddResponseCallback(kTestNodeId, kTestSequence, successCallback.Cancel(), failureCallback.Cancel()); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId, kTestSequence, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_NO_ERROR); - - auto outSuccessCallback = decltype(successCallback)::FromCancelable(successCancelable); - auto outFailureCallback = decltype(failureCallback)::FromCancelable(failureCancelable); - - NL_TEST_ASSERT(testSuite, outSuccessCallback == &successCallback); - NL_TEST_ASSERT(testSuite, outFailureCallback == &failureCallback); - } - - { - Callback::Cancelable * successCancelable = nullptr; - Callback::Cancelable * failureCancelable = nullptr; - CHIP_ERROR error = callbacks.GetResponseCallback(kTestNodeId, kTestSequence, &successCancelable, &failureCancelable); - NL_TEST_ASSERT(testSuite, error == CHIP_ERROR_KEY_NOT_FOUND); - } -} - -} // namespace -} // namespace app -} // namespace chip - -const nlTest sTests[] = { - NL_TEST_DEF("ShouldGetSingleResponseCallback", chip::app::ShouldGetSingleResponseCallback), // - NL_TEST_DEF("ShouldGetMultipleResponseCallbacks", chip::app::ShouldGetMultipleResponseCallbacks), // - NL_TEST_DEF("ShouldFailGetCanceledResponseCallback", chip::app::ShouldFailGetCanceledResponseCallback), // - NL_TEST_SENTINEL(), // -}; - -int TestCHIPDeviceCallbacksMgr() -{ - // clang-format off - nlTestSuite theSuite = - { - "TestCHIPDeviceCallbacksMgr", - &sTests[0], - nullptr, - nullptr - }; - // clang-format on - - nlTestRunner(&theSuite, nullptr); - - return (nlTestRunnerStats(&theSuite)); -} - -CHIP_REGISTER_TEST_SUITE(TestCHIPDeviceCallbacksMgr) diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp index 3062cda18bcdc2..c0a040d3968a27 100644 --- a/src/app/tests/TestCommandInteraction.cpp +++ b/src/app/tests/TestCommandInteraction.cpp @@ -103,15 +103,6 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip chip::isCommandDispatched = true; } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, chip::TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - ChipLogDetail(Controller, - "Received Cluster Command: Endpoint=%" PRIx16 " Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI, - aCommandPath.mEndpointId, ChipLogValueMEI(aCommandPath.mClusterId), ChipLogValueMEI(aCommandPath.mCommandId)); - // Nothing todo. -} - class MockCommandSenderCallback : public CommandSender::Callback { public: diff --git a/src/app/tests/integration/chip_im_initiator.cpp b/src/app/tests/integration/chip_im_initiator.cpp index e2968780d6fa06..3068e83a4a9739 100644 --- a/src/app/tests/integration/chip_im_initiator.cpp +++ b/src/app/tests/integration/chip_im_initiator.cpp @@ -645,23 +645,6 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip // Nothing todo. } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, chip::TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - if (aCommandPath.mClusterId != kTestClusterId || aCommandPath.mCommandId != kTestCommandId || - aCommandPath.mEndpointId != kTestEndpointId) - { - return; - } - - if (aReader.GetLength() != 0) - { - chip::TLV::Debug::Dump(aReader, TLVPrettyPrinter); - } - - gLastCommandResult = TestCommandResult::kSuccess; -} - CHIP_ERROR ReadSingleClusterData(const Access::SubjectDescriptor & aSubjectDescriptor, bool aIsFabricFiltered, const ConcreteReadAttributePath & aPath, AttributeReportIBs::Builder & aAttributeReports, AttributeValueEncoder::AttributeEncodeState * apEncoderState) diff --git a/src/app/tests/integration/chip_im_responder.cpp b/src/app/tests/integration/chip_im_responder.cpp index 55479c8fecfdcd..ae7b00f366beee 100644 --- a/src/app/tests/integration/chip_im_responder.cpp +++ b/src/app/tests/integration/chip_im_responder.cpp @@ -97,15 +97,6 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip statusCodeFlipper = !statusCodeFlipper; } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, chip::TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - // Nothing todo. - (void) aCommandPath; - (void) aReader; - (void) apCommandObj; -} - CHIP_ERROR ReadSingleClusterData(const Access::SubjectDescriptor & aSubjectDescriptor, bool aIsFabricFiltered, const ConcreteReadAttributePath & aPath, AttributeReportIBs::Builder & aAttributeReports, AttributeValueEncoder::AttributeEncodeState * apEncoderState) diff --git a/src/app/util/BUILD.gn b/src/app/util/BUILD.gn index 46276985f3be0b..7c7ec66b7e709c 100644 --- a/src/app/util/BUILD.gn +++ b/src/app/util/BUILD.gn @@ -13,17 +13,3 @@ # limitations under the License. import("//build_overrides/chip.gni") - -source_set("device_callbacks_manager") { - sources = [ - "CHIPDeviceCallbacksMgr.cpp", - "CHIPDeviceCallbacksMgr.h", - ] - - public_deps = [ - "${chip_root}/src/lib/core", - "${chip_root}/src/lib/support", - ] - - cflags = [ "-Wconversion" ] -} diff --git a/src/app/util/CHIPDeviceCallbacksMgr.cpp b/src/app/util/CHIPDeviceCallbacksMgr.cpp deleted file mode 100644 index 50849bca93bb73..00000000000000 --- a/src/app/util/CHIPDeviceCallbacksMgr.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * This file contains implementations for the CallbacksMgr class. The object of this - * class will be used by Controller applications to interact with ZCL messages. - * This class provide mechanism to store callbacks for global message dispatching - * across the ZCL stack. - */ - -#include "CHIPDeviceCallbacksMgr.h" - -#include -#include - -namespace chip { -namespace app { - -CHIPDeviceCallbacksMgr & CHIPDeviceCallbacksMgr::GetInstance() -{ - static CHIPDeviceCallbacksMgr instance; - return instance; -} - -CHIP_ERROR CHIPDeviceCallbacksMgr::AddResponseCallback(NodeId nodeId, uint8_t sequenceNumber, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, TLVDataFilter filter) -{ - VerifyOrReturnError(onSuccessCallback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(onFailureCallback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - - ResponseCallbackInfo info = { nodeId, sequenceNumber }; - static_assert(sizeof(onSuccessCallback->mInfo) >= sizeof(info), "Callback info too large"); - memcpy(&onSuccessCallback->mInfo, &info, sizeof(info)); - memcpy(&onFailureCallback->mInfo, &info, sizeof(info)); - - // If some callbacks have already been registered for the same ResponseCallbackInfo, it usually means that the response - // has not been received for a previous command with the same sequenceNumber. Cancel the previously registered callbacks. - CancelCallback(info, mResponsesSuccess); - CancelCallback(info, mResponsesFailure); - PopResponseFilter(info, nullptr); - - if (filter != nullptr) - { - ReturnErrorOnFailure(AddResponseFilter(info, filter)); - } - mResponsesSuccess.Enqueue(onSuccessCallback); - mResponsesFailure.Enqueue(onFailureCallback); - return CHIP_NO_ERROR; -} - -CHIP_ERROR CHIPDeviceCallbacksMgr::CancelResponseCallback(NodeId nodeId, uint8_t sequenceNumber) -{ - ResponseCallbackInfo info = { nodeId, sequenceNumber }; - CancelCallback(info, mResponsesSuccess); - CancelCallback(info, mResponsesFailure); - PopResponseFilter(info, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR CHIPDeviceCallbacksMgr::AddResponseFilter(const ResponseCallbackInfo & info, TLVDataFilter filter) -{ - constexpr ResponseCallbackInfo kEmptyInfo{ kPlaceholderNodeId, 0 }; - - for (size_t i = 0; i < kTLVFilterPoolSize; i++) - { - if (mTLVFilterPool[i].info == kEmptyInfo) - { - mTLVFilterPool[i].info = info; - mTLVFilterPool[i].filter = filter; - return CHIP_NO_ERROR; - } - } - - return CHIP_ERROR_NO_MEMORY; -} - -CHIP_ERROR CHIPDeviceCallbacksMgr::PopResponseFilter(const ResponseCallbackInfo & info, TLVDataFilter * outFilter) -{ - for (size_t i = 0; i < kTLVFilterPoolSize; i++) - { - if (mTLVFilterPool[i].info == info) - { - if (outFilter != nullptr) - { - *outFilter = mTLVFilterPool[i].filter; - } - mTLVFilterPool[i].info = ResponseCallbackInfo{ kPlaceholderNodeId, 0 }; - mTLVFilterPool[i].filter = nullptr; - return CHIP_NO_ERROR; - } - } - - return CHIP_ERROR_KEY_NOT_FOUND; -} - -CHIP_ERROR CHIPDeviceCallbacksMgr::GetResponseCallback(NodeId nodeId, uint8_t sequenceNumber, - Callback::Cancelable ** onSuccessCallback, - Callback::Cancelable ** onFailureCallback, TLVDataFilter * outFilter) -{ - ResponseCallbackInfo info = { nodeId, sequenceNumber }; - - ReturnErrorOnFailure(GetCallback(info, mResponsesSuccess, onSuccessCallback)); - (*onSuccessCallback)->Cancel(); - - ReturnErrorOnFailure(GetCallback(info, mResponsesFailure, onFailureCallback)); - (*onFailureCallback)->Cancel(); - - if (outFilter == nullptr) - { - PopResponseFilter(info, nullptr); - } - else - { - ReturnErrorOnFailure(PopResponseFilter(info, outFilter)); - } - - return CHIP_NO_ERROR; -} - -} // namespace app -} // namespace chip diff --git a/src/app/util/CHIPDeviceCallbacksMgr.h b/src/app/util/CHIPDeviceCallbacksMgr.h deleted file mode 100644 index 908a4a6e4d8768..00000000000000 --- a/src/app/util/CHIPDeviceCallbacksMgr.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * This file contains definitions for the CallbacksMgr class. The object of this - * class will be used by Controller applications to interact with ZCL messages. - * This class provide mechanism to store callbacks for global message dispatching - * across the ZCL stack. - */ - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include - -namespace chip { -namespace app { - -#ifndef CHIP_DEVICE_CALLBACK_MANAGER_TLV_FILTER_POOL_SIZE -constexpr size_t kTLVFilterPoolSize = 32; -#else -constexpr size_t kTLVFilterPoolSize = CHIP_DEVICE_CALLBACK_MANAGER_TLV_FILTER_POOL_SIZE; -#endif - -/** - * The filter interface for processing data from TLV. - * The caller of the function will pass the original TLV data, the original success and failure callback to this function. - * Since success callback and failure callback contains necessary context, this function itself is stateless. - * The possible implementation of this function might be: - * - Unpack the data with some schema from TLV - * - Call success callback and failure callback according to the result of unpack routine. - * - onFailure MAY be nullptr, in this case, response error will be ignored. (Usually for subscribe responses.) - */ -using TLVDataFilter = void (*)(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, - chip::Callback::Cancelable * onFailure); - -class DLL_EXPORT CHIPDeviceCallbacksMgr -{ -public: - CHIPDeviceCallbacksMgr(const CHIPDeviceCallbacksMgr &) = delete; - CHIPDeviceCallbacksMgr(const CHIPDeviceCallbacksMgr &&) = delete; - CHIPDeviceCallbacksMgr & operator=(const CHIPDeviceCallbacksMgr &) = delete; - - static CHIPDeviceCallbacksMgr & GetInstance(); - - CHIP_ERROR AddResponseCallback(NodeId nodeId, uint8_t sequenceNumber, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, TLVDataFilter callbackFilter = nullptr); - CHIP_ERROR CancelResponseCallback(NodeId nodeId, uint8_t sequenceNumber); - CHIP_ERROR GetResponseCallback(NodeId nodeId, uint8_t sequenceNumber, Callback::Cancelable ** onSuccessCallback, - Callback::Cancelable ** onFailureCallback, TLVDataFilter * callbackFilter = nullptr); - -private: - CHIPDeviceCallbacksMgr() {} - - struct ResponseCallbackInfo - { - chip::NodeId nodeId; - uint8_t sequenceNumber; - - bool operator==(ResponseCallbackInfo const & other) - { - return nodeId == other.nodeId && sequenceNumber == other.sequenceNumber; - } - }; - - struct ReportCallbackInfo - { - chip::NodeId nodeId; - chip::EndpointId endpointId; - chip::ClusterId clusterId; - chip::AttributeId attributeId; - - bool operator==(ReportCallbackInfo const & other) - { - return nodeId == other.nodeId && endpointId == other.endpointId && clusterId == other.clusterId && - attributeId == other.attributeId; - } - }; - - template - struct TLVFilterItem - { - T info = { .nodeId = kPlaceholderNodeId }; - TLVDataFilter filter = nullptr; - }; - - template - CHIP_ERROR CancelCallback(T & info, Callback::CallbackDeque & queue) - { - Callback::Cancelable * ca = nullptr; - CHIP_ERROR err = GetCallback(info, queue, &ca); - if (CHIP_NO_ERROR == err) - { - ca->Cancel(); - queue.Dequeue(ca); - } - - return err; - } - - template - CHIP_ERROR GetCallback(T & info, Callback::CallbackDeque & queue, Callback::Cancelable ** callback) - { - Callback::Cancelable * ca = &queue; - while (ca != nullptr && ca->mNext != &queue) - { - T callbackInfo; - static_assert(std::is_pod::value, "Callback info must be POD"); - static_assert(sizeof(ca->mNext->mInfo) >= sizeof(callbackInfo), "Callback info too large"); - memcpy(&callbackInfo, ca->mNext->mInfo, sizeof(callbackInfo)); - if (callbackInfo == info) - { - *callback = ca->mNext; - return CHIP_NO_ERROR; - } - - ca = ca->mNext; - } - - return CHIP_ERROR_KEY_NOT_FOUND; - } - - CHIP_ERROR AddResponseFilter(const ResponseCallbackInfo & info, TLVDataFilter callbackFilter); - CHIP_ERROR PopResponseFilter(const ResponseCallbackInfo & info, TLVDataFilter * callbackFilter); - - Callback::CallbackDeque mResponsesSuccess; - Callback::CallbackDeque mResponsesFailure; - TLVFilterItem mTLVFilterPool[kTLVFilterPoolSize]; -}; - -} // namespace app -} // namespace chip diff --git a/src/app/util/im-client-callbacks.cpp b/src/app/util/im-client-callbacks.cpp deleted file mode 100644 index 10c5f03df01d80..00000000000000 --- a/src/app/util/im-client-callbacks.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; - -void LogStatus(uint8_t status) -{ - switch (status) - { - case EMBER_ZCL_STATUS_SUCCESS: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_SUCCESS (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_FAILURE: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_FAILURE (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_INVALID_SUBSCRIPTION: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_INVALID_SUBSCRIPTION (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_MALFORMED_COMMAND: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_MALFORMED_COMMAND (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DEPRECATED82: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DEPRECATED82 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DEPRECATED83: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DEPRECATED83 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DEPRECATED84: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DEPRECATED84 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_INVALID_COMMAND: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_INVALID_COMMAND (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_INVALID_VALUE: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_INVALID_VALUE (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_UNSUPPORTED_WRITE: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_UNSUPPORTED_WRITE (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DUPLICATE_EXISTS: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DUPLICATE_EXISTS (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_NOT_FOUND: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_NOT_FOUND (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_UNREPORTABLE_ATTRIBUTE: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_UNREPORTABLE_ATTRIBUTE (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_INVALID_DATA_TYPE: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_INVALID_DATA_TYPE (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DEPRECATED8E: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DEPRECATED8E (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_UNSUPPORTED_READ: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_UNSUPPORTED_READ (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DEPRECATED90: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DEPRECATED90 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DEPRECATED91: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DEPRECATED91 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DATA_VERSION_MISMATCH: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DATA_VERSION_MISMATCH (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DEPRECATED93: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DEPRECATED93 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_TIMEOUT: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_TIMEOUT (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_RESERVED95: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_RESERVED95 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_RESERVED96: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_RESERVED96 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_RESERVED97: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_RESERVED97 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_RESERVED98: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_RESERVED98 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_RESERVED99: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_RESERVED99 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_RESERVED9A: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_RESERVED9A (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_BUSY: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_BUSY (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DEPRECATEDC0: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DEPRECATEDC0 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DEPRECATEDC1: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DEPRECATEDC1 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_DEPRECATEDC4: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_DEPRECATEDC4 (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_NO_UPSTREAM_SUBSCRIPTION: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_NO_UPSTREAM_SUBSCRIPTION (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_NEEDS_TIMED_INTERACTION: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_NEEDS_TIMED_INTERACTION (0x%02x)", status); - break; - case EMBER_ZCL_STATUS_UNSUPPORTED_EVENT: - ChipLogProgress(Zcl, " status: EMBER_ZCL_STATUS_UNSUPPORTED_EVENT (0x%02x)", status); - break; - default: - ChipLogError(Zcl, "Unknown status: 0x%02x", status); - break; - } -} - -static void LogIMStatus(Protocols::InteractionModel::Status status) -{ - switch (status) - { - case Protocols::InteractionModel::Status::Success: - ChipLogProgress(Zcl, " status: Success (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Failure: - ChipLogProgress(Zcl, " status: Failure (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::InvalidSubscription: - ChipLogProgress(Zcl, " status: InvalidSubscription (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::UnsupportedAccess: - ChipLogProgress(Zcl, " status: UnsupportedAccess (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::UnsupportedEndpoint: - ChipLogProgress(Zcl, " status: UnsupportedEndpoint (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::InvalidAction: - ChipLogProgress(Zcl, " status: InvalidAction (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::UnsupportedCommand: - ChipLogProgress(Zcl, " status: UnsupportedCommand (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecated82: - ChipLogProgress(Zcl, " status: Deprecated82 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecated83: - ChipLogProgress(Zcl, " status: Deprecated83 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecated84: - ChipLogProgress(Zcl, " status: Deprecated84 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::InvalidCommand: - ChipLogProgress(Zcl, " status: InvalidCommand (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::UnsupportedAttribute: - ChipLogProgress(Zcl, " status: UnsupportedAttribute (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::ConstraintError: - ChipLogProgress(Zcl, " status: InvalidValue (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::UnsupportedWrite: - ChipLogProgress(Zcl, " status: UnsupportedWrite (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::ResourceExhausted: - ChipLogProgress(Zcl, " status: ResourceExhausted (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecated8a: - ChipLogProgress(Zcl, " status: Deprecated8a (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::NotFound: - ChipLogProgress(Zcl, " status: NotFound (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::UnreportableAttribute: - ChipLogProgress(Zcl, " status: UnreportableAttribute (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::InvalidDataType: - ChipLogProgress(Zcl, " status: InvalidDataType (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecated8e: - ChipLogProgress(Zcl, " status: Deprecated8e (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::UnsupportedRead: - ChipLogProgress(Zcl, " status: UnsupportedRead (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecated90: - ChipLogProgress(Zcl, " status: Deprecated90 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecated91: - ChipLogProgress(Zcl, " status: Deprecated91 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::DataVersionMismatch: - ChipLogProgress(Zcl, " status: DataVersionMismatch (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecated93: - ChipLogProgress(Zcl, " status: Deprecated93 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Timeout: - ChipLogProgress(Zcl, " status: Timeout (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Reserved95: - ChipLogProgress(Zcl, " status: Reserved95 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Reserved96: - ChipLogProgress(Zcl, " status: Reserved96 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Reserved97: - ChipLogProgress(Zcl, " status: Reserved97 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Reserved98: - ChipLogProgress(Zcl, " status: Reserved98 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Reserved99: - ChipLogProgress(Zcl, " status: Reserved99 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Reserved9a: - ChipLogProgress(Zcl, " status: Reserved9a (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Busy: - ChipLogProgress(Zcl, " status: Busy (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecatedc0: - ChipLogProgress(Zcl, " status: Deprecatedc0 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecatedc1: - ChipLogProgress(Zcl, " status: Deprecatedc1 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecatedc2: - ChipLogProgress(Zcl, " status: Deprecatedc2 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::UnsupportedCluster: - ChipLogProgress(Zcl, " status: UnsupportedCluster (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::Deprecatedc4: - ChipLogProgress(Zcl, " status: Deprecatedc4 (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::NoUpstreamSubscription: - ChipLogProgress(Zcl, " status: NoUpstreamSubscription (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::NeedsTimedInteraction: - ChipLogProgress(Zcl, " status: NeedsTimedInteraction (0x%02" PRIx8 ")", to_underlying(status)); - break; - case Protocols::InteractionModel::Status::UnsupportedEvent: - ChipLogProgress(Zcl, " status: UnsupportedEvent (0x%02" PRIx8 ")", to_underlying(status)); - break; - default: - ChipLogError(Zcl, "Unknown status: 0x%02" PRIx8, to_underlying(status)); - break; - } -} - -// Singleton instance of the callbacks manager -static app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -bool IMDefaultResponseCallback(const app::CommandSender * commandObj, EmberAfStatus status) -{ - ChipLogProgress(Zcl, "DefaultResponse:"); - ChipLogProgress(Zcl, " Transaction: %p", commandObj); - LogStatus(status); - - Callback::Cancelable * onSuccessCallback = nullptr; - Callback::Cancelable * onFailureCallback = nullptr; - NodeId sourceIdentifier = - reinterpret_cast(commandObj); /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a - device, so the seqNum is always set to 0. */ - - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); - - if (CHIP_NO_ERROR != err) - { - if (onSuccessCallback == nullptr) - { - ChipLogDetail(Zcl, "%s: Missing success callback", __FUNCTION__); - } - - if (onFailureCallback == nullptr) - { - ChipLogDetail(Zcl, "%s: Missing failure callback", __FUNCTION__); - } - - return true; - } - - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext); - } - else - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, static_cast(status)); - } - - return true; -} - -bool IMWriteResponseCallback(const chip::app::WriteClient * writeClient, chip::Protocols::InteractionModel::Status status) -{ - ChipLogProgress(Zcl, "WriteResponse:"); - LogIMStatus(status); - - Callback::Cancelable * onSuccessCallback = nullptr; - Callback::Cancelable * onFailureCallback = nullptr; - CHIP_ERROR err = - gCallbacks.GetResponseCallback(reinterpret_cast(writeClient), 0, &onSuccessCallback, &onFailureCallback); - - if (CHIP_NO_ERROR != err) - { - if (onSuccessCallback == nullptr) - { - ChipLogDetail(Zcl, "%s: Missing success callback", __FUNCTION__); - } - - if (onFailureCallback == nullptr) - { - ChipLogDetail(Zcl, "%s: Missing failure callback", __FUNCTION__); - } - - return true; - } - - if (status == Protocols::InteractionModel::Status::Success) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext); - } - else - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, static_cast(to_underlying(status))); - } - - return true; -} - -bool emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status) -{ - ChipLogProgress(Zcl, "DefaultResponse:"); - ChipLogProgress(Zcl, " ClusterId: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); - ChipLogProgress(Zcl, " CommandId: " ChipLogFormatMEI, ChipLogValueMEI(commandId)); - LogStatus(status); - - Callback::Cancelable * onSuccessCallback = nullptr; - Callback::Cancelable * onFailureCallback = nullptr; - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); - - if (CHIP_NO_ERROR != err) - { - if (onSuccessCallback == nullptr) - { - ChipLogDetail(Zcl, "%s: Missing success callback", __FUNCTION__); - } - - if (onFailureCallback == nullptr) - { - ChipLogDetail(Zcl, "%s: Missing failure callback", __FUNCTION__); - } - - return true; - } - - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext); - } - else - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, static_cast(status)); - } - - return true; -} diff --git a/src/app/util/im-client-callbacks.h b/src/app/util/im-client-callbacks.h index e42a71e9cd0d0e..0ecf06f273468e 100644 --- a/src/app/util/im-client-callbacks.h +++ b/src/app/util/im-client-callbacks.h @@ -26,13 +26,6 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. -bool IMDefaultResponseCallback(const chip::app::CommandSender * commandObj, EmberAfStatus status); -bool IMWriteResponseCallback(const chip::app::WriteClient * writeClient, chip::Protocols::InteractionModel::Status status); -void LogStatus(uint8_t status); - // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); typedef void (*DefaultFailureCallback)(void * context, uint8_t status); diff --git a/src/app/zap-templates/app-templates.json b/src/app/zap-templates/app-templates.json index e7b05ff21a8bc0..3a075c6e90c7b9 100644 --- a/src/app/zap-templates/app-templates.json +++ b/src/app/zap-templates/app-templates.json @@ -67,11 +67,6 @@ "name": "CHIP Client Callbacks header", "output": "CHIPClientCallbacks.h" }, - { - "path": "templates/app/CHIPClientCallbacks-src.zapt", - "name": "CHIP Client Callbacks", - "output": "CHIPClientCallbacks.cpp" - }, { "path": "templates/app/im-cluster-command-handler.zapt", "name": "CHIP Client Callbacks for Interaction Model", @@ -82,11 +77,6 @@ "name": "C++ ZCL API Header", "output": "CHIPClusters.h" }, - { - "path": "templates/app/CHIPClusters-src.zapt", - "name": "C++ ZCL API", - "output": "CHIPClusters.cpp" - }, { "path": "templates/app/MatterIDL.zapt", "name": "Human-readable Matter IDL", diff --git a/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt b/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt deleted file mode 100644 index efa95d94238030..00000000000000 --- a/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt +++ /dev/null @@ -1,180 +0,0 @@ -{{> header}} - -{{#if (chip_has_client_clusters)}} -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { - [[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - - -{{! TODO: These IM related callbacks contains small or no generated code, should be put into separate file to reduce the size of template. }} - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -{{#chip_client_clusters}} -{{#if (chip_server_has_list_attributes)}} -{{#chip_server_cluster_attributes}} -{{#if isArray}} -void {{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}ListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - {{zapTypeToDecodableClusterObjectType type ns=parent.name}} list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback<{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}ListAttributeCallback> * cb = Callback::Callback<{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}ListAttributeCallback>::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -{{/if}} -{{/chip_server_cluster_attributes}} -{{/if}} -{{/chip_client_clusters}} - -{{#chip_client_clusters}} -{{#chip_cluster_responses}} -bool emberAf{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Callback(EndpointId endpoint, app::CommandSender * commandObj{{#chip_cluster_response_arguments}}, {{#if isArray}}{{asUnderlyingZclType type}}{{else}}{{#if_is_struct type}}{{zapTypeToDecodableClusterObjectType type ns=parent.parent.name}}{{else}}{{asUnderlyingZclType type}}{{/if_is_struct}}{{/if}} {{asSymbol label}}{{/chip_cluster_response_arguments}}) -{ - ChipLogProgress(Zcl, "{{asUpperCamelCase name}}:"); - {{#chip_cluster_response_arguments}} - {{#if isArray}} - ChipLogProgress(Zcl, " {{asSymbol label}}: {{asPrintFormat type}}", {{asSymbol label}}); - {{else if (isOctetString type)}} - ChipLogProgress(Zcl, " {{asSymbol label}}: %zu", {{asSymbol label}}.size()); - {{else if (isCharString type)}} - ChipLogProgress(Zcl, " {{asSymbol label}}: %.*s", static_cast({{asSymbol label}}.size()), {{asSymbol label}}.data()); - {{else}} - {{#if_is_struct type}} - ChipLogProgress(Zcl, " {{asSymbol label}}: Not sure how to log struct {{type}}"); - {{else}} - ChipLogProgress(Zcl, " {{asSymbol label}}: {{asPrintFormat type}}", {{asSymbol label}}); - {{/if_is_struct}} - {{/if}} - {{/chip_cluster_response_arguments}} - - GET_CLUSTER_RESPONSE_CALLBACKS("{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Callback"); - - Callback::Callback<{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Callback> * cb = Callback::Callback<{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Callback>::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext{{#chip_cluster_response_arguments}}, {{#if isArray}}{{asSymbol label}}{{else}}{{#if_is_struct type}}::{{asUnderlyingZclType type}}(){{else}}{{asSymbol label}}{{/if_is_struct}}{{/if}}{{/chip_cluster_response_arguments}}); - return true; -} - -{{/chip_cluster_responses}} -{{/chip_client_clusters}} -{{/if}} diff --git a/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt b/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt index ff63907680339c..765cb27892d249 100644 --- a/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt +++ b/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt @@ -14,18 +14,6 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks -{{#chip_client_clusters}} -{{#chip_cluster_responses}} -typedef void (*{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Callback)(void * context{{#chip_cluster_response_arguments}}, {{asUnderlyingZclType type}} {{asSymbol label}}{{/chip_cluster_response_arguments}}); -{{/chip_cluster_responses}} -{{/chip_client_clusters}} -{{/if}} - // List specific responses {{#chip_client_clusters}} {{#chip_server_cluster_attributes}} @@ -35,3 +23,5 @@ typedef void (*{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}ListAttr {{/if}} {{/chip_server_cluster_attributes}} {{/chip_client_clusters}} + +{{/if}} \ No newline at end of file diff --git a/src/app/zap-templates/templates/app/CHIPClusters-src.zapt b/src/app/zap-templates/templates/app/CHIPClusters-src.zapt deleted file mode 100644 index 6d1f3df0b9333d..00000000000000 --- a/src/app/zap-templates/templates/app/CHIPClusters-src.zapt +++ /dev/null @@ -1,82 +0,0 @@ -{{> header}} - -{{#if (chip_has_client_clusters)}} -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -{{#chip_client_clusters}} - -// {{asUpperCamelCase name}} Cluster Commands -{{#chip_cluster_commands}} -CHIP_ERROR {{asUpperCamelCase clusterName}}Cluster::{{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback{{#chip_cluster_command_arguments_with_structs_expanded}}{{#if_is_struct type}}{{else}}, {{chipType}} {{asLowerCamelCase label}}{{/if_is_struct}}{{/chip_cluster_command_arguments_with_structs_expanded}}) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, {{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender(Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - -{{#chip_cluster_command_arguments_with_structs_expanded}} -{{#if_is_struct type}} -{{else}} -{{#first}} - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); -{{/first}} - // {{asLowerCamelCase label}}: {{asLowerCamelCase type}} -{{#if (isCharString type)}} - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), {{asLowerCamelCase label}})); -{{else}} - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), {{asLowerCamelCase label}})); -{{/if}} -{{/if_is_struct}} -{{else}} - // Command takes no arguments. -{{/chip_cluster_command_arguments_with_structs_expanded}} - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object now. - sender.release(); -exit: - return err; -} - -{{/chip_cluster_commands}} - -{{/chip_client_clusters}} - -} // namespace Controller -} // namespace chip -{{/if}} diff --git a/src/app/zap-templates/templates/app/CHIPClusters.zapt b/src/app/zap-templates/templates/app/CHIPClusters.zapt index 33b8fcd023f5d8..38e393c5bbd28e 100644 --- a/src/app/zap-templates/templates/app/CHIPClusters.zapt +++ b/src/app/zap-templates/templates/app/CHIPClusters.zapt @@ -20,13 +20,6 @@ class DLL_EXPORT {{asUpperCamelCase name}}Cluster : public ClusterBase public: {{asUpperCamelCase name}}Cluster() : ClusterBase(app::Clusters::{{asUpperCamelCase name}}::Id) {} ~{{asUpperCamelCase name}}Cluster() {} - {{#chip_cluster_commands}} - {{#first}} - - // Cluster Commands - {{/first}} - CHIP_ERROR {{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback{{#chip_cluster_command_arguments_with_structs_expanded}}{{#if_is_struct type}}{{else}}, {{chipType}} {{asLowerCamelCase label}}{{/if_is_struct}}{{/chip_cluster_command_arguments_with_structs_expanded}}); - {{/chip_cluster_commands}} }; {{/chip_client_clusters}} diff --git a/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt b/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt index bb840e882179c9..4a9ebdc2c4b51e 100644 --- a/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt +++ b/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt @@ -25,24 +25,15 @@ namespace app { namespace Clusters { {{#all_user_clusters}} +{{#if (isServer side)}} {{#if (user_cluster_has_enabled_command name side)}} namespace {{asUpperCamelCase name}} { -void Dispatch{{asUpperCamelCase side}}Command({{#if (isServer side)}}CommandHandler{{else}}CommandSender{{/if}} * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { {{#chip_available_cluster_commands}} {{#first}} - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; - {{#unless (isServer parent.side)}} - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - {{/unless}} bool wasHandled = false; { switch (aCommandPath.mCommandId) @@ -54,40 +45,29 @@ void Dispatch{{asUpperCamelCase side}}Command({{#if (isServer side)}}CommandHand } {{#last}} default: { - {{#if (isServer parent.side)}} // Unrecognized command ID, error status will apply. apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); - {{/if}} return; } } } - if (CHIP_NO_ERROR != TLVError {{#unless (isServer parent.side)}}|| CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount{{/unless}} || !wasHandled) + if (CHIP_NO_ERROR != TLVError || !wasHandled) { - {{#if (isServer parent.side)}} apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); - {{else}} - ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - {{/if}} } {{/last}} {{else}} - {{#if (isServer parent.side)}} apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); - {{/if}} {{/chip_available_cluster_commands}} } } +{{/if}} {{/if}} {{/all_user_clusters}} @@ -118,30 +98,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - {{#chip_client_clusters}} - {{#if (user_cluster_has_enabled_command name side)}} - case Clusters::{{asUpperCamelCase name}}::Id: - Clusters::{{asUpperCamelCase name}}::Dispatch{{asUpperCamelCase side}}Command(apCommandObj, aCommandPath, aReader); - break; - {{/if}} - {{/chip_client_clusters}} - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/src/controller/BUILD.gn b/src/controller/BUILD.gn index f08596c4cb7b3b..4b58532fb46eba 100644 --- a/src/controller/BUILD.gn +++ b/src/controller/BUILD.gn @@ -60,7 +60,6 @@ static_library("controller") { public_deps = [ "${chip_root}/src/app", - "${chip_root}/src/app/util:device_callbacks_manager", "${chip_root}/src/lib/core", "${chip_root}/src/lib/dnssd", "${chip_root}/src/lib/support", diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index ed15b6f5cfa3fd..f4feb64a7abdd0 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -90,14 +90,6 @@ using namespace chip::Transport; using namespace chip::Credentials; using namespace chip::app::Clusters; -// For some applications those does not implement IMDelegate, the DeviceControllerInteractionModelDelegate will dispatch the -// response to IMDefaultResponseCallback CHIPClientCallbacks, for the applications those implemented IMDelegate, this function will -// not be used. -bool __attribute__((weak)) IMDefaultResponseCallback(const chip::app::CommandSender * commandObj, EmberAfStatus status) -{ - return false; -} - namespace chip { namespace Controller { @@ -152,7 +144,6 @@ CHIP_ERROR DeviceController::Init(ControllerInitParams params) .idAllocator = &mIDAllocator, .fabricTable = params.systemState->Fabrics(), .clientPool = &mCASEClientPool, - .imDelegate = params.systemState->IMDelegate(), .mrpLocalConfig = Optional::Value(mMRPConfig), }; @@ -647,7 +638,6 @@ ControllerDeviceInitParams DeviceController::GetControllerDeviceInitParams() .storageDelegate = mStorageDelegate, .idAllocator = &mIDAllocator, .fabricsTable = mSystemState->Fabrics(), - .imDelegate = mSystemState->IMDelegate(), }; } diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 5b0184789681f1..0567ec0d5227d5 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/src/controller/CHIPDeviceControllerFactory.cpp b/src/controller/CHIPDeviceControllerFactory.cpp index 3e8dc7233ff9a7..68c9ddbdd72e75 100644 --- a/src/controller/CHIPDeviceControllerFactory.cpp +++ b/src/controller/CHIPDeviceControllerFactory.cpp @@ -131,11 +131,6 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params) #endif )); - if (params.imDelegate == nullptr) - { - params.imDelegate = chip::Platform::New(); - } - stateParams.fabricTable = chip::Platform::New(); stateParams.sessionMgr = chip::Platform::New(); stateParams.exchangeMgr = chip::Platform::New(); @@ -149,7 +144,6 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params) InitDataModelHandler(stateParams.exchangeMgr); - stateParams.imDelegate = params.imDelegate; ReturnErrorOnFailure(chip::app::InteractionModelEngine::GetInstance()->Init(stateParams.exchangeMgr)); #if CHIP_DEVICE_CONFIG_ENABLE_DNSSD @@ -290,12 +284,6 @@ CHIP_ERROR DeviceControllerSystemState::Shutdown() mSessionMgr = nullptr; } - if (mIMDelegate != nullptr) - { - chip::Platform::Delete(mIMDelegate); - mIMDelegate = nullptr; - } - return CHIP_NO_ERROR; } diff --git a/src/controller/CHIPDeviceControllerFactory.h b/src/controller/CHIPDeviceControllerFactory.h index 9d49eeefa36283..ca2667c68619dd 100644 --- a/src/controller/CHIPDeviceControllerFactory.h +++ b/src/controller/CHIPDeviceControllerFactory.h @@ -71,7 +71,6 @@ struct FactoryInitParams System::Layer * systemLayer = nullptr; Inet::EndPointManager * tcpEndPointManager = nullptr; Inet::EndPointManager * udpEndPointManager = nullptr; - DeviceControllerInteractionModelDelegate * imDelegate = nullptr; #if CONFIG_NETWORK_LAYER_BLE Ble::BleLayer * bleLayer = nullptr; #endif diff --git a/src/controller/CHIPDeviceControllerSystemState.h b/src/controller/CHIPDeviceControllerSystemState.h index 6ad01c9376b5f1..6c2a3e0cfb726c 100644 --- a/src/controller/CHIPDeviceControllerSystemState.h +++ b/src/controller/CHIPDeviceControllerSystemState.h @@ -29,7 +29,6 @@ #pragma once -#include #include #include #include @@ -73,7 +72,6 @@ struct DeviceControllerSystemStateParams Messaging::ExchangeManager * exchangeMgr = nullptr; secure_channel::MessageCounterManager * messageCounterManager = nullptr; FabricTable * fabricTable = nullptr; - DeviceControllerInteractionModelDelegate * imDelegate = nullptr; }; // A representation of the internal state maintained by the DeviceControllerFactory @@ -86,8 +84,7 @@ class DeviceControllerSystemState DeviceControllerSystemState(DeviceControllerSystemStateParams params) : mSystemLayer(params.systemLayer), mTCPEndPointManager(params.tcpEndPointManager), mUDPEndPointManager(params.udpEndPointManager), mTransportMgr(params.transportMgr), mSessionMgr(params.sessionMgr), - mExchangeMgr(params.exchangeMgr), mMessageCounterManager(params.messageCounterManager), mFabrics(params.fabricTable), - mIMDelegate(params.imDelegate) + mExchangeMgr(params.exchangeMgr), mMessageCounterManager(params.messageCounterManager), mFabrics(params.fabricTable) { #if CONFIG_NETWORK_LAYER_BLE mBleLayer = params.bleLayer; @@ -130,7 +127,6 @@ class DeviceControllerSystemState Messaging::ExchangeManager * ExchangeMgr() { return mExchangeMgr; } secure_channel::MessageCounterManager * MessageCounterManager() { return mMessageCounterManager; }; FabricTable * Fabrics() { return mFabrics; }; - DeviceControllerInteractionModelDelegate * IMDelegate() { return mIMDelegate; } #if CONFIG_NETWORK_LAYER_BLE Ble::BleLayer * BleLayer() { return mBleLayer; }; #endif @@ -149,7 +145,6 @@ class DeviceControllerSystemState Messaging::ExchangeManager * mExchangeMgr = nullptr; secure_channel::MessageCounterManager * mMessageCounterManager = nullptr; FabricTable * mFabrics = nullptr; - DeviceControllerInteractionModelDelegate * mIMDelegate = nullptr; std::atomic mRefCount{ 1 }; diff --git a/src/controller/CommissioneeDeviceProxy.h b/src/controller/CommissioneeDeviceProxy.h index 3f2af4154cd41c..ca3715a23c6710 100644 --- a/src/controller/CommissioneeDeviceProxy.h +++ b/src/controller/CommissioneeDeviceProxy.h @@ -28,10 +28,8 @@ #include #include -#include #include #include -#include #include #include #include @@ -76,8 +74,6 @@ struct ControllerDeviceInitParams Ble::BleLayer * bleLayer = nullptr; #endif FabricTable * fabricsTable = nullptr; - - Controller::DeviceControllerInteractionModelDelegate * imDelegate = nullptr; }; class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegate @@ -125,7 +121,6 @@ class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegat mUDPEndPointManager = params.udpEndPointManager; mFabricIndex = fabric; mIDAllocator = params.idAllocator; - mpIMDelegate = params.imDelegate; #if CONFIG_NETWORK_LAYER_BLE mBleLayer = params.bleLayer; #endif @@ -233,8 +228,6 @@ class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegat return LoadSecureSessionParametersIfNeeded(loadedSecureSession); }; - Controller::DeviceControllerInteractionModelDelegate * GetInteractionModelDelegate() override { return mpIMDelegate; }; - private: enum class ConnectionState { @@ -273,8 +266,6 @@ class CommissioneeDeviceProxy : public DeviceProxy, public SessionReleaseDelegat SessionHolderWithDelegate mSecureSession; - Controller::DeviceControllerInteractionModelDelegate * mpIMDelegate = nullptr; - uint8_t mSequenceNumber = 0; /** diff --git a/src/controller/data_model/BUILD.gn b/src/controller/data_model/BUILD.gn index 879f69e3c4d418..495d3551e97917 100644 --- a/src/controller/data_model/BUILD.gn +++ b/src/controller/data_model/BUILD.gn @@ -26,7 +26,6 @@ chip_data_model("data_model") { "${chip_root}/zzz_generated/controller-clusters/zap-generated" use_tests_apis = true - use_default_client_callbacks = true allow_circular_includes_from = [ "${chip_root}/src/controller" ] } diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp index b35180506bebd4..6c687cb4eeaa69 100644 --- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp +++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp @@ -223,7 +223,6 @@ ChipError::StorageType pychip_DeviceController_StackInit() FactoryInitParams factoryParams; factoryParams.fabricStorage = &sFabricStorage; - factoryParams.imDelegate = nullptr; ReturnErrorOnFailure(DeviceControllerFactory::GetInstance().Init(factoryParams).AsInteger()); diff --git a/src/controller/python/chip/interaction_model/Delegate.cpp b/src/controller/python/chip/interaction_model/Delegate.cpp index aa88b653bc229c..54f73386bfc7fc 100644 --- a/src/controller/python/chip/interaction_model/Delegate.cpp +++ b/src/controller/python/chip/interaction_model/Delegate.cpp @@ -31,78 +31,18 @@ namespace chip { namespace Controller { -PythonInteractionModelDelegate gPythonInteractionModelDelegate; - -void PythonInteractionModelDelegate::OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aPath, - const app::StatusIB & aStatus, TLV::TLVReader * aData) -{ - CommandStatus status{ - aStatus.mStatus, - aStatus.mClusterStatus.HasValue() ? aStatus.mClusterStatus.Value() : chip::python::kUndefinedClusterStatus, - aPath.mEndpointId, - aPath.mClusterId, - aPath.mCommandId, - 1 - }; // This indicates the index of the command if multiple command/status payloads are present in the - // message. For now, we don't support this in the IM layer, so just always set this to 1. - if (commandResponseStatusFunct != nullptr) - { - commandResponseStatusFunct(reinterpret_cast(apCommandSender), &status, sizeof(status)); - } - - DeviceControllerInteractionModelDelegate::OnResponse(apCommandSender, aPath, aStatus, aData); - - if (commandResponseErrorFunct != nullptr) - { - commandResponseErrorFunct(reinterpret_cast(apCommandSender), CHIP_NO_ERROR.AsInteger()); - } -} - -void PythonInteractionModelDelegate::OnError(const app::CommandSender * apCommandSender, CHIP_ERROR aError) -{ - StatusIB serverStatus(aError); - CommandStatus status{ - serverStatus.mStatus, serverStatus.mClusterStatus.ValueOr(chip::python::kUndefinedClusterStatus), 0, 0, 0, 1 - }; - - if (commandResponseStatusFunct != nullptr) - { - commandResponseStatusFunct(reinterpret_cast(apCommandSender), &status, sizeof(status)); - } - - if (commandResponseErrorFunct != nullptr) - { - commandResponseErrorFunct(reinterpret_cast(apCommandSender), aError.AsInteger()); - } - DeviceControllerInteractionModelDelegate::OnError(apCommandSender, aError); -} - void pychip_InteractionModelDelegate_SetCommandResponseStatusCallback( PythonInteractionModelDelegate_OnCommandResponseStatusCodeReceivedFunct f) -{ - gPythonInteractionModelDelegate.SetOnCommandResponseStatusCodeReceivedCallback(f); -} +{} void pychip_InteractionModelDelegate_SetCommandResponseProtocolErrorCallback( PythonInteractionModelDelegate_OnCommandResponseProtocolErrorFunct f) -{ - gPythonInteractionModelDelegate.SetOnCommandResponseProtocolErrorCallback(f); -} +{} -void pychip_InteractionModelDelegate_SetCommandResponseErrorCallback(PythonInteractionModelDelegate_OnCommandResponseFunct f) -{ - gPythonInteractionModelDelegate.SetOnCommandResponseCallback(f); -} +void pychip_InteractionModelDelegate_SetCommandResponseErrorCallback(PythonInteractionModelDelegate_OnCommandResponseFunct f) {} void pychip_InteractionModelDelegate_SetOnWriteResponseStatusCallback(PythonInteractionModelDelegate_OnWriteResponseStatusFunct f) -{ - gPythonInteractionModelDelegate.SetOnWriteResponseStatusCallback(f); -} - -PythonInteractionModelDelegate & PythonInteractionModelDelegate::Instance() -{ - return gPythonInteractionModelDelegate; -} +{} } // namespace Controller } // namespace chip diff --git a/src/controller/python/chip/interaction_model/Delegate.h b/src/controller/python/chip/interaction_model/Delegate.h index 4f9dbb4cf534a3..11d3764003a5b0 100644 --- a/src/controller/python/chip/interaction_model/Delegate.h +++ b/src/controller/python/chip/interaction_model/Delegate.h @@ -90,35 +90,5 @@ void pychip_InteractionModelDelegate_SetCommandResponseErrorCallback(PythonInter void pychip_InteractionModelDelegate_SetOnWriteResponseStatusCallback(PythonInteractionModelDelegate_OnWriteResponseStatusFunct f); } -class PythonInteractionModelDelegate : public chip::Controller::DeviceControllerInteractionModelDelegate -{ -public: - void OnResponse(app::CommandSender * apCommandSender, const app::ConcreteCommandPath & aPath, const app::StatusIB & aStatus, - TLV::TLVReader * aData) override; - void OnError(const app::CommandSender * apCommandSender, CHIP_ERROR aError) override; - - static PythonInteractionModelDelegate & Instance(); - - void SetOnCommandResponseStatusCodeReceivedCallback(PythonInteractionModelDelegate_OnCommandResponseStatusCodeReceivedFunct f) - { - commandResponseStatusFunct = f; - } - - void SetOnCommandResponseProtocolErrorCallback(PythonInteractionModelDelegate_OnCommandResponseProtocolErrorFunct f) - { - commandResponseProtocolErrorFunct = f; - } - - void SetOnCommandResponseCallback(PythonInteractionModelDelegate_OnCommandResponseFunct f) { commandResponseErrorFunct = f; } - - void SetOnWriteResponseStatusCallback(PythonInteractionModelDelegate_OnWriteResponseStatusFunct f) { onWriteResponseFunct = f; } - -private: - PythonInteractionModelDelegate_OnCommandResponseStatusCodeReceivedFunct commandResponseStatusFunct = nullptr; - PythonInteractionModelDelegate_OnCommandResponseProtocolErrorFunct commandResponseProtocolErrorFunct = nullptr; - PythonInteractionModelDelegate_OnCommandResponseFunct commandResponseErrorFunct = nullptr; - PythonInteractionModelDelegate_OnWriteResponseStatusFunct onWriteResponseFunct = nullptr; -}; - } // namespace Controller } // namespace chip diff --git a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj index 5cc83020846a17..b5f01a5bee33b3 100644 --- a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj @@ -9,9 +9,7 @@ /* Begin PBXBuildFile section */ 1E16A90226B98AB700683C53 /* CHIPTestClustersObjc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1E16A8FA26B9835700683C53 /* CHIPTestClustersObjc.mm */; }; 1E16A90326B98AF100683C53 /* CHIPTestClustersObjc.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E16A8F926B9835600683C53 /* CHIPTestClustersObjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 1E857306265519720050A4D9 /* CHIPClientCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E857305265519720050A4D9 /* CHIPClientCallbacks.cpp */; }; 1E85730C265519AE0050A4D9 /* callback-stub.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E857307265519AE0050A4D9 /* callback-stub.cpp */; }; - 1E85730E265519AE0050A4D9 /* CHIPClusters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E857309265519AE0050A4D9 /* CHIPClusters.cpp */; }; 1E857310265519AE0050A4D9 /* IMClusterCommandHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85730B265519AE0050A4D9 /* IMClusterCommandHandler.cpp */; }; 1E85732226551A490050A4D9 /* binding-table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731226551A490050A4D9 /* binding-table.cpp */; }; 1E85732526551A490050A4D9 /* message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731526551A490050A4D9 /* message.cpp */; }; @@ -45,7 +43,6 @@ 2CB7163B252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CB71638252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.h */; }; 2CB7163C252E8A7C0026E2BB /* CHIPDevicePairingDelegateBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2CB71639252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.mm */; }; 2CB7163F252F731E0026E2BB /* CHIPDevicePairingDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CB7163E252F731E0026E2BB /* CHIPDevicePairingDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 2F79A67726CE6672006377B0 /* im-client-callbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2F79A67626CE6672006377B0 /* im-client-callbacks.cpp */; }; 2FD775552695557E00FF4B12 /* error-mapping.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2FD775542695557E00FF4B12 /* error-mapping.cpp */; }; 5129BCFD26A9EE3300122DDF /* CHIPError.h in Headers */ = {isa = PBXBuildFile; fileRef = 5129BCFC26A9EE3300122DDF /* CHIPError.h */; settings = {ATTRIBUTES = (Public, ); }; }; 513DDB862761F69300DAA01A /* CHIPAttributeTLVValueDecoder_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 513DDB852761F69300DAA01A /* CHIPAttributeTLVValueDecoder_Internal.h */; }; @@ -97,9 +94,7 @@ /* Begin PBXFileReference section */ 1E16A8F926B9835600683C53 /* CHIPTestClustersObjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CHIPTestClustersObjc.h; path = "zap-generated/CHIPTestClustersObjc.h"; sourceTree = ""; }; 1E16A8FA26B9835700683C53 /* CHIPTestClustersObjc.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CHIPTestClustersObjc.mm; path = "zap-generated/CHIPTestClustersObjc.mm"; sourceTree = ""; }; - 1E857305265519720050A4D9 /* CHIPClientCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CHIPClientCallbacks.cpp; path = "../../../../zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp"; sourceTree = ""; }; 1E857307265519AE0050A4D9 /* callback-stub.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "callback-stub.cpp"; path = "../../../../zzz_generated/controller-clusters/zap-generated/callback-stub.cpp"; sourceTree = ""; }; - 1E857309265519AE0050A4D9 /* CHIPClusters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CHIPClusters.cpp; path = "../../../../zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp"; sourceTree = ""; }; 1E85730B265519AE0050A4D9 /* IMClusterCommandHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IMClusterCommandHandler.cpp; path = "../../../../zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp"; sourceTree = ""; }; 1E85731226551A490050A4D9 /* binding-table.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "binding-table.cpp"; path = "../../../app/util/binding-table.cpp"; sourceTree = ""; }; 1E85731526551A490050A4D9 /* message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = message.cpp; path = ../../../app/util/message.cpp; sourceTree = ""; }; @@ -133,7 +128,6 @@ 2CB71638252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPDevicePairingDelegateBridge.h; sourceTree = ""; }; 2CB71639252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPDevicePairingDelegateBridge.mm; sourceTree = ""; }; 2CB7163E252F731E0026E2BB /* CHIPDevicePairingDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPDevicePairingDelegate.h; sourceTree = ""; }; - 2F79A67626CE6672006377B0 /* im-client-callbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "im-client-callbacks.cpp"; path = "../../../app/util/im-client-callbacks.cpp"; sourceTree = ""; }; 2FD775542695557E00FF4B12 /* error-mapping.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "error-mapping.cpp"; path = "../../../app/util/error-mapping.cpp"; sourceTree = ""; }; 5129BCFC26A9EE3300122DDF /* CHIPError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CHIPError.h; path = CHIP/CHIPError.h; sourceTree = ""; }; 513DDB852761F69300DAA01A /* CHIPAttributeTLVValueDecoder_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPAttributeTLVValueDecoder_Internal.h; sourceTree = ""; }; @@ -200,7 +194,6 @@ 1E857311265519DE0050A4D9 /* CHIPApp */ = { isa = PBXGroup; children = ( - 2F79A67626CE6672006377B0 /* im-client-callbacks.cpp */, 2FD775542695557E00FF4B12 /* error-mapping.cpp */, 1E85731926551A490050A4D9 /* af-event.cpp */, 1E85731F26551A490050A4D9 /* attribute-size-util.cpp */, @@ -230,9 +223,7 @@ 1E16A8FA26B9835700683C53 /* CHIPTestClustersObjc.mm */, 1ED276DF26C57CF000547A89 /* CHIPCallbackBridge.mm */, 1E857307265519AE0050A4D9 /* callback-stub.cpp */, - 1E857309265519AE0050A4D9 /* CHIPClusters.cpp */, 1E85730B265519AE0050A4D9 /* IMClusterCommandHandler.cpp */, - 1E857305265519720050A4D9 /* CHIPClientCallbacks.cpp */, 1EC4CE6325CC276600D7304F /* CHIPClustersObjc.h */, 1EC4CE5925CC26E900D7304F /* CHIPClustersObjc.mm */, ); @@ -493,7 +484,6 @@ 2CB7163C252E8A7C0026E2BB /* CHIPDevicePairingDelegateBridge.mm in Sources */, 997DED162695343400975E97 /* CHIPThreadOperationalDataset.mm in Sources */, 998F287126D56940001846C6 /* CHIPP256KeypairBridge.mm in Sources */, - 1E85730E265519AE0050A4D9 /* CHIPClusters.cpp in Sources */, 1E16A90226B98AB700683C53 /* CHIPTestClustersObjc.mm in Sources */, 51B22C2A2740CB47008D5055 /* CHIPCommandPayloadsObjc.mm in Sources */, 1E85732E26551A490050A4D9 /* ember-print.cpp in Sources */, @@ -501,11 +491,9 @@ 51B22C262740CB32008D5055 /* CHIPStructsObjc.mm in Sources */, 2C222AD1255C620600E446B9 /* CHIPDevice.mm in Sources */, 1EC3238D271999E2002A8BF0 /* cluster-objects.cpp in Sources */, - 1E857306265519720050A4D9 /* CHIPClientCallbacks.cpp in Sources */, 991DC0892475F47D00C13860 /* CHIPDeviceController.mm in Sources */, B2E0D7B7245B0B5C003C5B48 /* CHIPQRCodeSetupPayloadParser.mm in Sources */, 1EC4CE5D25CC26E900D7304F /* CHIPClustersObjc.mm in Sources */, - 2F79A67726CE6672006377B0 /* im-client-callbacks.cpp in Sources */, 1E85732226551A490050A4D9 /* binding-table.cpp in Sources */, 1ED276E226C5812A00547A89 /* CHIPCluster.mm in Sources */, 1E85732526551A490050A4D9 /* message.cpp in Sources */, diff --git a/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index b671ace166b10b..00000000000000 --- a/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -bool emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t action, uint32_t delayedActionTime) -{ - ChipLogProgress(Zcl, "ApplyUpdateResponse:"); - ChipLogProgress(Zcl, " action: %" PRIu8 "", action); - ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); - - GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, action, delayedActionTime); - return true; -} diff --git a/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.h index e391926be63b3f..7ce7f6e003bd31 100644 --- a/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.h @@ -30,12 +30,4 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks -typedef void (*OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback)(void * context, uint8_t action, - uint32_t delayedActionTime); - // List specific responses diff --git a/zzz_generated/all-clusters-app/zap-generated/CHIPClusters.cpp b/zzz_generated/all-clusters-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index 8ba83874fa6545..00000000000000 --- a/zzz_generated/all-clusters-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// OtaSoftwareUpdateProvider Cluster Commands -CHIP_ERROR OtaSoftwareUpdateProviderCluster::ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // newVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), newVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::QueryImage(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::VendorId vendorId, - uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::QueryImage::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // vendorId: vendorId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), vendorId)); - // productId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), productId)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - // protocolsSupported: OTADownloadProtocol - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), protocolsSupported)); - // hardwareVersion: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hardwareVersion)); - // location: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), location)); - // requestorCanConsent: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), requestorCanConsent)); - // metadataForProvider: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), metadataForProvider)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/all-clusters-app/zap-generated/CHIPClusters.h b/zzz_generated/all-clusters-app/zap-generated/CHIPClusters.h index ede4e32855fc3a..15ec5aca34a215 100644 --- a/zzz_generated/all-clusters-app/zap-generated/CHIPClusters.h +++ b/zzz_generated/all-clusters-app/zap-generated/CHIPClusters.h @@ -35,16 +35,6 @@ class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase public: OtaSoftwareUpdateProviderCluster() : ClusterBase(app::Clusters::OtaSoftwareUpdateProvider::Id) {} ~OtaSoftwareUpdateProviderCluster() {} - - // Cluster Commands - CHIP_ERROR ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion); - CHIP_ERROR NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion); - CHIP_ERROR QueryImage(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::VendorId vendorId, uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider); }; } // namespace Controller diff --git a/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp index 1a59cbbbb14c71..d632c304e0a9f0 100644 --- a/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace BarrierControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -172,10 +164,6 @@ namespace Binding { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -222,10 +210,6 @@ namespace ColorControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -426,10 +410,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -467,10 +447,6 @@ namespace DoorLock { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -601,10 +577,6 @@ namespace EthernetNetworkDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -642,10 +614,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -702,10 +670,6 @@ namespace GroupKeyManagement { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -770,10 +734,6 @@ namespace Groups { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -856,10 +816,6 @@ namespace IasZone { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -897,10 +853,6 @@ namespace Identify { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -956,10 +908,6 @@ namespace LevelControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1060,10 +1008,6 @@ namespace LowPower { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1101,10 +1045,6 @@ namespace ModeSelect { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1142,10 +1082,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1226,115 +1162,10 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } // namespace NetworkCommissioning -namespace OtaSoftwareUpdateProvider { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::ApplyUpdateResponse::Id: { - expectArgumentCount = 2; - uint8_t action; - uint32_t delayedActionTime; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(action); - break; - case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback( - aCommandPath.mEndpointId, apCommandObj, action, delayedActionTime); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace OtaSoftwareUpdateProvider - namespace OtaSoftwareUpdateRequestor { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1373,10 +1204,6 @@ namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1459,10 +1286,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1576,10 +1399,6 @@ namespace Scenes { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1671,10 +1490,6 @@ namespace SoftwareDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1712,10 +1527,6 @@ namespace TestCluster { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1917,10 +1728,6 @@ namespace ThreadNetworkDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1958,10 +1765,6 @@ namespace WiFiNetworkDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1999,10 +1802,6 @@ namespace WindowCovering { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -2146,27 +1945,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - case Clusters::OtaSoftwareUpdateProvider::Id: - Clusters::OtaSoftwareUpdateProvider::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/bridge-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/bridge-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/bridge-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/bridge-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/bridge-app/zap-generated/CHIPClientCallbacks.h index 4ad6af42ab6e54..fbed9690c1f3da 100644 --- a/zzz_generated/bridge-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/bridge-app/zap-generated/CHIPClientCallbacks.h @@ -16,5 +16,3 @@ */ // THIS FILE IS GENERATED BY ZAP - -// List specific responses diff --git a/zzz_generated/bridge-app/zap-generated/CHIPClusters.cpp b/zzz_generated/bridge-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/bridge-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/bridge-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/bridge-app/zap-generated/IMClusterCommandHandler.cpp index de1b328a27519d..eee972c808955e 100644 --- a/zzz_generated/bridge-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/bridge-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -163,10 +155,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -223,10 +211,6 @@ namespace LevelControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -327,10 +311,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -415,10 +395,6 @@ namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -474,10 +450,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -625,24 +597,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index ef18eabfa875a3..00000000000000 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,3116 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -void AccessControlClusterAclListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void AccessControlClusterExtensionListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void AccessControlClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void AccountLoginClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void AdministratorCommissioningClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ApplicationBasicClusterAllowedVendorListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ApplicationBasicClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ApplicationLauncherClusterApplicationLauncherListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ApplicationLauncherClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void AudioOutputClusterAudioOutputListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void AudioOutputClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void BarrierControlClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void BasicClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void BinaryInputBasicClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void BindingClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void BooleanStateClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void BridgedActionsClusterActionListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void BridgedActionsClusterEndpointListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void BridgedActionsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void BridgedDeviceBasicClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ChannelClusterChannelListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ChannelClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ColorControlClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ContentLauncherClusterAcceptHeaderListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ContentLauncherClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void DescriptorClusterDeviceListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void DescriptorClusterServerListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void DescriptorClusterClientListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void DescriptorClusterPartsListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void DescriptorClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void DiagnosticLogsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void DoorLockClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ElectricalMeasurementClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void EthernetNetworkDiagnosticsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void FixedLabelClusterLabelListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void FixedLabelClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void FlowMeasurementClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GeneralCommissioningClusterBasicCommissioningInfoListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList< - chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfoType::DecodableType> - list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GeneralCommissioningClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GeneralDiagnosticsClusterNetworkInterfacesListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GeneralDiagnosticsClusterActiveHardwareFaultsListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GeneralDiagnosticsClusterActiveRadioFaultsListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GeneralDiagnosticsClusterActiveNetworkFaultsListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GeneralDiagnosticsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GroupKeyManagementClusterGroupKeyMapListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GroupKeyManagementClusterGroupTableListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GroupKeyManagementClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void GroupsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void IdentifyClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void IlluminanceMeasurementClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void KeypadInputClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void LevelControlClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void LocalizationConfigurationClusterSupportedLocalesListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void LowPowerClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void MediaInputClusterMediaInputListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void MediaInputClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void MediaPlaybackClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ModeSelectClusterSupportedModesListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ModeSelectClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void NetworkCommissioningClusterNetworksListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OtaSoftwareUpdateProviderClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OtaSoftwareUpdateRequestorClusterDefaultOtaProvidersListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList - list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OtaSoftwareUpdateRequestorClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OccupancySensingClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OnOffClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OnOffSwitchConfigurationClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterNOCsListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterFabricsListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterTrustedRootCertificatesListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void PowerSourceClusterActiveBatteryFaultsListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void PowerSourceClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void PowerSourceConfigurationClusterSourcesListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void PowerSourceConfigurationClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void PressureMeasurementClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void PumpConfigurationAndControlClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void RelativeHumidityMeasurementClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ScenesClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void SoftwareDiagnosticsClusterThreadMetricsListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void SoftwareDiagnosticsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void SwitchClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TargetNavigatorClusterTargetNavigatorListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TargetNavigatorClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TemperatureMeasurementClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TestClusterClusterListInt8uListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TestClusterClusterListOctetStringListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TestClusterClusterListStructOctetStringListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TestClusterClusterListNullablesAndOptionalsStructListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TestClusterClusterListLongOctetStringListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TestClusterClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ThermostatClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ThermostatUserInterfaceConfigurationClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ThreadNetworkDiagnosticsClusterNeighborTableListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ThreadNetworkDiagnosticsClusterRouteTableListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ThreadNetworkDiagnosticsClusterSecurityPolicyListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ThreadNetworkDiagnosticsClusterOperationalDatasetComponentsListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList< - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::DecodableType> - list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ThreadNetworkDiagnosticsClusterActiveNetworkFaultsListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ThreadNetworkDiagnosticsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TimeFormatLocalizationClusterSupportedCalendarTypesListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void UserLabelClusterLabelListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void WakeOnLanClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void WiFiNetworkDiagnosticsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void WindowCoveringClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -bool emberAfAccountLoginClusterGetSetupPINResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - chip::CharSpan setupPIN) -{ - ChipLogProgress(Zcl, "GetSetupPINResponse:"); - ChipLogProgress(Zcl, " setupPIN: %.*s", static_cast(setupPIN.size()), setupPIN.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("AccountLoginClusterGetSetupPINResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, setupPIN); - return true; -} - -bool emberAfApplicationLauncherClusterLauncherResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - chip::CharSpan data) -{ - ChipLogProgress(Zcl, "LauncherResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " data: %.*s", static_cast(data.size()), data.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("ApplicationLauncherClusterLauncherResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, data); - return true; -} - -bool emberAfChannelClusterChangeChannelResponseCallback( - EndpointId endpoint, app::CommandSender * commandObj, - chip::app::Clusters::Channel::Structs::ChannelInfo::DecodableType channelMatch, uint8_t errorType) -{ - ChipLogProgress(Zcl, "ChangeChannelResponse:"); - ChipLogProgress(Zcl, " channelMatch: Not sure how to log struct ChannelInfo"); - ChipLogProgress(Zcl, " errorType: %" PRIu8 "", errorType); - - GET_CLUSTER_RESPONSE_CALLBACKS("ChannelClusterChangeChannelResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, ::ChannelInfo(), errorType); - return true; -} - -bool emberAfContentLauncherClusterLaunchResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - chip::CharSpan data) -{ - ChipLogProgress(Zcl, "LaunchResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " data: %.*s", static_cast(data.size()), data.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("ContentLauncherClusterLaunchResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, data); - return true; -} - -bool emberAfDiagnosticLogsClusterRetrieveLogsResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - chip::ByteSpan content, uint32_t timeStamp, uint32_t timeSinceBoot) -{ - ChipLogProgress(Zcl, "RetrieveLogsResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " content: %zu", content.size()); - ChipLogProgress(Zcl, " timeStamp: %" PRIu32 "", timeStamp); - ChipLogProgress(Zcl, " timeSinceBoot: %" PRIu32 "", timeSinceBoot); - - GET_CLUSTER_RESPONSE_CALLBACKS("DiagnosticLogsClusterRetrieveLogsResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, content, timeStamp, timeSinceBoot); - return true; -} - -bool emberAfDoorLockClusterGetCredentialStatusResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - bool credentialExists, uint16_t userIndex, - uint16_t nextCredentialIndex) -{ - ChipLogProgress(Zcl, "GetCredentialStatusResponse:"); - ChipLogProgress(Zcl, " credentialExists: %d", credentialExists); - ChipLogProgress(Zcl, " userIndex: %" PRIu16 "", userIndex); - ChipLogProgress(Zcl, " nextCredentialIndex: %" PRIu16 "", nextCredentialIndex); - - GET_CLUSTER_RESPONSE_CALLBACKS("DoorLockClusterGetCredentialStatusResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, credentialExists, userIndex, nextCredentialIndex); - return true; -} - -bool emberAfDoorLockClusterGetUserResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint16_t userIndex, - chip::CharSpan userName, uint32_t userUniqueId, uint8_t userStatus, - uint8_t userType, uint8_t credentialRule, - /* TYPE WARNING: array array defaults to */ uint8_t * credentials, - chip::FabricIndex creatorFabricIndex, chip::FabricIndex lastModifiedFabricIndex, - uint16_t nextUserIndex) -{ - ChipLogProgress(Zcl, "GetUserResponse:"); - ChipLogProgress(Zcl, " userIndex: %" PRIu16 "", userIndex); - ChipLogProgress(Zcl, " userName: %.*s", static_cast(userName.size()), userName.data()); - ChipLogProgress(Zcl, " userUniqueId: %" PRIu32 "", userUniqueId); - ChipLogProgress(Zcl, " userStatus: %" PRIu8 "", userStatus); - ChipLogProgress(Zcl, " userType: %" PRIu8 "", userType); - ChipLogProgress(Zcl, " credentialRule: %" PRIu8 "", credentialRule); - ChipLogProgress(Zcl, " credentials: %p", credentials); - ChipLogProgress(Zcl, " creatorFabricIndex: %" PRIu8 "", creatorFabricIndex); - ChipLogProgress(Zcl, " lastModifiedFabricIndex: %" PRIu8 "", lastModifiedFabricIndex); - ChipLogProgress(Zcl, " nextUserIndex: %" PRIu16 "", nextUserIndex); - - GET_CLUSTER_RESPONSE_CALLBACKS("DoorLockClusterGetUserResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, userIndex, userName, userUniqueId, userStatus, userType, credentialRule, credentials, - creatorFabricIndex, lastModifiedFabricIndex, nextUserIndex); - return true; -} - -bool emberAfDoorLockClusterGetWeekDayScheduleResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t weekDayIndex, uint16_t userIndex, uint8_t status, - uint8_t daysMask, uint8_t startHour, uint8_t startMinute, - uint8_t endHour, uint8_t endMinute) -{ - ChipLogProgress(Zcl, "GetWeekDayScheduleResponse:"); - ChipLogProgress(Zcl, " weekDayIndex: %" PRIu8 "", weekDayIndex); - ChipLogProgress(Zcl, " userIndex: %" PRIu16 "", userIndex); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " daysMask: %" PRIu8 "", daysMask); - ChipLogProgress(Zcl, " startHour: %" PRIu8 "", startHour); - ChipLogProgress(Zcl, " startMinute: %" PRIu8 "", startMinute); - ChipLogProgress(Zcl, " endHour: %" PRIu8 "", endHour); - ChipLogProgress(Zcl, " endMinute: %" PRIu8 "", endMinute); - - GET_CLUSTER_RESPONSE_CALLBACKS("DoorLockClusterGetWeekDayScheduleResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, weekDayIndex, userIndex, status, daysMask, startHour, startMinute, endHour, endMinute); - return true; -} - -bool emberAfDoorLockClusterGetYearDayScheduleResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t yearDayIndex, uint16_t userIndex, uint8_t status, - uint32_t localStartTime, uint32_t localEndTime) -{ - ChipLogProgress(Zcl, "GetYearDayScheduleResponse:"); - ChipLogProgress(Zcl, " yearDayIndex: %" PRIu8 "", yearDayIndex); - ChipLogProgress(Zcl, " userIndex: %" PRIu16 "", userIndex); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " localStartTime: %" PRIu32 "", localStartTime); - ChipLogProgress(Zcl, " localEndTime: %" PRIu32 "", localEndTime); - - GET_CLUSTER_RESPONSE_CALLBACKS("DoorLockClusterGetYearDayScheduleResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, yearDayIndex, userIndex, status, localStartTime, localEndTime); - return true; -} - -bool emberAfDoorLockClusterSetCredentialResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - uint16_t userIndex, uint16_t nextCredentialIndex) -{ - ChipLogProgress(Zcl, "SetCredentialResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " userIndex: %" PRIu16 "", userIndex); - ChipLogProgress(Zcl, " nextCredentialIndex: %" PRIu16 "", nextCredentialIndex); - - GET_CLUSTER_RESPONSE_CALLBACKS("DoorLockClusterSetCredentialResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, userIndex, nextCredentialIndex); - return true; -} - -bool emberAfGeneralCommissioningClusterArmFailSafeResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t errorCode, chip::CharSpan debugText) -{ - ChipLogProgress(Zcl, "ArmFailSafeResponse:"); - ChipLogProgress(Zcl, " errorCode: %" PRIu8 "", errorCode); - ChipLogProgress(Zcl, " debugText: %.*s", static_cast(debugText.size()), debugText.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("GeneralCommissioningClusterArmFailSafeResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, errorCode, debugText); - return true; -} - -bool emberAfGeneralCommissioningClusterCommissioningCompleteResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t errorCode, chip::CharSpan debugText) -{ - ChipLogProgress(Zcl, "CommissioningCompleteResponse:"); - ChipLogProgress(Zcl, " errorCode: %" PRIu8 "", errorCode); - ChipLogProgress(Zcl, " debugText: %.*s", static_cast(debugText.size()), debugText.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("GeneralCommissioningClusterCommissioningCompleteResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, errorCode, debugText); - return true; -} - -bool emberAfGeneralCommissioningClusterSetRegulatoryConfigResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t errorCode, chip::CharSpan debugText) -{ - ChipLogProgress(Zcl, "SetRegulatoryConfigResponse:"); - ChipLogProgress(Zcl, " errorCode: %" PRIu8 "", errorCode); - ChipLogProgress(Zcl, " debugText: %.*s", static_cast(debugText.size()), debugText.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("GeneralCommissioningClusterSetRegulatoryConfigResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, errorCode, debugText); - return true; -} - -bool emberAfGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback( - EndpointId endpoint, app::CommandSender * commandObj, /* TYPE WARNING: array array defaults to */ uint8_t * groupKeySetIDs) -{ - ChipLogProgress(Zcl, "KeySetReadAllIndicesResponse:"); - ChipLogProgress(Zcl, " groupKeySetIDs: %p", groupKeySetIDs); - - GET_CLUSTER_RESPONSE_CALLBACKS("GroupKeyManagementClusterKeySetReadAllIndicesResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, groupKeySetIDs); - return true; -} - -bool emberAfGroupKeyManagementClusterKeySetReadResponseCallback( - EndpointId endpoint, app::CommandSender * commandObj, - chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySet::DecodableType groupKeySet) -{ - ChipLogProgress(Zcl, "KeySetReadResponse:"); - ChipLogProgress(Zcl, " groupKeySet: Not sure how to log struct GroupKeySet"); - - GET_CLUSTER_RESPONSE_CALLBACKS("GroupKeyManagementClusterKeySetReadResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, ::GroupKeySet()); - return true; -} - -bool emberAfGroupsClusterAddGroupResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - uint16_t groupId) -{ - ChipLogProgress(Zcl, "AddGroupResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " groupId: %" PRIu16 "", groupId); - - GET_CLUSTER_RESPONSE_CALLBACKS("GroupsClusterAddGroupResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, groupId); - return true; -} - -bool emberAfGroupsClusterGetGroupMembershipResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t capacity, - /* TYPE WARNING: array array defaults to */ uint8_t * groupList) -{ - ChipLogProgress(Zcl, "GetGroupMembershipResponse:"); - ChipLogProgress(Zcl, " capacity: %" PRIu8 "", capacity); - ChipLogProgress(Zcl, " groupList: %p", groupList); - - GET_CLUSTER_RESPONSE_CALLBACKS("GroupsClusterGetGroupMembershipResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, capacity, groupList); - return true; -} - -bool emberAfGroupsClusterRemoveGroupResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - uint16_t groupId) -{ - ChipLogProgress(Zcl, "RemoveGroupResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " groupId: %" PRIu16 "", groupId); - - GET_CLUSTER_RESPONSE_CALLBACKS("GroupsClusterRemoveGroupResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, groupId); - return true; -} - -bool emberAfGroupsClusterViewGroupResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - uint16_t groupId, chip::CharSpan groupName) -{ - ChipLogProgress(Zcl, "ViewGroupResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " groupId: %" PRIu16 "", groupId); - ChipLogProgress(Zcl, " groupName: %.*s", static_cast(groupName.size()), groupName.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("GroupsClusterViewGroupResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, groupId, groupName); - return true; -} - -bool emberAfIdentifyClusterIdentifyQueryResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint16_t timeout) -{ - ChipLogProgress(Zcl, "IdentifyQueryResponse:"); - ChipLogProgress(Zcl, " timeout: %" PRIu16 "", timeout); - - GET_CLUSTER_RESPONSE_CALLBACKS("IdentifyClusterIdentifyQueryResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, timeout); - return true; -} - -bool emberAfKeypadInputClusterSendKeyResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status) -{ - ChipLogProgress(Zcl, "SendKeyResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - - GET_CLUSTER_RESPONSE_CALLBACKS("KeypadInputClusterSendKeyResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status); - return true; -} - -bool emberAfMediaPlaybackClusterPlaybackResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status) -{ - ChipLogProgress(Zcl, "PlaybackResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - - GET_CLUSTER_RESPONSE_CALLBACKS("MediaPlaybackClusterPlaybackResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status); - return true; -} - -bool emberAfNetworkCommissioningClusterConnectNetworkResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t NetworkingStatus, chip::CharSpan DebugText, - int32_t ErrorValue) -{ - ChipLogProgress(Zcl, "ConnectNetworkResponse:"); - ChipLogProgress(Zcl, " NetworkingStatus: %" PRIu8 "", NetworkingStatus); - ChipLogProgress(Zcl, " DebugText: %.*s", static_cast(DebugText.size()), DebugText.data()); - ChipLogProgress(Zcl, " ErrorValue: %" PRId32 "", ErrorValue); - - GET_CLUSTER_RESPONSE_CALLBACKS("NetworkCommissioningClusterConnectNetworkResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, NetworkingStatus, DebugText, ErrorValue); - return true; -} - -bool emberAfNetworkCommissioningClusterNetworkConfigResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t NetworkingStatus, chip::CharSpan DebugText) -{ - ChipLogProgress(Zcl, "NetworkConfigResponse:"); - ChipLogProgress(Zcl, " NetworkingStatus: %" PRIu8 "", NetworkingStatus); - ChipLogProgress(Zcl, " DebugText: %.*s", static_cast(DebugText.size()), DebugText.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("NetworkCommissioningClusterNetworkConfigResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, NetworkingStatus, DebugText); - return true; -} - -bool emberAfNetworkCommissioningClusterScanNetworksResponseCallback( - EndpointId endpoint, app::CommandSender * commandObj, uint8_t NetworkingStatus, chip::CharSpan DebugText, - /* TYPE WARNING: array array defaults to */ uint8_t * WiFiScanResults, - /* TYPE WARNING: array array defaults to */ uint8_t * ThreadScanResults) -{ - ChipLogProgress(Zcl, "ScanNetworksResponse:"); - ChipLogProgress(Zcl, " NetworkingStatus: %" PRIu8 "", NetworkingStatus); - ChipLogProgress(Zcl, " DebugText: %.*s", static_cast(DebugText.size()), DebugText.data()); - ChipLogProgress(Zcl, " WiFiScanResults: %p", WiFiScanResults); - ChipLogProgress(Zcl, " ThreadScanResults: %p", ThreadScanResults); - - GET_CLUSTER_RESPONSE_CALLBACKS("NetworkCommissioningClusterScanNetworksResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, NetworkingStatus, DebugText, WiFiScanResults, ThreadScanResults); - return true; -} - -bool emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t action, uint32_t delayedActionTime) -{ - ChipLogProgress(Zcl, "ApplyUpdateResponse:"); - ChipLogProgress(Zcl, " action: %" PRIu8 "", action); - ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); - - GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, action, delayedActionTime); - return true; -} - -bool emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t status, uint32_t delayedActionTime, - chip::CharSpan imageURI, uint32_t softwareVersion, - chip::CharSpan softwareVersionString, - chip::ByteSpan updateToken, bool userConsentNeeded, - chip::ByteSpan metadataForRequestor) -{ - ChipLogProgress(Zcl, "QueryImageResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); - ChipLogProgress(Zcl, " imageURI: %.*s", static_cast(imageURI.size()), imageURI.data()); - ChipLogProgress(Zcl, " softwareVersion: %" PRIu32 "", softwareVersion); - ChipLogProgress(Zcl, " softwareVersionString: %.*s", static_cast(softwareVersionString.size()), - softwareVersionString.data()); - ChipLogProgress(Zcl, " updateToken: %zu", updateToken.size()); - ChipLogProgress(Zcl, " userConsentNeeded: %d", userConsentNeeded); - ChipLogProgress(Zcl, " metadataForRequestor: %zu", metadataForRequestor.size()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterQueryImageResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, delayedActionTime, imageURI, softwareVersion, softwareVersionString, updateToken, - userConsentNeeded, metadataForRequestor); - return true; -} - -bool emberAfOperationalCredentialsClusterAttestationResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - chip::ByteSpan AttestationElements, chip::ByteSpan Signature) -{ - ChipLogProgress(Zcl, "AttestationResponse:"); - ChipLogProgress(Zcl, " AttestationElements: %zu", AttestationElements.size()); - ChipLogProgress(Zcl, " Signature: %zu", Signature.size()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OperationalCredentialsClusterAttestationResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, AttestationElements, Signature); - return true; -} - -bool emberAfOperationalCredentialsClusterCertificateChainResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - chip::ByteSpan Certificate) -{ - ChipLogProgress(Zcl, "CertificateChainResponse:"); - ChipLogProgress(Zcl, " Certificate: %zu", Certificate.size()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OperationalCredentialsClusterCertificateChainResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, Certificate); - return true; -} - -bool emberAfOperationalCredentialsClusterNOCResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t StatusCode, uint8_t FabricIndex, chip::CharSpan DebugText) -{ - ChipLogProgress(Zcl, "NOCResponse:"); - ChipLogProgress(Zcl, " StatusCode: %" PRIu8 "", StatusCode); - ChipLogProgress(Zcl, " FabricIndex: %" PRIu8 "", FabricIndex); - ChipLogProgress(Zcl, " DebugText: %.*s", static_cast(DebugText.size()), DebugText.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OperationalCredentialsClusterNOCResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, StatusCode, FabricIndex, DebugText); - return true; -} - -bool emberAfOperationalCredentialsClusterOpCSRResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - chip::ByteSpan NOCSRElements, chip::ByteSpan AttestationSignature) -{ - ChipLogProgress(Zcl, "OpCSRResponse:"); - ChipLogProgress(Zcl, " NOCSRElements: %zu", NOCSRElements.size()); - ChipLogProgress(Zcl, " AttestationSignature: %zu", AttestationSignature.size()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OperationalCredentialsClusterOpCSRResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, NOCSRElements, AttestationSignature); - return true; -} - -bool emberAfScenesClusterAddSceneResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - uint16_t groupId, uint8_t sceneId) -{ - ChipLogProgress(Zcl, "AddSceneResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " groupId: %" PRIu16 "", groupId); - ChipLogProgress(Zcl, " sceneId: %" PRIu8 "", sceneId); - - GET_CLUSTER_RESPONSE_CALLBACKS("ScenesClusterAddSceneResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, groupId, sceneId); - return true; -} - -bool emberAfScenesClusterGetSceneMembershipResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - uint8_t capacity, uint16_t groupId, uint8_t sceneCount, - /* TYPE WARNING: array array defaults to */ uint8_t * sceneList) -{ - ChipLogProgress(Zcl, "GetSceneMembershipResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " capacity: %" PRIu8 "", capacity); - ChipLogProgress(Zcl, " groupId: %" PRIu16 "", groupId); - ChipLogProgress(Zcl, " sceneCount: %" PRIu8 "", sceneCount); - ChipLogProgress(Zcl, " sceneList: %p", sceneList); - - GET_CLUSTER_RESPONSE_CALLBACKS("ScenesClusterGetSceneMembershipResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, capacity, groupId, sceneCount, sceneList); - return true; -} - -bool emberAfScenesClusterRemoveAllScenesResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - uint16_t groupId) -{ - ChipLogProgress(Zcl, "RemoveAllScenesResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " groupId: %" PRIu16 "", groupId); - - GET_CLUSTER_RESPONSE_CALLBACKS("ScenesClusterRemoveAllScenesResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, groupId); - return true; -} - -bool emberAfScenesClusterRemoveSceneResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - uint16_t groupId, uint8_t sceneId) -{ - ChipLogProgress(Zcl, "RemoveSceneResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " groupId: %" PRIu16 "", groupId); - ChipLogProgress(Zcl, " sceneId: %" PRIu8 "", sceneId); - - GET_CLUSTER_RESPONSE_CALLBACKS("ScenesClusterRemoveSceneResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, groupId, sceneId); - return true; -} - -bool emberAfScenesClusterStoreSceneResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - uint16_t groupId, uint8_t sceneId) -{ - ChipLogProgress(Zcl, "StoreSceneResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " groupId: %" PRIu16 "", groupId); - ChipLogProgress(Zcl, " sceneId: %" PRIu8 "", sceneId); - - GET_CLUSTER_RESPONSE_CALLBACKS("ScenesClusterStoreSceneResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, groupId, sceneId); - return true; -} - -bool emberAfScenesClusterViewSceneResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t status, - uint16_t groupId, uint8_t sceneId, uint16_t transitionTime, - chip::CharSpan sceneName, - /* TYPE WARNING: array array defaults to */ uint8_t * extensionFieldSets) -{ - ChipLogProgress(Zcl, "ViewSceneResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " groupId: %" PRIu16 "", groupId); - ChipLogProgress(Zcl, " sceneId: %" PRIu8 "", sceneId); - ChipLogProgress(Zcl, " transitionTime: %" PRIu16 "", transitionTime); - ChipLogProgress(Zcl, " sceneName: %.*s", static_cast(sceneName.size()), sceneName.data()); - ChipLogProgress(Zcl, " extensionFieldSets: %p", extensionFieldSets); - - GET_CLUSTER_RESPONSE_CALLBACKS("ScenesClusterViewSceneResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, groupId, sceneId, transitionTime, sceneName, extensionFieldSets); - return true; -} - -bool emberAfTargetNavigatorClusterNavigateTargetResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t status, chip::CharSpan data) -{ - ChipLogProgress(Zcl, "NavigateTargetResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " data: %.*s", static_cast(data.size()), data.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("TargetNavigatorClusterNavigateTargetResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, data); - return true; -} - -bool emberAfTestClusterClusterBooleanResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, bool value) -{ - ChipLogProgress(Zcl, "BooleanResponse:"); - ChipLogProgress(Zcl, " value: %d", value); - - GET_CLUSTER_RESPONSE_CALLBACKS("TestClusterClusterBooleanResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - return true; -} - -bool emberAfTestClusterClusterSimpleStructResponseCallback( - EndpointId endpoint, app::CommandSender * commandObj, - chip::app::Clusters::TestCluster::Structs::SimpleStruct::DecodableType arg1) -{ - ChipLogProgress(Zcl, "SimpleStructResponse:"); - ChipLogProgress(Zcl, " arg1: Not sure how to log struct SimpleStruct"); - - GET_CLUSTER_RESPONSE_CALLBACKS("TestClusterClusterSimpleStructResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, ::SimpleStruct()); - return true; -} - -bool emberAfTestClusterClusterTestAddArgumentsResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t returnValue) -{ - ChipLogProgress(Zcl, "TestAddArgumentsResponse:"); - ChipLogProgress(Zcl, " returnValue: %" PRIu8 "", returnValue); - - GET_CLUSTER_RESPONSE_CALLBACKS("TestClusterClusterTestAddArgumentsResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, returnValue); - return true; -} - -bool emberAfTestClusterClusterTestEmitTestEventResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint64_t value) -{ - ChipLogProgress(Zcl, "TestEmitTestEventResponse:"); - ChipLogProgress(Zcl, " value: %" PRIu64 "", value); - - GET_CLUSTER_RESPONSE_CALLBACKS("TestClusterClusterTestEmitTestEventResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - return true; -} - -bool emberAfTestClusterClusterTestEnumsResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, chip::VendorId arg1, - uint8_t arg2) -{ - ChipLogProgress(Zcl, "TestEnumsResponse:"); - ChipLogProgress(Zcl, " arg1: %" PRIu16 "", arg1); - ChipLogProgress(Zcl, " arg2: %" PRIu8 "", arg2); - - GET_CLUSTER_RESPONSE_CALLBACKS("TestClusterClusterTestEnumsResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, arg1, arg2); - return true; -} - -bool emberAfTestClusterClusterTestListInt8UReverseResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - /* TYPE WARNING: array array defaults to */ uint8_t * arg1) -{ - ChipLogProgress(Zcl, "TestListInt8UReverseResponse:"); - ChipLogProgress(Zcl, " arg1: %p", arg1); - - GET_CLUSTER_RESPONSE_CALLBACKS("TestClusterClusterTestListInt8UReverseResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, arg1); - return true; -} - -bool emberAfTestClusterClusterTestNullableOptionalResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - bool wasPresent, bool wasNull, uint8_t value, - uint8_t originalValue) -{ - ChipLogProgress(Zcl, "TestNullableOptionalResponse:"); - ChipLogProgress(Zcl, " wasPresent: %d", wasPresent); - ChipLogProgress(Zcl, " wasNull: %d", wasNull); - ChipLogProgress(Zcl, " value: %" PRIu8 "", value); - ChipLogProgress(Zcl, " originalValue: %" PRIu8 "", originalValue); - - GET_CLUSTER_RESPONSE_CALLBACKS("TestClusterClusterTestNullableOptionalResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, wasPresent, wasNull, value, originalValue); - return true; -} - -bool emberAfTestClusterClusterTestSpecificResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t returnValue) -{ - ChipLogProgress(Zcl, "TestSpecificResponse:"); - ChipLogProgress(Zcl, " returnValue: %" PRIu8 "", returnValue); - - GET_CLUSTER_RESPONSE_CALLBACKS("TestClusterClusterTestSpecificResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, returnValue); - return true; -} - -bool emberAfThermostatClusterGetRelayStatusLogResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint16_t timeOfDay, uint16_t relayStatus, int16_t localTemperature, - uint8_t humidityInPercentage, int16_t setpoint, - uint16_t unreadEntries) -{ - ChipLogProgress(Zcl, "GetRelayStatusLogResponse:"); - ChipLogProgress(Zcl, " timeOfDay: %" PRIu16 "", timeOfDay); - ChipLogProgress(Zcl, " relayStatus: %" PRIu16 "", relayStatus); - ChipLogProgress(Zcl, " localTemperature: %" PRId16 "", localTemperature); - ChipLogProgress(Zcl, " humidityInPercentage: %" PRIu8 "", humidityInPercentage); - ChipLogProgress(Zcl, " setpoint: %" PRId16 "", setpoint); - ChipLogProgress(Zcl, " unreadEntries: %" PRIu16 "", unreadEntries); - - GET_CLUSTER_RESPONSE_CALLBACKS("ThermostatClusterGetRelayStatusLogResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, timeOfDay, relayStatus, localTemperature, humidityInPercentage, setpoint, unreadEntries); - return true; -} - -bool emberAfThermostatClusterGetWeeklyScheduleResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t numberOfTransitionsForSequence, uint8_t dayOfWeekForSequence, - uint8_t modeForSequence, - /* TYPE WARNING: array array defaults to */ uint8_t * payload) -{ - ChipLogProgress(Zcl, "GetWeeklyScheduleResponse:"); - ChipLogProgress(Zcl, " numberOfTransitionsForSequence: %" PRIu8 "", numberOfTransitionsForSequence); - ChipLogProgress(Zcl, " dayOfWeekForSequence: %" PRIu8 "", dayOfWeekForSequence); - ChipLogProgress(Zcl, " modeForSequence: %" PRIu8 "", modeForSequence); - ChipLogProgress(Zcl, " payload: %p", payload); - - GET_CLUSTER_RESPONSE_CALLBACKS("ThermostatClusterGetWeeklyScheduleResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, numberOfTransitionsForSequence, dayOfWeekForSequence, modeForSequence, payload); - return true; -} diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h index 20f0ebdabf723d..2d440da32c5950 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h @@ -30,96 +30,6 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks -typedef void (*AccountLoginClusterGetSetupPINResponseCallback)(void * context, chip::CharSpan setupPIN); -typedef void (*ApplicationLauncherClusterLauncherResponseCallback)(void * context, uint8_t status, chip::CharSpan data); -typedef void (*ChannelClusterChangeChannelResponseCallback)(void * context, ChannelInfo channelMatch, uint8_t errorType); -typedef void (*ContentLauncherClusterLaunchResponseCallback)(void * context, uint8_t status, chip::CharSpan data); -typedef void (*DiagnosticLogsClusterRetrieveLogsResponseCallback)(void * context, uint8_t status, chip::ByteSpan content, - uint32_t timeStamp, uint32_t timeSinceBoot); -typedef void (*DoorLockClusterGetCredentialStatusResponseCallback)(void * context, bool credentialExists, uint16_t userIndex, - uint16_t nextCredentialIndex); -typedef void (*DoorLockClusterGetUserResponseCallback)(void * context, uint16_t userIndex, chip::CharSpan userName, - uint32_t userUniqueId, uint8_t userStatus, uint8_t userType, - uint8_t credentialRule, - /* TYPE WARNING: array array defaults to */ uint8_t * credentials, - chip::FabricIndex creatorFabricIndex, - chip::FabricIndex lastModifiedFabricIndex, uint16_t nextUserIndex); -typedef void (*DoorLockClusterGetWeekDayScheduleResponseCallback)(void * context, uint8_t weekDayIndex, uint16_t userIndex, - uint8_t status, uint8_t daysMask, uint8_t startHour, - uint8_t startMinute, uint8_t endHour, uint8_t endMinute); -typedef void (*DoorLockClusterGetYearDayScheduleResponseCallback)(void * context, uint8_t yearDayIndex, uint16_t userIndex, - uint8_t status, uint32_t localStartTime, uint32_t localEndTime); -typedef void (*DoorLockClusterSetCredentialResponseCallback)(void * context, uint8_t status, uint16_t userIndex, - uint16_t nextCredentialIndex); -typedef void (*GeneralCommissioningClusterArmFailSafeResponseCallback)(void * context, uint8_t errorCode, chip::CharSpan debugText); -typedef void (*GeneralCommissioningClusterCommissioningCompleteResponseCallback)(void * context, uint8_t errorCode, - chip::CharSpan debugText); -typedef void (*GeneralCommissioningClusterSetRegulatoryConfigResponseCallback)(void * context, uint8_t errorCode, - chip::CharSpan debugText); -typedef void (*GroupKeyManagementClusterKeySetReadAllIndicesResponseCallback)( - void * context, /* TYPE WARNING: array array defaults to */ uint8_t * groupKeySetIDs); -typedef void (*GroupKeyManagementClusterKeySetReadResponseCallback)(void * context, GroupKeySet groupKeySet); -typedef void (*GroupsClusterAddGroupResponseCallback)(void * context, uint8_t status, uint16_t groupId); -typedef void (*GroupsClusterGetGroupMembershipResponseCallback)(void * context, uint8_t capacity, - /* TYPE WARNING: array array defaults to */ uint8_t * groupList); -typedef void (*GroupsClusterRemoveGroupResponseCallback)(void * context, uint8_t status, uint16_t groupId); -typedef void (*GroupsClusterViewGroupResponseCallback)(void * context, uint8_t status, uint16_t groupId, chip::CharSpan groupName); -typedef void (*IdentifyClusterIdentifyQueryResponseCallback)(void * context, uint16_t timeout); -typedef void (*KeypadInputClusterSendKeyResponseCallback)(void * context, uint8_t status); -typedef void (*MediaPlaybackClusterPlaybackResponseCallback)(void * context, uint8_t status); -typedef void (*NetworkCommissioningClusterConnectNetworkResponseCallback)(void * context, uint8_t NetworkingStatus, - chip::CharSpan DebugText, int32_t ErrorValue); -typedef void (*NetworkCommissioningClusterNetworkConfigResponseCallback)(void * context, uint8_t NetworkingStatus, - chip::CharSpan DebugText); -typedef void (*NetworkCommissioningClusterScanNetworksResponseCallback)( - void * context, uint8_t NetworkingStatus, chip::CharSpan DebugText, - /* TYPE WARNING: array array defaults to */ uint8_t * WiFiScanResults, - /* TYPE WARNING: array array defaults to */ uint8_t * ThreadScanResults); -typedef void (*OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback)(void * context, uint8_t action, - uint32_t delayedActionTime); -typedef void (*OtaSoftwareUpdateProviderClusterQueryImageResponseCallback)( - void * context, uint8_t status, uint32_t delayedActionTime, chip::CharSpan imageURI, uint32_t softwareVersion, - chip::CharSpan softwareVersionString, chip::ByteSpan updateToken, bool userConsentNeeded, chip::ByteSpan metadataForRequestor); -typedef void (*OperationalCredentialsClusterAttestationResponseCallback)(void * context, chip::ByteSpan AttestationElements, - chip::ByteSpan Signature); -typedef void (*OperationalCredentialsClusterCertificateChainResponseCallback)(void * context, chip::ByteSpan Certificate); -typedef void (*OperationalCredentialsClusterNOCResponseCallback)(void * context, uint8_t StatusCode, uint8_t FabricIndex, - chip::CharSpan DebugText); -typedef void (*OperationalCredentialsClusterOpCSRResponseCallback)(void * context, chip::ByteSpan NOCSRElements, - chip::ByteSpan AttestationSignature); -typedef void (*ScenesClusterAddSceneResponseCallback)(void * context, uint8_t status, uint16_t groupId, uint8_t sceneId); -typedef void (*ScenesClusterGetSceneMembershipResponseCallback)(void * context, uint8_t status, uint8_t capacity, uint16_t groupId, - uint8_t sceneCount, - /* TYPE WARNING: array array defaults to */ uint8_t * sceneList); -typedef void (*ScenesClusterRemoveAllScenesResponseCallback)(void * context, uint8_t status, uint16_t groupId); -typedef void (*ScenesClusterRemoveSceneResponseCallback)(void * context, uint8_t status, uint16_t groupId, uint8_t sceneId); -typedef void (*ScenesClusterStoreSceneResponseCallback)(void * context, uint8_t status, uint16_t groupId, uint8_t sceneId); -typedef void (*ScenesClusterViewSceneResponseCallback)(void * context, uint8_t status, uint16_t groupId, uint8_t sceneId, - uint16_t transitionTime, chip::CharSpan sceneName, - /* TYPE WARNING: array array defaults to */ uint8_t * extensionFieldSets); -typedef void (*TargetNavigatorClusterNavigateTargetResponseCallback)(void * context, uint8_t status, chip::CharSpan data); -typedef void (*TestClusterClusterBooleanResponseCallback)(void * context, bool value); -typedef void (*TestClusterClusterSimpleStructResponseCallback)(void * context, SimpleStruct arg1); -typedef void (*TestClusterClusterTestAddArgumentsResponseCallback)(void * context, uint8_t returnValue); -typedef void (*TestClusterClusterTestEmitTestEventResponseCallback)(void * context, uint64_t value); -typedef void (*TestClusterClusterTestEnumsResponseCallback)(void * context, chip::VendorId arg1, uint8_t arg2); -typedef void (*TestClusterClusterTestListInt8UReverseResponseCallback)(void * context, - /* TYPE WARNING: array array defaults to */ uint8_t * arg1); -typedef void (*TestClusterClusterTestNullableOptionalResponseCallback)(void * context, bool wasPresent, bool wasNull, uint8_t value, - uint8_t originalValue); -typedef void (*TestClusterClusterTestSpecificResponseCallback)(void * context, uint8_t returnValue); -typedef void (*ThermostatClusterGetRelayStatusLogResponseCallback)(void * context, uint16_t timeOfDay, uint16_t relayStatus, - int16_t localTemperature, uint8_t humidityInPercentage, - int16_t setpoint, uint16_t unreadEntries); -typedef void (*ThermostatClusterGetWeeklyScheduleResponseCallback)(void * context, uint8_t numberOfTransitionsForSequence, - uint8_t dayOfWeekForSequence, uint8_t modeForSequence, - /* TYPE WARNING: array array defaults to */ uint8_t * payload); - // List specific responses void AccessControlClusterAclListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, chip::Callback::Cancelable * onFailureCallback); diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp deleted file mode 100644 index c041827eb64555..00000000000000 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,7879 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// AccessControl Cluster Commands - -// AccountLogin Cluster Commands -CHIP_ERROR AccountLoginCluster::GetSetupPINRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::CharSpan tempAccountIdentifier) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, AccountLogin::Commands::GetSetupPINRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // tempAccountIdentifier: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), tempAccountIdentifier)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR AccountLoginCluster::LoginRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan tempAccountIdentifier, chip::CharSpan setupPIN) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, AccountLogin::Commands::LoginRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // tempAccountIdentifier: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), tempAccountIdentifier)); - // setupPIN: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), setupPIN)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR AccountLoginCluster::LogoutRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, AccountLogin::Commands::LogoutRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// AdministratorCommissioning Cluster Commands -CHIP_ERROR AdministratorCommissioningCluster::OpenBasicCommissioningWindow(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - uint16_t commissioningTimeout) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // commissioningTimeout: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), commissioningTimeout)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR AdministratorCommissioningCluster::OpenCommissioningWindow(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - uint16_t commissioningTimeout, chip::ByteSpan PAKEVerifier, - uint16_t discriminator, uint32_t iterations, - chip::ByteSpan salt, uint16_t passcodeID) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - AdministratorCommissioning::Commands::OpenCommissioningWindow::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // commissioningTimeout: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), commissioningTimeout)); - // PAKEVerifier: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), PAKEVerifier)); - // discriminator: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), discriminator)); - // iterations: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), iterations)); - // salt: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), salt)); - // passcodeID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), passcodeID)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR AdministratorCommissioningCluster::RevokeCommissioning(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - AdministratorCommissioning::Commands::RevokeCommissioning::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// ApplicationBasic Cluster Commands - -// ApplicationLauncher Cluster Commands -CHIP_ERROR ApplicationLauncherCluster::HideAppRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t catalogVendorId, - chip::CharSpan applicationId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ApplicationLauncher::Commands::HideAppRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // catalogVendorId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), catalogVendorId)); - // applicationId: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), applicationId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ApplicationLauncherCluster::LaunchAppRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::CharSpan data, - uint16_t catalogVendorId, chip::CharSpan applicationId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ApplicationLauncher::Commands::LaunchAppRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // data: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), data)); - // catalogVendorId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), catalogVendorId)); - // applicationId: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), applicationId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ApplicationLauncherCluster::StopAppRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t catalogVendorId, - chip::CharSpan applicationId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ApplicationLauncher::Commands::StopAppRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // catalogVendorId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), catalogVendorId)); - // applicationId: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), applicationId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// AudioOutput Cluster Commands -CHIP_ERROR AudioOutputCluster::RenameOutputRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t index, chip::CharSpan name) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, AudioOutput::Commands::RenameOutputRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // index: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), index)); - // name: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), name)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR AudioOutputCluster::SelectOutputRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t index) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, AudioOutput::Commands::SelectOutputRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // index: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), index)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// BarrierControl Cluster Commands -CHIP_ERROR BarrierControlCluster::BarrierControlGoToPercent(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t percentOpen) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - BarrierControl::Commands::BarrierControlGoToPercent::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // percentOpen: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), percentOpen)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BarrierControlCluster::BarrierControlStop(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, BarrierControl::Commands::BarrierControlStop::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Basic Cluster Commands - -// BinaryInputBasic Cluster Commands - -// Binding Cluster Commands -CHIP_ERROR BindingCluster::Bind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::NodeId nodeId, chip::GroupId groupId, chip::EndpointId endpointId, chip::ClusterId clusterId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Binding::Commands::Bind::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // nodeId: nodeId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), nodeId)); - // groupId: groupId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // endpointId: endpointNo - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), endpointId)); - // clusterId: clusterId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), clusterId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BindingCluster::Unbind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::NodeId nodeId, chip::GroupId groupId, chip::EndpointId endpointId, - chip::ClusterId clusterId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Binding::Commands::Unbind::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // nodeId: nodeId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), nodeId)); - // groupId: groupId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // endpointId: endpointNo - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), endpointId)); - // clusterId: clusterId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), clusterId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// BooleanState Cluster Commands - -// BridgedActions Cluster Commands -CHIP_ERROR BridgedActionsCluster::DisableAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, BridgedActions::Commands::DisableAction::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::DisableActionWithDuration(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID, uint32_t duration) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - BridgedActions::Commands::DisableActionWithDuration::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - // duration: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), duration)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::EnableAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, BridgedActions::Commands::EnableAction::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::EnableActionWithDuration(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID, uint32_t duration) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - BridgedActions::Commands::EnableActionWithDuration::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - // duration: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), duration)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::InstantAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, BridgedActions::Commands::InstantAction::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::InstantActionWithTransition(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID, uint16_t transitionTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - BridgedActions::Commands::InstantActionWithTransition::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::PauseAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, BridgedActions::Commands::PauseAction::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::PauseActionWithDuration(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID, uint32_t duration) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - BridgedActions::Commands::PauseActionWithDuration::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - // duration: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), duration)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::ResumeAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, BridgedActions::Commands::ResumeAction::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::StartAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, BridgedActions::Commands::StartAction::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::StartActionWithDuration(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID, uint32_t duration) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - BridgedActions::Commands::StartActionWithDuration::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - // duration: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), duration)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BridgedActionsCluster::StopAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, BridgedActions::Commands::StopAction::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // actionID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), actionID)); - // invokeID: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), invokeID)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// BridgedDeviceBasic Cluster Commands - -// Channel Cluster Commands -CHIP_ERROR ChannelCluster::ChangeChannelByNumberRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t majorNumber, - uint16_t minorNumber) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - Channel::Commands::ChangeChannelByNumberRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // majorNumber: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), majorNumber)); - // minorNumber: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), minorNumber)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ChannelCluster::ChangeChannelRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan match) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Channel::Commands::ChangeChannelRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // match: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), match)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ChannelCluster::SkipChannelRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t count) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Channel::Commands::SkipChannelRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // count: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), count)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// ColorControl Cluster Commands -CHIP_ERROR ColorControlCluster::ColorLoopSet(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t updateFlags, uint8_t action, uint8_t direction, uint16_t time, - uint16_t startHue, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::ColorLoopSet::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateFlags: colorLoopUpdateFlags - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateFlags)); - // action: colorLoopAction - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), action)); - // direction: colorLoopDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // time: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), time)); - // startHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), startHue)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::EnhancedMoveHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: hueMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveToHue(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t enhancedHue, uint8_t direction, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::EnhancedMoveToHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // enhancedHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), enhancedHue)); - // direction: hueDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t enhancedHue, - uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ColorControl::Commands::EnhancedMoveToHueAndSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // enhancedHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), enhancedHue)); - // saturation: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedStepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::EnhancedStepHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: hueStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - int16_t rateX, int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveColor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // rateX: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rateX)); - // rateY: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rateY)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveColorTemperature(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t moveMode, uint16_t rate, - uint16_t colorTemperatureMinimum, uint16_t colorTemperatureMaximum, - uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveColorTemperature::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: hueMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // colorTemperatureMinimum: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMinimum)); - // colorTemperatureMaximum: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMaximum)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: hueMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: saturationMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t colorX, uint16_t colorY, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveToColor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // colorX: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorX)); - // colorY: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorY)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToColorTemperature(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t colorTemperature, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ColorControl::Commands::MoveToColorTemperature::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // colorTemperature: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperature)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t hue, uint8_t direction, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveToHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // hue: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hue)); - // direction: hueDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t hue, uint8_t saturation, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ColorControl::Commands::MoveToHueAndSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // hue: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hue)); - // saturation: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveToSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // saturation: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StepColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - int16_t stepX, int16_t stepY, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StepColor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepX: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepX)); - // stepY: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepY)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StepColorTemperature(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t stepMode, uint16_t stepSize, - uint16_t transitionTime, uint16_t colorTemperatureMinimum, - uint16_t colorTemperatureMaximum, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StepColorTemperature::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: hueStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // colorTemperatureMinimum: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMinimum)); - // colorTemperatureMaximum: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMaximum)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StepHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: hueStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StepSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StepSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: saturationStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StopMoveStep(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StopMoveStep::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// ContentLauncher Cluster Commands -CHIP_ERROR ContentLauncherCluster::LaunchContentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, bool autoPlay, - chip::CharSpan data) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ContentLauncher::Commands::LaunchContentRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // autoPlay: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), autoPlay)); - // data: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), data)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ContentLauncherCluster::LaunchURLRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::CharSpan contentURL, - chip::CharSpan displayString, chip::CharSpan providerName) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ContentLauncher::Commands::LaunchURLRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // contentURL: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), contentURL)); - // displayString: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), displayString)); - // providerName: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), providerName)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Descriptor Cluster Commands - -// DiagnosticLogs Cluster Commands -CHIP_ERROR DiagnosticLogsCluster::RetrieveLogsRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t intent, - uint8_t requestedProtocol, chip::ByteSpan transferFileDesignator) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DiagnosticLogs::Commands::RetrieveLogsRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // intent: logsIntent - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), intent)); - // requestedProtocol: logsTransferProtocol - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), requestedProtocol)); - // transferFileDesignator: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transferFileDesignator)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// DoorLock Cluster Commands -CHIP_ERROR DoorLockCluster::ClearCredential(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t credentialType, uint16_t credentialIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::ClearCredential::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // credentialType: dlCredentialType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), credentialType)); - // credentialIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), credentialIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::ClearUser(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t userIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::ClearUser::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // userIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::ClearWeekDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t weekDayIndex, uint16_t userIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::ClearWeekDaySchedule::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // weekDayIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), weekDayIndex)); - // userIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::ClearYearDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t yearDayIndex, uint16_t userIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::ClearYearDaySchedule::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // yearDayIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), yearDayIndex)); - // userIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::GetCredentialStatus(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t credentialType, uint16_t credentialIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::GetCredentialStatus::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // credentialType: dlCredentialType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), credentialType)); - // credentialIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), credentialIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::GetUser(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t userIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::GetUser::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // userIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::GetWeekDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t weekDayIndex, uint16_t userIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::GetWeekDaySchedule::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // weekDayIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), weekDayIndex)); - // userIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::GetYearDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t yearDayIndex, uint16_t userIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::GetYearDaySchedule::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // yearDayIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), yearDayIndex)); - // userIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::LockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan pinCode) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::LockDoor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // pinCode: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), pinCode)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::SetCredential(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t operationType, uint8_t credentialType, uint16_t credentialIndex, - chip::ByteSpan credentialData, uint16_t userIndex, uint8_t userStatus, uint8_t userType) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::SetCredential::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // operationType: dlDataOperationType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), operationType)); - // credentialType: dlCredentialType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), credentialType)); - // credentialIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), credentialIndex)); - // credentialData: longOctetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), credentialData)); - // userIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userIndex)); - // userStatus: dlUserStatus - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userStatus)); - // userType: dlUserType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userType)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::SetUser(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t operationType, uint16_t userIndex, chip::CharSpan userName, uint32_t userUniqueId, - uint8_t userStatus, uint8_t userType, uint8_t credentialRule) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::SetUser::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // operationType: dlDataOperationType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), operationType)); - // userIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userIndex)); - // userName: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), userName)); - // userUniqueId: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userUniqueId)); - // userStatus: dlUserStatus - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userStatus)); - // userType: dlUserType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userType)); - // credentialRule: dlCredentialRule - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), credentialRule)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::SetWeekDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t weekDayIndex, uint16_t userIndex, uint8_t daysMask, uint8_t startHour, - uint8_t startMinute, uint8_t endHour, uint8_t endMinute) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::SetWeekDaySchedule::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // weekDayIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), weekDayIndex)); - // userIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userIndex)); - // daysMask: dlDaysMaskMap - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), daysMask)); - // startHour: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), startHour)); - // startMinute: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), startMinute)); - // endHour: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), endHour)); - // endMinute: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), endMinute)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::SetYearDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t yearDayIndex, uint16_t userIndex, uint32_t localStartTime, - uint32_t localEndTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::SetYearDaySchedule::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // yearDayIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), yearDayIndex)); - // userIndex: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), userIndex)); - // localStartTime: epochS - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), localStartTime)); - // localEndTime: epochS - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), localEndTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::UnlockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan pinCode) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::UnlockDoor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // pinCode: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), pinCode)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR DoorLockCluster::UnlockWithTimeout(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t timeout, chip::ByteSpan pinCode) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, DoorLock::Commands::UnlockWithTimeout::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // timeout: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), timeout)); - // pinCode: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), pinCode)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// ElectricalMeasurement Cluster Commands - -// EthernetNetworkDiagnostics Cluster Commands -CHIP_ERROR EthernetNetworkDiagnosticsCluster::ResetCounts(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - EthernetNetworkDiagnostics::Commands::ResetCounts::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// FixedLabel Cluster Commands - -// FlowMeasurement Cluster Commands - -// GeneralCommissioning Cluster Commands -CHIP_ERROR GeneralCommissioningCluster::ArmFailSafe(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t expiryLengthSeconds, - uint64_t breadcrumb, uint32_t timeoutMs) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, GeneralCommissioning::Commands::ArmFailSafe::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // expiryLengthSeconds: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), expiryLengthSeconds)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - // timeoutMs: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GeneralCommissioningCluster::CommissioningComplete(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - GeneralCommissioning::Commands::CommissioningComplete::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GeneralCommissioningCluster::SetRegulatoryConfig(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t location, - chip::CharSpan countryCode, uint64_t breadcrumb, uint32_t timeoutMs) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - GeneralCommissioning::Commands::SetRegulatoryConfig::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // location: regulatoryLocationType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), location)); - // countryCode: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), countryCode)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - // timeoutMs: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// GeneralDiagnostics Cluster Commands - -// GroupKeyManagement Cluster Commands -CHIP_ERROR GroupKeyManagementCluster::KeySetRead(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupKeySetID) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, GroupKeyManagement::Commands::KeySetRead::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupKeySetID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupKeySetID)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupKeyManagementCluster::KeySetReadAllIndices(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t groupKeySetIDs) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - GroupKeyManagement::Commands::KeySetReadAllIndices::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupKeySetIDs: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupKeySetIDs)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupKeyManagementCluster::KeySetRemove(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t groupKeySetID) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, GroupKeyManagement::Commands::KeySetRemove::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupKeySetID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupKeySetID)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupKeyManagementCluster::KeySetWrite(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t groupKeySetID, - uint8_t securityPolicy, chip::ByteSpan epochKey0, uint64_t epochStartTime0, - chip::ByteSpan epochKey1, uint64_t epochStartTime1, chip::ByteSpan epochKey2, - uint64_t epochStartTime2) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, GroupKeyManagement::Commands::KeySetWrite::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupKeySetID: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupKeySetID)); - // securityPolicy: groupKeySecurityPolicy - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), securityPolicy)); - // epochKey0: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), epochKey0)); - // epochStartTime0: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), epochStartTime0)); - // epochKey1: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), epochKey1)); - // epochStartTime1: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), epochStartTime1)); - // epochKey2: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), epochKey2)); - // epochStartTime2: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), epochStartTime2)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Groups Cluster Commands -CHIP_ERROR GroupsCluster::AddGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, chip::CharSpan groupName) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::AddGroup::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // groupName: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), groupName)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupsCluster::AddGroupIfIdentifying(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, chip::CharSpan groupName) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::AddGroupIfIdentifying::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // groupName: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), groupName)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupsCluster::GetGroupMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupList) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::GetGroupMembership::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupList: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupList)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupsCluster::RemoveAllGroups(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::RemoveAllGroups::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupsCluster::RemoveGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::RemoveGroup::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GroupsCluster::ViewGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Groups::Commands::ViewGroup::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Identify Cluster Commands -CHIP_ERROR IdentifyCluster::Identify(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t identifyTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Identify::Commands::Identify::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // identifyTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), identifyTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR IdentifyCluster::IdentifyQuery(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Identify::Commands::IdentifyQuery::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR IdentifyCluster::TriggerEffect(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t effectIdentifier, uint8_t effectVariant) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Identify::Commands::TriggerEffect::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // effectIdentifier: identifyEffectIdentifier - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), effectIdentifier)); - // effectVariant: identifyEffectVariant - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), effectVariant)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// IlluminanceMeasurement Cluster Commands - -// KeypadInput Cluster Commands -CHIP_ERROR KeypadInputCluster::SendKeyRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t keyCode) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, KeypadInput::Commands::SendKeyRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // keyCode: cecKeyCode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), keyCode)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// LevelControl Cluster Commands -CHIP_ERROR LevelControlCluster::Move(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint8_t rate, uint8_t optionMask, uint8_t optionOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::Move::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: moveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); - // optionOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::MoveToLevel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t level, uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::MoveToLevel::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // level: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), level)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); - // optionOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::MoveToLevelWithOnOff(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t level, - uint16_t transitionTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::MoveToLevelWithOnOff::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // level: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), level)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::MoveWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint8_t rate) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::MoveWithOnOff::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: moveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::Step(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint8_t stepSize, uint16_t transitionTime, uint8_t optionMask, - uint8_t optionOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::Step::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: stepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); - // optionOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::StepWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint8_t stepSize, uint16_t transitionTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::StepWithOnOff::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: stepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::Stop(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t optionMask, uint8_t optionOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::Stop::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // optionMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); - // optionOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::StopWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::StopWithOnOff::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// LocalizationConfiguration Cluster Commands - -// LowPower Cluster Commands -CHIP_ERROR LowPowerCluster::Sleep(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LowPower::Commands::Sleep::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// MediaInput Cluster Commands -CHIP_ERROR MediaInputCluster::HideInputStatusRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaInput::Commands::HideInputStatusRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaInputCluster::RenameInputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t index, chip::CharSpan name) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaInput::Commands::RenameInputRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // index: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), index)); - // name: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), name)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaInputCluster::SelectInputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t index) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaInput::Commands::SelectInputRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // index: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), index)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaInputCluster::ShowInputStatusRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaInput::Commands::ShowInputStatusRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// MediaPlayback Cluster Commands -CHIP_ERROR MediaPlaybackCluster::FastForwardRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::FastForwardRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::NextRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::NextRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::PauseRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::PauseRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::PlayRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::PlayRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::PreviousRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::PreviousRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::RewindRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::RewindRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::SeekRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint64_t position) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::SeekRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // position: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), position)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::SkipBackwardRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::SkipBackwardRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // deltaPositionMilliseconds: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), deltaPositionMilliseconds)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::SkipForwardRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::SkipForwardRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // deltaPositionMilliseconds: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), deltaPositionMilliseconds)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::StartOverRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::StartOverRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::StopRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::StopRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// ModeSelect Cluster Commands -CHIP_ERROR ModeSelectCluster::ChangeToMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t newMode) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ModeSelect::Commands::ChangeToMode::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // newMode: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), newMode)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// NetworkCommissioning Cluster Commands -CHIP_ERROR NetworkCommissioningCluster::AddOrUpdateThreadNetwork(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan operationalDataset, uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - NetworkCommissioning::Commands::AddOrUpdateThreadNetwork::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // operationalDataset: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), operationalDataset)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR NetworkCommissioningCluster::AddOrUpdateWiFiNetwork(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid, - chip::ByteSpan credentials, uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - NetworkCommissioning::Commands::AddOrUpdateWiFiNetwork::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // ssid: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ssid)); - // credentials: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), credentials)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR NetworkCommissioningCluster::ConnectNetwork(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID, - uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - NetworkCommissioning::Commands::ConnectNetwork::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // networkID: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), networkID)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR NetworkCommissioningCluster::RemoveNetwork(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID, - uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, NetworkCommissioning::Commands::RemoveNetwork::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // networkID: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), networkID)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR NetworkCommissioningCluster::ReorderNetwork(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID, - uint8_t networkIndex, uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - NetworkCommissioning::Commands::ReorderNetwork::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // networkID: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), networkID)); - // networkIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), networkIndex)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR NetworkCommissioningCluster::ScanNetworks(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid, - uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, NetworkCommissioning::Commands::ScanNetworks::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // ssid: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ssid)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OtaSoftwareUpdateProvider Cluster Commands -CHIP_ERROR OtaSoftwareUpdateProviderCluster::ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // newVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), newVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::QueryImage(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::VendorId vendorId, - uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::QueryImage::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // vendorId: vendorId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), vendorId)); - // productId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), productId)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - // protocolsSupported: OTADownloadProtocol - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), protocolsSupported)); - // hardwareVersion: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hardwareVersion)); - // location: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), location)); - // requestorCanConsent: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), requestorCanConsent)); - // metadataForProvider: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), metadataForProvider)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OtaSoftwareUpdateRequestor Cluster Commands -CHIP_ERROR OtaSoftwareUpdateRequestorCluster::AnnounceOtaProvider(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::NodeId providerNodeId, chip::VendorId vendorId, - uint8_t announcementReason, chip::ByteSpan metadataForNode, - chip::EndpointId endpoint) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // providerNodeId: nodeId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), providerNodeId)); - // vendorId: vendorId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), vendorId)); - // announcementReason: OTAAnnouncementReason - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), announcementReason)); - // metadataForNode: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), metadataForNode)); - // endpoint: endpointNo - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), endpoint)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OccupancySensing Cluster Commands - -// OnOff Cluster Commands -CHIP_ERROR OnOffCluster::Off(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::Off::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::OffWithEffect(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t effectId, uint8_t effectVariant) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::OffWithEffect::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // effectId: onOffEffectIdentifier - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), effectId)); - // effectVariant: onOffDelayedAllOffEffectVariant - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), effectVariant)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::On(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::On::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::OnWithRecallGlobalScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::OnWithRecallGlobalScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::OnWithTimedOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t onOffControl, uint16_t onTime, uint16_t offWaitTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::OnWithTimedOff::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // onOffControl: onOffControl - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), onOffControl)); - // onTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), onTime)); - // offWaitTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), offWaitTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::Toggle(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::Toggle::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OnOffSwitchConfiguration Cluster Commands - -// OperationalCredentials Cluster Commands -CHIP_ERROR OperationalCredentialsCluster::AddNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan NOCValue, chip::ByteSpan ICACValue, chip::ByteSpan IPKValue, - chip::NodeId caseAdminNode, uint16_t adminVendorId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OperationalCredentials::Commands::AddNOC::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // NOCValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), NOCValue)); - // ICACValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ICACValue)); - // IPKValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), IPKValue)); - // caseAdminNode: nodeId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), caseAdminNode)); - // adminVendorId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), adminVendorId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::AddTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan rootCertificate) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::AddTrustedRootCertificate::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // rootCertificate: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rootCertificate)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::AttestationRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan attestationNonce) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::AttestationRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // attestationNonce: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), attestationNonce)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::CertificateChainRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t certificateType) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::CertificateChainRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // certificateType: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), certificateType)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::OpCSRRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan CSRNonce) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::OpCSRRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // CSRNonce: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), CSRNonce)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::RemoveFabric(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t fabricIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::RemoveFabric::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // fabricIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), fabricIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::RemoveTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan trustedRootIdentifier) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::RemoveTrustedRootCertificate::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // trustedRootIdentifier: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), trustedRootIdentifier)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::UpdateFabricLabel(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::CharSpan label) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::UpdateFabricLabel::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // label: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), label)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::UpdateNOC(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan NOCValue, - chip::ByteSpan ICACValue) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OperationalCredentials::Commands::UpdateNOC::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // NOCValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), NOCValue)); - // ICACValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ICACValue)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// PowerSource Cluster Commands - -// PowerSourceConfiguration Cluster Commands - -// PressureMeasurement Cluster Commands - -// PumpConfigurationAndControl Cluster Commands - -// RelativeHumidityMeasurement Cluster Commands - -// Scenes Cluster Commands -CHIP_ERROR ScenesCluster::AddScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId, uint16_t transitionTime, chip::CharSpan sceneName, - chip::ClusterId clusterId, uint8_t length, uint8_t value) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::AddScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // sceneId: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // sceneName: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), sceneName)); - // clusterId: clusterId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), clusterId)); - // length: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), length)); - // value: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), value)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::GetSceneMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::GetSceneMembership::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::RecallScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId, uint16_t transitionTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::RecallScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // sceneId: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::RemoveAllScenes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::RemoveAllScenes::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::RemoveScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::RemoveScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // sceneId: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::StoreScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::StoreScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // sceneId: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ScenesCluster::ViewScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Scenes::Commands::ViewScene::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // groupId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // sceneId: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// SoftwareDiagnostics Cluster Commands -CHIP_ERROR SoftwareDiagnosticsCluster::ResetWatermarks(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - SoftwareDiagnostics::Commands::ResetWatermarks::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Switch Cluster Commands - -// TargetNavigator Cluster Commands -CHIP_ERROR TargetNavigatorCluster::NavigateTargetRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t target, - chip::CharSpan data) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TargetNavigator::Commands::NavigateTargetRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // target: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), target)); - // data: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), data)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// TemperatureMeasurement Cluster Commands - -// TestCluster Cluster Commands -CHIP_ERROR TestClusterCluster::SimpleStructEchoRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t a, bool b, uint8_t c, - chip::ByteSpan d, chip::CharSpan e, uint8_t f, float g, double h) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::SimpleStructEchoRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // a: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), a)); - // b: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), b)); - // c: simpleEnum - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), c)); - // d: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), d)); - // e: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), e)); - // f: simpleBitmap - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), f)); - // g: single - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), g)); - // h: double - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), h)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::Test(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, TestCluster::Commands::Test::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestAddArguments(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t arg1, uint8_t arg2) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, TestCluster::Commands::TestAddArguments::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // arg1: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg1)); - // arg2: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg2)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestEmitTestEventRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t arg1, uint8_t arg2, - bool arg3) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::TestEmitTestEventRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // arg1: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg1)); - // arg2: simpleEnum - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg2)); - // arg3: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg3)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestEnumsRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::VendorId arg1, uint8_t arg2) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, TestCluster::Commands::TestEnumsRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // arg1: vendorId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg1)); - // arg2: simpleEnum - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg2)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestListInt8UArgumentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t arg1) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::TestListInt8UArgumentRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // arg1: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg1)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestListInt8UReverseRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t arg1) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::TestListInt8UReverseRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // arg1: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg1)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestListNestedStructListArgumentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t a, bool b, - uint32_t e, chip::ByteSpan f, uint8_t g) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::TestListNestedStructListArgumentRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // a: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), a)); - // b: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), b)); - // e: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), e)); - // f: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), f)); - // g: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), g)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestListStructArgumentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t a, bool b, uint8_t c, - chip::ByteSpan d, chip::CharSpan e, uint8_t f, float g, double h) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::TestListStructArgumentRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // a: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), a)); - // b: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), b)); - // c: simpleEnum - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), c)); - // d: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), d)); - // e: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), e)); - // f: simpleBitmap - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), f)); - // g: single - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), g)); - // h: double - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), h)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestNestedStructArgumentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t a, bool b) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::TestNestedStructArgumentRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // a: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), a)); - // b: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), b)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestNestedStructListArgumentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t a, bool b, - uint32_t e, chip::ByteSpan f, uint8_t g) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::TestNestedStructListArgumentRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // a: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), a)); - // b: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), b)); - // e: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), e)); - // f: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), f)); - // g: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), g)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestNotHandled(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, TestCluster::Commands::TestNotHandled::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestNullableOptionalRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t arg1) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::TestNullableOptionalRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // arg1: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg1)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestSimpleOptionalArgumentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, bool arg1) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::TestSimpleOptionalArgumentRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // arg1: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), arg1)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestSpecific(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, TestCluster::Commands::TestSpecific::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestStructArgumentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t a, bool b, uint8_t c, - chip::ByteSpan d, chip::CharSpan e, uint8_t f, float g, double h) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TestCluster::Commands::TestStructArgumentRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // a: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), a)); - // b: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), b)); - // c: simpleEnum - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), c)); - // d: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), d)); - // e: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), e)); - // f: simpleBitmap - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), f)); - // g: single - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), g)); - // h: double - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), h)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TestUnknownCommand(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, TestCluster::Commands::TestUnknownCommand::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR TestClusterCluster::TimedInvokeRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, TestCluster::Commands::TimedInvokeRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Thermostat Cluster Commands -CHIP_ERROR ThermostatCluster::ClearWeeklySchedule(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Thermostat::Commands::ClearWeeklySchedule::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ThermostatCluster::GetRelayStatusLog(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Thermostat::Commands::GetRelayStatusLog::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ThermostatCluster::GetWeeklySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t daysToReturn, uint8_t modeToReturn) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Thermostat::Commands::GetWeeklySchedule::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // daysToReturn: dayOfWeek - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), daysToReturn)); - // modeToReturn: modeForSequence - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), modeToReturn)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ThermostatCluster::SetWeeklySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t numberOfTransitionsForSequence, uint8_t dayOfWeekForSequence, - uint8_t modeForSequence, uint8_t payload) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Thermostat::Commands::SetWeeklySchedule::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // numberOfTransitionsForSequence: enum8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), numberOfTransitionsForSequence)); - // dayOfWeekForSequence: dayOfWeek - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), dayOfWeekForSequence)); - // modeForSequence: modeForSequence - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), modeForSequence)); - // payload: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), payload)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ThermostatCluster::SetpointRaiseLower(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t mode, int8_t amount) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Thermostat::Commands::SetpointRaiseLower::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // mode: setpointAdjustMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), mode)); - // amount: int8s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), amount)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// ThermostatUserInterfaceConfiguration Cluster Commands - -// ThreadNetworkDiagnostics Cluster Commands -CHIP_ERROR ThreadNetworkDiagnosticsCluster::ResetCounts(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ThreadNetworkDiagnostics::Commands::ResetCounts::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// TimeFormatLocalization Cluster Commands - -// UnitLocalization Cluster Commands - -// UserLabel Cluster Commands - -// WakeOnLan Cluster Commands - -// WiFiNetworkDiagnostics Cluster Commands -CHIP_ERROR WiFiNetworkDiagnosticsCluster::ResetCounts(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, WiFiNetworkDiagnostics::Commands::ResetCounts::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// WindowCovering Cluster Commands -CHIP_ERROR WindowCoveringCluster::DownOrClose(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, WindowCovering::Commands::DownOrClose::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR WindowCoveringCluster::GoToLiftPercentage(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::Percent liftPercentageValue, - chip::Percent100ths liftPercent100thsValue) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, WindowCovering::Commands::GoToLiftPercentage::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // liftPercentageValue: percent - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), liftPercentageValue)); - // liftPercent100thsValue: percent100ths - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), liftPercent100thsValue)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR WindowCoveringCluster::GoToLiftValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t liftValue) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, WindowCovering::Commands::GoToLiftValue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // liftValue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), liftValue)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR WindowCoveringCluster::GoToTiltPercentage(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::Percent tiltPercentageValue, - chip::Percent100ths tiltPercent100thsValue) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, WindowCovering::Commands::GoToTiltPercentage::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // tiltPercentageValue: percent - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), tiltPercentageValue)); - // tiltPercent100thsValue: percent100ths - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), tiltPercent100thsValue)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR WindowCoveringCluster::GoToTiltValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t tiltValue) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, WindowCovering::Commands::GoToTiltValue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // tiltValue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), tiltValue)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR WindowCoveringCluster::StopMotion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, WindowCovering::Commands::StopMotion::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR WindowCoveringCluster::UpOrOpen(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, WindowCovering::Commands::UpOrOpen::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h index accde31fb79fe9..ae1737b2edca92 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h @@ -42,13 +42,6 @@ class DLL_EXPORT AccountLoginCluster : public ClusterBase public: AccountLoginCluster() : ClusterBase(app::Clusters::AccountLogin::Id) {} ~AccountLoginCluster() {} - - // Cluster Commands - CHIP_ERROR GetSetupPINRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan tempAccountIdentifier); - CHIP_ERROR LoginRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan tempAccountIdentifier, chip::CharSpan setupPIN); - CHIP_ERROR LogoutRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT AdministratorCommissioningCluster : public ClusterBase @@ -56,14 +49,6 @@ class DLL_EXPORT AdministratorCommissioningCluster : public ClusterBase public: AdministratorCommissioningCluster() : ClusterBase(app::Clusters::AdministratorCommissioning::Id) {} ~AdministratorCommissioningCluster() {} - - // Cluster Commands - CHIP_ERROR OpenBasicCommissioningWindow(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t commissioningTimeout); - CHIP_ERROR OpenCommissioningWindow(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t commissioningTimeout, chip::ByteSpan PAKEVerifier, uint16_t discriminator, - uint32_t iterations, chip::ByteSpan salt, uint16_t passcodeID); - CHIP_ERROR RevokeCommissioning(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT ApplicationBasicCluster : public ClusterBase @@ -78,14 +63,6 @@ class DLL_EXPORT ApplicationLauncherCluster : public ClusterBase public: ApplicationLauncherCluster() : ClusterBase(app::Clusters::ApplicationLauncher::Id) {} ~ApplicationLauncherCluster() {} - - // Cluster Commands - CHIP_ERROR HideAppRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t catalogVendorId, chip::CharSpan applicationId); - CHIP_ERROR LaunchAppRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan data, uint16_t catalogVendorId, chip::CharSpan applicationId); - CHIP_ERROR StopAppRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t catalogVendorId, chip::CharSpan applicationId); }; class DLL_EXPORT AudioOutputCluster : public ClusterBase @@ -93,12 +70,6 @@ class DLL_EXPORT AudioOutputCluster : public ClusterBase public: AudioOutputCluster() : ClusterBase(app::Clusters::AudioOutput::Id) {} ~AudioOutputCluster() {} - - // Cluster Commands - CHIP_ERROR RenameOutputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t index, chip::CharSpan name); - CHIP_ERROR SelectOutputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t index); }; class DLL_EXPORT BarrierControlCluster : public ClusterBase @@ -106,11 +77,6 @@ class DLL_EXPORT BarrierControlCluster : public ClusterBase public: BarrierControlCluster() : ClusterBase(app::Clusters::BarrierControl::Id) {} ~BarrierControlCluster() {} - - // Cluster Commands - CHIP_ERROR BarrierControlGoToPercent(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t percentOpen); - CHIP_ERROR BarrierControlStop(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT BasicCluster : public ClusterBase @@ -132,12 +98,6 @@ class DLL_EXPORT BindingCluster : public ClusterBase public: BindingCluster() : ClusterBase(app::Clusters::Binding::Id) {} ~BindingCluster() {} - - // Cluster Commands - CHIP_ERROR Bind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::NodeId nodeId, - chip::GroupId groupId, chip::EndpointId endpointId, chip::ClusterId clusterId); - CHIP_ERROR Unbind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::NodeId nodeId, - chip::GroupId groupId, chip::EndpointId endpointId, chip::ClusterId clusterId); }; class DLL_EXPORT BooleanStateCluster : public ClusterBase @@ -152,32 +112,6 @@ class DLL_EXPORT BridgedActionsCluster : public ClusterBase public: BridgedActionsCluster() : ClusterBase(app::Clusters::BridgedActions::Id) {} ~BridgedActionsCluster() {} - - // Cluster Commands - CHIP_ERROR DisableAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID); - CHIP_ERROR DisableActionWithDuration(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID, uint32_t duration); - CHIP_ERROR EnableAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID); - CHIP_ERROR EnableActionWithDuration(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID, uint32_t duration); - CHIP_ERROR InstantAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID); - CHIP_ERROR InstantActionWithTransition(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID, uint16_t transitionTime); - CHIP_ERROR PauseAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID); - CHIP_ERROR PauseActionWithDuration(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID, uint32_t duration); - CHIP_ERROR ResumeAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID); - CHIP_ERROR StartAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID); - CHIP_ERROR StartActionWithDuration(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t actionID, uint32_t invokeID, uint32_t duration); - CHIP_ERROR StopAction(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t actionID, - uint32_t invokeID); }; class DLL_EXPORT BridgedDeviceBasicCluster : public ClusterBase @@ -192,14 +126,6 @@ class DLL_EXPORT ChannelCluster : public ClusterBase public: ChannelCluster() : ClusterBase(app::Clusters::Channel::Id) {} ~ChannelCluster() {} - - // Cluster Commands - CHIP_ERROR ChangeChannelByNumberRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t majorNumber, uint16_t minorNumber); - CHIP_ERROR ChangeChannelRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan match); - CHIP_ERROR SkipChannelRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t count); }; class DLL_EXPORT ColorControlCluster : public ClusterBase @@ -207,53 +133,6 @@ class DLL_EXPORT ColorControlCluster : public ClusterBase public: ColorControlCluster() : ClusterBase(app::Clusters::ColorControl::Id) {} ~ColorControlCluster() {} - - // Cluster Commands - CHIP_ERROR ColorLoopSet(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t updateFlags, - uint8_t action, uint8_t direction, uint16_t time, uint16_t startHue, uint8_t optionsMask, - uint8_t optionsOverride); - CHIP_ERROR EnhancedMoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR EnhancedMoveToHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t enhancedHue, uint8_t direction, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride); - CHIP_ERROR EnhancedMoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t enhancedHue, uint8_t saturation, uint16_t transitionTime, - uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR EnhancedStepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, int16_t rateX, - int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveColorTemperature(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint16_t rate, uint16_t colorTemperatureMinimum, - uint16_t colorTemperatureMaximum, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveToColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t colorX, - uint16_t colorY, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveToColorTemperature(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t colorTemperature, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride); - CHIP_ERROR MoveToHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t hue, - uint8_t direction, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t hue, uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride); - CHIP_ERROR MoveToSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR StepColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, int16_t stepX, - int16_t stepY, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR StepColorTemperature(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime, uint16_t colorTemperatureMinimum, - uint16_t colorTemperatureMaximum, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR StepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR StepSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR StopMoveStep(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t optionsMask, - uint8_t optionsOverride); }; class DLL_EXPORT ContentLauncherCluster : public ClusterBase @@ -261,12 +140,6 @@ class DLL_EXPORT ContentLauncherCluster : public ClusterBase public: ContentLauncherCluster() : ClusterBase(app::Clusters::ContentLauncher::Id) {} ~ContentLauncherCluster() {} - - // Cluster Commands - CHIP_ERROR LaunchContentRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - bool autoPlay, chip::CharSpan data); - CHIP_ERROR LaunchURLRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan contentURL, chip::CharSpan displayString, chip::CharSpan providerName); }; class DLL_EXPORT DescriptorCluster : public ClusterBase @@ -281,10 +154,6 @@ class DLL_EXPORT DiagnosticLogsCluster : public ClusterBase public: DiagnosticLogsCluster() : ClusterBase(app::Clusters::DiagnosticLogs::Id) {} ~DiagnosticLogsCluster() {} - - // Cluster Commands - CHIP_ERROR RetrieveLogsRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t intent, uint8_t requestedProtocol, chip::ByteSpan transferFileDesignator); }; class DLL_EXPORT DoorLockCluster : public ClusterBase @@ -292,38 +161,6 @@ class DLL_EXPORT DoorLockCluster : public ClusterBase public: DoorLockCluster() : ClusterBase(app::Clusters::DoorLock::Id) {} ~DoorLockCluster() {} - - // Cluster Commands - CHIP_ERROR ClearCredential(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t credentialType, uint16_t credentialIndex); - CHIP_ERROR ClearUser(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t userIndex); - CHIP_ERROR ClearWeekDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t weekDayIndex, uint16_t userIndex); - CHIP_ERROR ClearYearDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t yearDayIndex, uint16_t userIndex); - CHIP_ERROR GetCredentialStatus(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t credentialType, uint16_t credentialIndex); - CHIP_ERROR GetUser(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t userIndex); - CHIP_ERROR GetWeekDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t weekDayIndex, uint16_t userIndex); - CHIP_ERROR GetYearDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t yearDayIndex, uint16_t userIndex); - CHIP_ERROR LockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::ByteSpan pinCode); - CHIP_ERROR SetCredential(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t operationType, uint8_t credentialType, uint16_t credentialIndex, chip::ByteSpan credentialData, - uint16_t userIndex, uint8_t userStatus, uint8_t userType); - CHIP_ERROR SetUser(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t operationType, - uint16_t userIndex, chip::CharSpan userName, uint32_t userUniqueId, uint8_t userStatus, uint8_t userType, - uint8_t credentialRule); - CHIP_ERROR SetWeekDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t weekDayIndex, uint16_t userIndex, uint8_t daysMask, uint8_t startHour, - uint8_t startMinute, uint8_t endHour, uint8_t endMinute); - CHIP_ERROR SetYearDaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t yearDayIndex, uint16_t userIndex, uint32_t localStartTime, uint32_t localEndTime); - CHIP_ERROR UnlockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan pinCode); - CHIP_ERROR UnlockWithTimeout(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t timeout, chip::ByteSpan pinCode); }; class DLL_EXPORT ElectricalMeasurementCluster : public ClusterBase @@ -338,9 +175,6 @@ class DLL_EXPORT EthernetNetworkDiagnosticsCluster : public ClusterBase public: EthernetNetworkDiagnosticsCluster() : ClusterBase(app::Clusters::EthernetNetworkDiagnostics::Id) {} ~EthernetNetworkDiagnosticsCluster() {} - - // Cluster Commands - CHIP_ERROR ResetCounts(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT FixedLabelCluster : public ClusterBase @@ -362,13 +196,6 @@ class DLL_EXPORT GeneralCommissioningCluster : public ClusterBase public: GeneralCommissioningCluster() : ClusterBase(app::Clusters::GeneralCommissioning::Id) {} ~GeneralCommissioningCluster() {} - - // Cluster Commands - CHIP_ERROR ArmFailSafe(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t expiryLengthSeconds, uint64_t breadcrumb, uint32_t timeoutMs); - CHIP_ERROR CommissioningComplete(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR SetRegulatoryConfig(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t location, chip::CharSpan countryCode, uint64_t breadcrumb, uint32_t timeoutMs); }; class DLL_EXPORT GeneralDiagnosticsCluster : public ClusterBase @@ -383,17 +210,6 @@ class DLL_EXPORT GroupKeyManagementCluster : public ClusterBase public: GroupKeyManagementCluster() : ClusterBase(app::Clusters::GroupKeyManagement::Id) {} ~GroupKeyManagementCluster() {} - - // Cluster Commands - CHIP_ERROR KeySetRead(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupKeySetID); - CHIP_ERROR KeySetReadAllIndices(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupKeySetIDs); - CHIP_ERROR KeySetRemove(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupKeySetID); - CHIP_ERROR KeySetWrite(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupKeySetID, uint8_t securityPolicy, chip::ByteSpan epochKey0, uint64_t epochStartTime0, - chip::ByteSpan epochKey1, uint64_t epochStartTime1, chip::ByteSpan epochKey2, uint64_t epochStartTime2); }; class DLL_EXPORT GroupsCluster : public ClusterBase @@ -401,17 +217,6 @@ class DLL_EXPORT GroupsCluster : public ClusterBase public: GroupsCluster() : ClusterBase(app::Clusters::Groups::Id) {} ~GroupsCluster() {} - - // Cluster Commands - CHIP_ERROR AddGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId, - chip::CharSpan groupName); - CHIP_ERROR AddGroupIfIdentifying(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, chip::CharSpan groupName); - CHIP_ERROR GetGroupMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupList); - CHIP_ERROR RemoveAllGroups(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR RemoveGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId); - CHIP_ERROR ViewGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId); }; class DLL_EXPORT IdentifyCluster : public ClusterBase @@ -419,12 +224,6 @@ class DLL_EXPORT IdentifyCluster : public ClusterBase public: IdentifyCluster() : ClusterBase(app::Clusters::Identify::Id) {} ~IdentifyCluster() {} - - // Cluster Commands - CHIP_ERROR Identify(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t identifyTime); - CHIP_ERROR IdentifyQuery(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR TriggerEffect(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t effectIdentifier, uint8_t effectVariant); }; class DLL_EXPORT IlluminanceMeasurementCluster : public ClusterBase @@ -439,9 +238,6 @@ class DLL_EXPORT KeypadInputCluster : public ClusterBase public: KeypadInputCluster() : ClusterBase(app::Clusters::KeypadInput::Id) {} ~KeypadInputCluster() {} - - // Cluster Commands - CHIP_ERROR SendKeyRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t keyCode); }; class DLL_EXPORT LevelControlCluster : public ClusterBase @@ -449,23 +245,6 @@ class DLL_EXPORT LevelControlCluster : public ClusterBase public: LevelControlCluster() : ClusterBase(app::Clusters::LevelControl::Id) {} ~LevelControlCluster() {} - - // Cluster Commands - CHIP_ERROR Move(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint8_t rate, uint8_t optionMask, uint8_t optionOverride); - CHIP_ERROR MoveToLevel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t level, - uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride); - CHIP_ERROR MoveToLevelWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t level, uint16_t transitionTime); - CHIP_ERROR MoveWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint8_t rate); - CHIP_ERROR Step(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint8_t stepSize, uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride); - CHIP_ERROR StepWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint8_t stepSize, uint16_t transitionTime); - CHIP_ERROR Stop(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t optionMask, - uint8_t optionOverride); - CHIP_ERROR StopWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT LocalizationConfigurationCluster : public ClusterBase @@ -480,9 +259,6 @@ class DLL_EXPORT LowPowerCluster : public ClusterBase public: LowPowerCluster() : ClusterBase(app::Clusters::LowPower::Id) {} ~LowPowerCluster() {} - - // Cluster Commands - CHIP_ERROR Sleep(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT MediaInputCluster : public ClusterBase @@ -490,14 +266,6 @@ class DLL_EXPORT MediaInputCluster : public ClusterBase public: MediaInputCluster() : ClusterBase(app::Clusters::MediaInput::Id) {} ~MediaInputCluster() {} - - // Cluster Commands - CHIP_ERROR HideInputStatusRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR RenameInputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t index, - chip::CharSpan name); - CHIP_ERROR SelectInputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t index); - CHIP_ERROR ShowInputStatusRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT MediaPlaybackCluster : public ClusterBase @@ -505,21 +273,6 @@ class DLL_EXPORT MediaPlaybackCluster : public ClusterBase public: MediaPlaybackCluster() : ClusterBase(app::Clusters::MediaPlayback::Id) {} ~MediaPlaybackCluster() {} - - // Cluster Commands - CHIP_ERROR FastForwardRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR NextRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR PauseRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR PlayRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR PreviousRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR RewindRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR SeekRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint64_t position); - CHIP_ERROR SkipBackwardRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint64_t deltaPositionMilliseconds); - CHIP_ERROR SkipForwardRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint64_t deltaPositionMilliseconds); - CHIP_ERROR StartOverRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR StopRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT ModeSelectCluster : public ClusterBase @@ -527,9 +280,6 @@ class DLL_EXPORT ModeSelectCluster : public ClusterBase public: ModeSelectCluster() : ClusterBase(app::Clusters::ModeSelect::Id) {} ~ModeSelectCluster() {} - - // Cluster Commands - CHIP_ERROR ChangeToMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t newMode); }; class DLL_EXPORT NetworkCommissioningCluster : public ClusterBase @@ -537,20 +287,6 @@ class DLL_EXPORT NetworkCommissioningCluster : public ClusterBase public: NetworkCommissioningCluster() : ClusterBase(app::Clusters::NetworkCommissioning::Id) {} ~NetworkCommissioningCluster() {} - - // Cluster Commands - CHIP_ERROR AddOrUpdateThreadNetwork(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan operationalDataset, uint64_t breadcrumb); - CHIP_ERROR AddOrUpdateWiFiNetwork(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan ssid, chip::ByteSpan credentials, uint64_t breadcrumb); - CHIP_ERROR ConnectNetwork(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan networkID, uint64_t breadcrumb); - CHIP_ERROR RemoveNetwork(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan networkID, uint64_t breadcrumb); - CHIP_ERROR ReorderNetwork(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan networkID, uint8_t networkIndex, uint64_t breadcrumb); - CHIP_ERROR ScanNetworks(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid, - uint64_t breadcrumb); }; class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase @@ -558,16 +294,6 @@ class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase public: OtaSoftwareUpdateProviderCluster() : ClusterBase(app::Clusters::OtaSoftwareUpdateProvider::Id) {} ~OtaSoftwareUpdateProviderCluster() {} - - // Cluster Commands - CHIP_ERROR ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion); - CHIP_ERROR NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion); - CHIP_ERROR QueryImage(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::VendorId vendorId, uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider); }; class DLL_EXPORT OtaSoftwareUpdateRequestorCluster : public ClusterBase @@ -575,11 +301,6 @@ class DLL_EXPORT OtaSoftwareUpdateRequestorCluster : public ClusterBase public: OtaSoftwareUpdateRequestorCluster() : ClusterBase(app::Clusters::OtaSoftwareUpdateRequestor::Id) {} ~OtaSoftwareUpdateRequestorCluster() {} - - // Cluster Commands - CHIP_ERROR AnnounceOtaProvider(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::NodeId providerNodeId, chip::VendorId vendorId, uint8_t announcementReason, - chip::ByteSpan metadataForNode, chip::EndpointId endpoint); }; class DLL_EXPORT OccupancySensingCluster : public ClusterBase @@ -594,16 +315,6 @@ class DLL_EXPORT OnOffCluster : public ClusterBase public: OnOffCluster() : ClusterBase(app::Clusters::OnOff::Id) {} ~OnOffCluster() {} - - // Cluster Commands - CHIP_ERROR Off(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR OffWithEffect(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t effectId, - uint8_t effectVariant); - CHIP_ERROR On(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR OnWithRecallGlobalScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR OnWithTimedOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t onOffControl, uint16_t onTime, uint16_t offWaitTime); - CHIP_ERROR Toggle(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT OnOffSwitchConfigurationCluster : public ClusterBase @@ -618,26 +329,6 @@ class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase public: OperationalCredentialsCluster() : ClusterBase(app::Clusters::OperationalCredentials::Id) {} ~OperationalCredentialsCluster() {} - - // Cluster Commands - CHIP_ERROR AddNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::ByteSpan NOCValue, - chip::ByteSpan ICACValue, chip::ByteSpan IPKValue, chip::NodeId caseAdminNode, uint16_t adminVendorId); - CHIP_ERROR AddTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan rootCertificate); - CHIP_ERROR AttestationRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan attestationNonce); - CHIP_ERROR CertificateChainRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t certificateType); - CHIP_ERROR OpCSRRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan CSRNonce); - CHIP_ERROR RemoveFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t fabricIndex); - CHIP_ERROR RemoveTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan trustedRootIdentifier); - CHIP_ERROR UpdateFabricLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan label); - CHIP_ERROR UpdateNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan NOCValue, chip::ByteSpan ICACValue); }; class DLL_EXPORT PowerSourceCluster : public ClusterBase @@ -680,23 +371,6 @@ class DLL_EXPORT ScenesCluster : public ClusterBase public: ScenesCluster() : ClusterBase(app::Clusters::Scenes::Id) {} ~ScenesCluster() {} - - // Cluster Commands - CHIP_ERROR AddScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId, - uint8_t sceneId, uint16_t transitionTime, chip::CharSpan sceneName, chip::ClusterId clusterId, - uint8_t length, uint8_t value); - CHIP_ERROR GetSceneMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId); - CHIP_ERROR RecallScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId, - uint8_t sceneId, uint16_t transitionTime); - CHIP_ERROR RemoveAllScenes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId); - CHIP_ERROR RemoveScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId, - uint8_t sceneId); - CHIP_ERROR StoreScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId, - uint8_t sceneId); - CHIP_ERROR ViewScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId, - uint8_t sceneId); }; class DLL_EXPORT SoftwareDiagnosticsCluster : public ClusterBase @@ -704,9 +378,6 @@ class DLL_EXPORT SoftwareDiagnosticsCluster : public ClusterBase public: SoftwareDiagnosticsCluster() : ClusterBase(app::Clusters::SoftwareDiagnostics::Id) {} ~SoftwareDiagnosticsCluster() {} - - // Cluster Commands - CHIP_ERROR ResetWatermarks(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT SwitchCluster : public ClusterBase @@ -721,10 +392,6 @@ class DLL_EXPORT TargetNavigatorCluster : public ClusterBase public: TargetNavigatorCluster() : ClusterBase(app::Clusters::TargetNavigator::Id) {} ~TargetNavigatorCluster() {} - - // Cluster Commands - CHIP_ERROR NavigateTargetRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t target, chip::CharSpan data); }; class DLL_EXPORT TemperatureMeasurementCluster : public ClusterBase @@ -739,44 +406,6 @@ class DLL_EXPORT TestClusterCluster : public ClusterBase public: TestClusterCluster() : ClusterBase(app::Clusters::TestCluster::Id) {} ~TestClusterCluster() {} - - // Cluster Commands - CHIP_ERROR SimpleStructEchoRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t a, bool b, uint8_t c, chip::ByteSpan d, chip::CharSpan e, uint8_t f, float g, - double h); - CHIP_ERROR Test(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR TestAddArguments(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t arg1, - uint8_t arg2); - CHIP_ERROR TestEmitTestEventRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t arg1, uint8_t arg2, bool arg3); - CHIP_ERROR TestEnumsRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::VendorId arg1, uint8_t arg2); - CHIP_ERROR TestListInt8UArgumentRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t arg1); - CHIP_ERROR TestListInt8UReverseRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t arg1); - CHIP_ERROR TestListNestedStructListArgumentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t a, bool b, uint32_t e, - chip::ByteSpan f, uint8_t g); - CHIP_ERROR TestListStructArgumentRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t a, bool b, uint8_t c, chip::ByteSpan d, chip::CharSpan e, uint8_t f, float g, - double h); - CHIP_ERROR TestNestedStructArgumentRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t a, bool b); - CHIP_ERROR TestNestedStructListArgumentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t a, bool b, uint32_t e, - chip::ByteSpan f, uint8_t g); - CHIP_ERROR TestNotHandled(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR TestNullableOptionalRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t arg1); - CHIP_ERROR TestSimpleOptionalArgumentRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - bool arg1); - CHIP_ERROR TestSpecific(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR TestStructArgumentRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t a, bool b, uint8_t c, chip::ByteSpan d, chip::CharSpan e, uint8_t f, float g, - double h); - CHIP_ERROR TestUnknownCommand(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR TimedInvokeRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT ThermostatCluster : public ClusterBase @@ -784,17 +413,6 @@ class DLL_EXPORT ThermostatCluster : public ClusterBase public: ThermostatCluster() : ClusterBase(app::Clusters::Thermostat::Id) {} ~ThermostatCluster() {} - - // Cluster Commands - CHIP_ERROR ClearWeeklySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR GetRelayStatusLog(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR GetWeeklySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t daysToReturn, uint8_t modeToReturn); - CHIP_ERROR SetWeeklySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t numberOfTransitionsForSequence, uint8_t dayOfWeekForSequence, uint8_t modeForSequence, - uint8_t payload); - CHIP_ERROR SetpointRaiseLower(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t mode, - int8_t amount); }; class DLL_EXPORT ThermostatUserInterfaceConfigurationCluster : public ClusterBase @@ -809,9 +427,6 @@ class DLL_EXPORT ThreadNetworkDiagnosticsCluster : public ClusterBase public: ThreadNetworkDiagnosticsCluster() : ClusterBase(app::Clusters::ThreadNetworkDiagnostics::Id) {} ~ThreadNetworkDiagnosticsCluster() {} - - // Cluster Commands - CHIP_ERROR ResetCounts(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT TimeFormatLocalizationCluster : public ClusterBase @@ -847,9 +462,6 @@ class DLL_EXPORT WiFiNetworkDiagnosticsCluster : public ClusterBase public: WiFiNetworkDiagnosticsCluster() : ClusterBase(app::Clusters::WiFiNetworkDiagnostics::Id) {} ~WiFiNetworkDiagnosticsCluster() {} - - // Cluster Commands - CHIP_ERROR ResetCounts(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT WindowCoveringCluster : public ClusterBase @@ -857,19 +469,6 @@ class DLL_EXPORT WindowCoveringCluster : public ClusterBase public: WindowCoveringCluster() : ClusterBase(app::Clusters::WindowCovering::Id) {} ~WindowCoveringCluster() {} - - // Cluster Commands - CHIP_ERROR DownOrClose(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR GoToLiftPercentage(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::Percent liftPercentageValue, chip::Percent100ths liftPercent100thsValue); - CHIP_ERROR GoToLiftValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t liftValue); - CHIP_ERROR GoToTiltPercentage(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::Percent tiltPercentageValue, chip::Percent100ths tiltPercent100thsValue); - CHIP_ERROR GoToTiltValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t tiltValue); - CHIP_ERROR StopMotion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR UpOrOpen(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; } // namespace Controller diff --git a/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp index 413c7604c68b63..dbcfc737576d37 100644 --- a/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp @@ -41,3910 +41,6 @@ namespace app { namespace Clusters { -namespace AccountLogin { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::GetSetupPINResponse::Id: { - expectArgumentCount = 1; - chip::CharSpan setupPIN; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(setupPIN); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = - emberAfAccountLoginClusterGetSetupPINResponseCallback(aCommandPath.mEndpointId, apCommandObj, setupPIN); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace AccountLogin - -namespace ApplicationLauncher { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::LauncherResponse::Id: { - expectArgumentCount = 2; - uint8_t status; - chip::CharSpan data; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(data); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = - emberAfApplicationLauncherClusterLauncherResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, data); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace ApplicationLauncher - -namespace Channel { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::ChangeChannelResponse::Id: { - expectArgumentCount = 2; - chip::app::Clusters::Channel::Structs::ChannelInfo::DecodableType channelMatch; - uint8_t errorType; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - // Not supported, just error out. - TLVUnpackError = CHIP_ERROR_UNEXPECTED_TLV_ELEMENT; - break; - case 1: - TLVUnpackError = aDataTlv.Get(errorType); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfChannelClusterChangeChannelResponseCallback(aCommandPath.mEndpointId, apCommandObj, - channelMatch, errorType); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace Channel - -namespace ContentLauncher { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::LaunchResponse::Id: { - expectArgumentCount = 2; - uint8_t status; - chip::CharSpan data; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(data); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = - emberAfContentLauncherClusterLaunchResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, data); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace ContentLauncher - -namespace DiagnosticLogs { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::RetrieveLogsResponse::Id: { - expectArgumentCount = 4; - uint8_t status; - chip::ByteSpan content; - uint32_t timeStamp; - uint32_t timeSinceBoot; - bool argExists[4]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 4) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(content); - break; - case 2: - TLVUnpackError = aDataTlv.Get(timeStamp); - break; - case 3: - TLVUnpackError = aDataTlv.Get(timeSinceBoot); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) - { - wasHandled = emberAfDiagnosticLogsClusterRetrieveLogsResponseCallback(aCommandPath.mEndpointId, apCommandObj, - status, content, timeStamp, timeSinceBoot); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace DiagnosticLogs - -namespace DoorLock { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::GetCredentialStatusResponse::Id: { - expectArgumentCount = 3; - bool credentialExists; - uint16_t userIndex; - uint16_t nextCredentialIndex; - bool argExists[3]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(credentialExists); - break; - case 1: - TLVUnpackError = aDataTlv.Get(userIndex); - break; - case 2: - TLVUnpackError = aDataTlv.Get(nextCredentialIndex); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) - { - wasHandled = emberAfDoorLockClusterGetCredentialStatusResponseCallback( - aCommandPath.mEndpointId, apCommandObj, credentialExists, userIndex, nextCredentialIndex); - } - break; - } - case Commands::GetUserResponse::Id: { - expectArgumentCount = 10; - uint16_t userIndex; - chip::CharSpan userName; - uint32_t userUniqueId; - uint8_t userStatus; - uint8_t userType; - uint8_t credentialRule; - /* TYPE WARNING: array array defaults to */ uint8_t * credentials; - chip::FabricIndex creatorFabricIndex; - chip::FabricIndex lastModifiedFabricIndex; - uint16_t nextUserIndex; - bool argExists[10]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 10) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(userIndex); - break; - case 1: - TLVUnpackError = aDataTlv.Get(userName); - break; - case 2: - TLVUnpackError = aDataTlv.Get(userUniqueId); - break; - case 3: - TLVUnpackError = aDataTlv.Get(userStatus); - break; - case 4: - TLVUnpackError = aDataTlv.Get(userType); - break; - case 5: - TLVUnpackError = aDataTlv.Get(credentialRule); - break; - case 6: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(credentials)); - break; - case 7: - TLVUnpackError = aDataTlv.Get(creatorFabricIndex); - break; - case 8: - TLVUnpackError = aDataTlv.Get(lastModifiedFabricIndex); - break; - case 9: - TLVUnpackError = aDataTlv.Get(nextUserIndex); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 10 == validArgumentCount) - { - wasHandled = emberAfDoorLockClusterGetUserResponseCallback( - aCommandPath.mEndpointId, apCommandObj, userIndex, userName, userUniqueId, userStatus, userType, credentialRule, - credentials, creatorFabricIndex, lastModifiedFabricIndex, nextUserIndex); - } - break; - } - case Commands::GetWeekDayScheduleResponse::Id: { - expectArgumentCount = 8; - uint8_t weekDayIndex; - uint16_t userIndex; - uint8_t status; - uint8_t daysMask; - uint8_t startHour; - uint8_t startMinute; - uint8_t endHour; - uint8_t endMinute; - bool argExists[8]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 8) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(weekDayIndex); - break; - case 1: - TLVUnpackError = aDataTlv.Get(userIndex); - break; - case 2: - TLVUnpackError = aDataTlv.Get(status); - break; - case 3: - TLVUnpackError = aDataTlv.Get(daysMask); - break; - case 4: - TLVUnpackError = aDataTlv.Get(startHour); - break; - case 5: - TLVUnpackError = aDataTlv.Get(startMinute); - break; - case 6: - TLVUnpackError = aDataTlv.Get(endHour); - break; - case 7: - TLVUnpackError = aDataTlv.Get(endMinute); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 8 == validArgumentCount) - { - wasHandled = emberAfDoorLockClusterGetWeekDayScheduleResponseCallback(aCommandPath.mEndpointId, apCommandObj, - weekDayIndex, userIndex, status, daysMask, - startHour, startMinute, endHour, endMinute); - } - break; - } - case Commands::GetYearDayScheduleResponse::Id: { - expectArgumentCount = 5; - uint8_t yearDayIndex; - uint16_t userIndex; - uint8_t status; - uint32_t localStartTime; - uint32_t localEndTime; - bool argExists[5]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 5) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(yearDayIndex); - break; - case 1: - TLVUnpackError = aDataTlv.Get(userIndex); - break; - case 2: - TLVUnpackError = aDataTlv.Get(status); - break; - case 3: - TLVUnpackError = aDataTlv.Get(localStartTime); - break; - case 4: - TLVUnpackError = aDataTlv.Get(localEndTime); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) - { - wasHandled = emberAfDoorLockClusterGetYearDayScheduleResponseCallback( - aCommandPath.mEndpointId, apCommandObj, yearDayIndex, userIndex, status, localStartTime, localEndTime); - } - break; - } - case Commands::SetCredentialResponse::Id: { - expectArgumentCount = 3; - uint8_t status; - uint16_t userIndex; - uint16_t nextCredentialIndex; - bool argExists[3]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(userIndex); - break; - case 2: - TLVUnpackError = aDataTlv.Get(nextCredentialIndex); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) - { - wasHandled = emberAfDoorLockClusterSetCredentialResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, - userIndex, nextCredentialIndex); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace DoorLock - -namespace GeneralCommissioning { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::ArmFailSafeResponse::Id: { - expectArgumentCount = 2; - uint8_t errorCode; - chip::CharSpan debugText; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - TLVUnpackError = aDataTlv.Get(debugText); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfGeneralCommissioningClusterArmFailSafeResponseCallback(aCommandPath.mEndpointId, apCommandObj, - errorCode, debugText); - } - break; - } - case Commands::CommissioningCompleteResponse::Id: { - expectArgumentCount = 2; - uint8_t errorCode; - chip::CharSpan debugText; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - TLVUnpackError = aDataTlv.Get(debugText); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfGeneralCommissioningClusterCommissioningCompleteResponseCallback( - aCommandPath.mEndpointId, apCommandObj, errorCode, debugText); - } - break; - } - case Commands::SetRegulatoryConfigResponse::Id: { - expectArgumentCount = 2; - uint8_t errorCode; - chip::CharSpan debugText; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - TLVUnpackError = aDataTlv.Get(debugText); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfGeneralCommissioningClusterSetRegulatoryConfigResponseCallback( - aCommandPath.mEndpointId, apCommandObj, errorCode, debugText); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace GeneralCommissioning - -namespace GroupKeyManagement { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::KeySetReadAllIndicesResponse::Id: { - expectArgumentCount = 1; - /* TYPE WARNING: array array defaults to */ uint8_t * groupKeySetIDs; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(groupKeySetIDs)); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = emberAfGroupKeyManagementClusterKeySetReadAllIndicesResponseCallback(aCommandPath.mEndpointId, - apCommandObj, groupKeySetIDs); - } - break; - } - case Commands::KeySetReadResponse::Id: { - expectArgumentCount = 1; - chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySet::DecodableType groupKeySet; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - // Not supported, just error out. - TLVUnpackError = CHIP_ERROR_UNEXPECTED_TLV_ELEMENT; - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = - emberAfGroupKeyManagementClusterKeySetReadResponseCallback(aCommandPath.mEndpointId, apCommandObj, groupKeySet); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace GroupKeyManagement - -namespace Groups { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::AddGroupResponse::Id: { - expectArgumentCount = 2; - uint8_t status; - uint16_t groupId; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(groupId); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfGroupsClusterAddGroupResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, groupId); - } - break; - } - case Commands::GetGroupMembershipResponse::Id: { - expectArgumentCount = 2; - uint8_t capacity; - /* TYPE WARNING: array array defaults to */ uint8_t * groupList; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(capacity); - break; - case 1: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(groupList)); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfGroupsClusterGetGroupMembershipResponseCallback(aCommandPath.mEndpointId, apCommandObj, - capacity, groupList); - } - break; - } - case Commands::RemoveGroupResponse::Id: { - expectArgumentCount = 2; - uint8_t status; - uint16_t groupId; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(groupId); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = - emberAfGroupsClusterRemoveGroupResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, groupId); - } - break; - } - case Commands::ViewGroupResponse::Id: { - expectArgumentCount = 3; - uint8_t status; - uint16_t groupId; - chip::CharSpan groupName; - bool argExists[3]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(groupId); - break; - case 2: - TLVUnpackError = aDataTlv.Get(groupName); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) - { - wasHandled = emberAfGroupsClusterViewGroupResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, groupId, - groupName); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace Groups - -namespace Identify { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::IdentifyQueryResponse::Id: { - expectArgumentCount = 1; - uint16_t timeout; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(timeout); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = emberAfIdentifyClusterIdentifyQueryResponseCallback(aCommandPath.mEndpointId, apCommandObj, timeout); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace Identify - -namespace KeypadInput { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::SendKeyResponse::Id: { - expectArgumentCount = 1; - uint8_t status; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = emberAfKeypadInputClusterSendKeyResponseCallback(aCommandPath.mEndpointId, apCommandObj, status); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace KeypadInput - -namespace MediaPlayback { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::PlaybackResponse::Id: { - expectArgumentCount = 1; - uint8_t status; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = emberAfMediaPlaybackClusterPlaybackResponseCallback(aCommandPath.mEndpointId, apCommandObj, status); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace MediaPlayback - -namespace NetworkCommissioning { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::ConnectNetworkResponse::Id: { - expectArgumentCount = 3; - uint8_t NetworkingStatus; - chip::CharSpan DebugText; - int32_t ErrorValue; - bool argExists[3]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(NetworkingStatus); - break; - case 1: - TLVUnpackError = aDataTlv.Get(DebugText); - break; - case 2: - TLVUnpackError = aDataTlv.Get(ErrorValue); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) - { - wasHandled = emberAfNetworkCommissioningClusterConnectNetworkResponseCallback( - aCommandPath.mEndpointId, apCommandObj, NetworkingStatus, DebugText, ErrorValue); - } - break; - } - case Commands::NetworkConfigResponse::Id: { - expectArgumentCount = 2; - uint8_t NetworkingStatus; - chip::CharSpan DebugText; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(NetworkingStatus); - break; - case 1: - TLVUnpackError = aDataTlv.Get(DebugText); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfNetworkCommissioningClusterNetworkConfigResponseCallback(aCommandPath.mEndpointId, apCommandObj, - NetworkingStatus, DebugText); - } - break; - } - case Commands::ScanNetworksResponse::Id: { - expectArgumentCount = 4; - uint8_t NetworkingStatus; - chip::CharSpan DebugText; - /* TYPE WARNING: array array defaults to */ uint8_t * WiFiScanResults; - /* TYPE WARNING: array array defaults to */ uint8_t * ThreadScanResults; - bool argExists[4]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 4) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(NetworkingStatus); - break; - case 1: - TLVUnpackError = aDataTlv.Get(DebugText); - break; - case 2: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(WiFiScanResults)); - break; - case 3: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(ThreadScanResults)); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) - { - wasHandled = emberAfNetworkCommissioningClusterScanNetworksResponseCallback( - aCommandPath.mEndpointId, apCommandObj, NetworkingStatus, DebugText, WiFiScanResults, ThreadScanResults); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace NetworkCommissioning - -namespace OtaSoftwareUpdateProvider { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::ApplyUpdateResponse::Id: { - expectArgumentCount = 2; - uint8_t action; - uint32_t delayedActionTime; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(action); - break; - case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback( - aCommandPath.mEndpointId, apCommandObj, action, delayedActionTime); - } - break; - } - case Commands::QueryImageResponse::Id: { - expectArgumentCount = 8; - uint8_t status; - uint32_t delayedActionTime; - chip::CharSpan imageURI; - uint32_t softwareVersion; - chip::CharSpan softwareVersionString; - chip::ByteSpan updateToken; - bool userConsentNeeded; - chip::ByteSpan metadataForRequestor; - bool argExists[8]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 8) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); - break; - case 2: - TLVUnpackError = aDataTlv.Get(imageURI); - break; - case 3: - TLVUnpackError = aDataTlv.Get(softwareVersion); - break; - case 4: - TLVUnpackError = aDataTlv.Get(softwareVersionString); - break; - case 5: - TLVUnpackError = aDataTlv.Get(updateToken); - break; - case 6: - TLVUnpackError = aDataTlv.Get(userConsentNeeded); - break; - case 7: - TLVUnpackError = aDataTlv.Get(metadataForRequestor); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 8 == validArgumentCount) - { - wasHandled = emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback( - aCommandPath.mEndpointId, apCommandObj, status, delayedActionTime, imageURI, softwareVersion, - softwareVersionString, updateToken, userConsentNeeded, metadataForRequestor); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace OtaSoftwareUpdateProvider - -namespace OperationalCredentials { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::AttestationResponse::Id: { - expectArgumentCount = 2; - chip::ByteSpan AttestationElements; - chip::ByteSpan Signature; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(AttestationElements); - break; - case 1: - TLVUnpackError = aDataTlv.Get(Signature); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfOperationalCredentialsClusterAttestationResponseCallback(aCommandPath.mEndpointId, apCommandObj, - AttestationElements, Signature); - } - break; - } - case Commands::CertificateChainResponse::Id: { - expectArgumentCount = 1; - chip::ByteSpan Certificate; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(Certificate); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = emberAfOperationalCredentialsClusterCertificateChainResponseCallback(aCommandPath.mEndpointId, - apCommandObj, Certificate); - } - break; - } - case Commands::NOCResponse::Id: { - expectArgumentCount = 3; - uint8_t StatusCode; - uint8_t FabricIndex; - chip::CharSpan DebugText; - bool argExists[3]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(StatusCode); - break; - case 1: - TLVUnpackError = aDataTlv.Get(FabricIndex); - break; - case 2: - TLVUnpackError = aDataTlv.Get(DebugText); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) - { - wasHandled = emberAfOperationalCredentialsClusterNOCResponseCallback(aCommandPath.mEndpointId, apCommandObj, - StatusCode, FabricIndex, DebugText); - } - break; - } - case Commands::OpCSRResponse::Id: { - expectArgumentCount = 2; - chip::ByteSpan NOCSRElements; - chip::ByteSpan AttestationSignature; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(NOCSRElements); - break; - case 1: - TLVUnpackError = aDataTlv.Get(AttestationSignature); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfOperationalCredentialsClusterOpCSRResponseCallback(aCommandPath.mEndpointId, apCommandObj, - NOCSRElements, AttestationSignature); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace OperationalCredentials - -namespace Scenes { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::AddSceneResponse::Id: { - expectArgumentCount = 3; - uint8_t status; - uint16_t groupId; - uint8_t sceneId; - bool argExists[3]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(groupId); - break; - case 2: - TLVUnpackError = aDataTlv.Get(sceneId); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) - { - wasHandled = - emberAfScenesClusterAddSceneResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, groupId, sceneId); - } - break; - } - case Commands::GetSceneMembershipResponse::Id: { - expectArgumentCount = 5; - uint8_t status; - uint8_t capacity; - uint16_t groupId; - uint8_t sceneCount; - /* TYPE WARNING: array array defaults to */ uint8_t * sceneList; - bool argExists[5]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 5) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(capacity); - break; - case 2: - TLVUnpackError = aDataTlv.Get(groupId); - break; - case 3: - TLVUnpackError = aDataTlv.Get(sceneCount); - break; - case 4: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(sceneList)); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) - { - wasHandled = emberAfScenesClusterGetSceneMembershipResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, - capacity, groupId, sceneCount, sceneList); - } - break; - } - case Commands::RemoveAllScenesResponse::Id: { - expectArgumentCount = 2; - uint8_t status; - uint16_t groupId; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(groupId); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = - emberAfScenesClusterRemoveAllScenesResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, groupId); - } - break; - } - case Commands::RemoveSceneResponse::Id: { - expectArgumentCount = 3; - uint8_t status; - uint16_t groupId; - uint8_t sceneId; - bool argExists[3]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(groupId); - break; - case 2: - TLVUnpackError = aDataTlv.Get(sceneId); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) - { - wasHandled = emberAfScenesClusterRemoveSceneResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, - groupId, sceneId); - } - break; - } - case Commands::StoreSceneResponse::Id: { - expectArgumentCount = 3; - uint8_t status; - uint16_t groupId; - uint8_t sceneId; - bool argExists[3]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(groupId); - break; - case 2: - TLVUnpackError = aDataTlv.Get(sceneId); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) - { - wasHandled = emberAfScenesClusterStoreSceneResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, groupId, - sceneId); - } - break; - } - case Commands::ViewSceneResponse::Id: { - expectArgumentCount = 6; - uint8_t status; - uint16_t groupId; - uint8_t sceneId; - uint16_t transitionTime; - chip::CharSpan sceneName; - /* TYPE WARNING: array array defaults to */ uint8_t * extensionFieldSets; - bool argExists[6]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 6) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(groupId); - break; - case 2: - TLVUnpackError = aDataTlv.Get(sceneId); - break; - case 3: - TLVUnpackError = aDataTlv.Get(transitionTime); - break; - case 4: - TLVUnpackError = aDataTlv.Get(sceneName); - break; - case 5: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(extensionFieldSets)); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 6 == validArgumentCount) - { - wasHandled = emberAfScenesClusterViewSceneResponseCallback(aCommandPath.mEndpointId, apCommandObj, status, groupId, - sceneId, transitionTime, sceneName, extensionFieldSets); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace Scenes - -namespace TargetNavigator { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::NavigateTargetResponse::Id: { - expectArgumentCount = 2; - uint8_t status; - chip::CharSpan data; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(data); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfTargetNavigatorClusterNavigateTargetResponseCallback(aCommandPath.mEndpointId, apCommandObj, - status, data); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace TargetNavigator - -namespace TestCluster { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::BooleanResponse::Id: { - expectArgumentCount = 1; - bool value; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(value); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = emberAfTestClusterClusterBooleanResponseCallback(aCommandPath.mEndpointId, apCommandObj, value); - } - break; - } - case Commands::SimpleStructResponse::Id: { - expectArgumentCount = 1; - chip::app::Clusters::TestCluster::Structs::SimpleStruct::DecodableType arg1; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - // Not supported, just error out. - TLVUnpackError = CHIP_ERROR_UNEXPECTED_TLV_ELEMENT; - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = emberAfTestClusterClusterSimpleStructResponseCallback(aCommandPath.mEndpointId, apCommandObj, arg1); - } - break; - } - case Commands::TestAddArgumentsResponse::Id: { - expectArgumentCount = 1; - uint8_t returnValue; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(returnValue); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = - emberAfTestClusterClusterTestAddArgumentsResponseCallback(aCommandPath.mEndpointId, apCommandObj, returnValue); - } - break; - } - case Commands::TestEmitTestEventResponse::Id: { - expectArgumentCount = 1; - uint64_t value; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(value); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = - emberAfTestClusterClusterTestEmitTestEventResponseCallback(aCommandPath.mEndpointId, apCommandObj, value); - } - break; - } - case Commands::TestEnumsResponse::Id: { - expectArgumentCount = 2; - chip::VendorId arg1; - uint8_t arg2; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(arg1); - break; - case 1: - TLVUnpackError = aDataTlv.Get(arg2); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfTestClusterClusterTestEnumsResponseCallback(aCommandPath.mEndpointId, apCommandObj, arg1, arg2); - } - break; - } - case Commands::TestListInt8UReverseResponse::Id: { - expectArgumentCount = 1; - /* TYPE WARNING: array array defaults to */ uint8_t * arg1; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(arg1)); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = - emberAfTestClusterClusterTestListInt8UReverseResponseCallback(aCommandPath.mEndpointId, apCommandObj, arg1); - } - break; - } - case Commands::TestNullableOptionalResponse::Id: { - expectArgumentCount = 4; - bool wasPresent; - bool wasNull; - uint8_t value; - uint8_t originalValue; - bool argExists[4]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 4) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(wasPresent); - break; - case 1: - TLVUnpackError = aDataTlv.Get(wasNull); - break; - case 2: - TLVUnpackError = aDataTlv.Get(value); - break; - case 3: - TLVUnpackError = aDataTlv.Get(originalValue); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) - { - wasHandled = emberAfTestClusterClusterTestNullableOptionalResponseCallback( - aCommandPath.mEndpointId, apCommandObj, wasPresent, wasNull, value, originalValue); - } - break; - } - case Commands::TestSpecificResponse::Id: { - expectArgumentCount = 1; - uint8_t returnValue; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(returnValue); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = - emberAfTestClusterClusterTestSpecificResponseCallback(aCommandPath.mEndpointId, apCommandObj, returnValue); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace TestCluster - -namespace Thermostat { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::GetRelayStatusLogResponse::Id: { - expectArgumentCount = 6; - uint16_t timeOfDay; - uint16_t relayStatus; - int16_t localTemperature; - uint8_t humidityInPercentage; - int16_t setpoint; - uint16_t unreadEntries; - bool argExists[6]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 6) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(timeOfDay); - break; - case 1: - TLVUnpackError = aDataTlv.Get(relayStatus); - break; - case 2: - TLVUnpackError = aDataTlv.Get(localTemperature); - break; - case 3: - TLVUnpackError = aDataTlv.Get(humidityInPercentage); - break; - case 4: - TLVUnpackError = aDataTlv.Get(setpoint); - break; - case 5: - TLVUnpackError = aDataTlv.Get(unreadEntries); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 6 == validArgumentCount) - { - wasHandled = emberAfThermostatClusterGetRelayStatusLogResponseCallback( - aCommandPath.mEndpointId, apCommandObj, timeOfDay, relayStatus, localTemperature, humidityInPercentage, - setpoint, unreadEntries); - } - break; - } - case Commands::GetWeeklyScheduleResponse::Id: { - expectArgumentCount = 4; - uint8_t numberOfTransitionsForSequence; - uint8_t dayOfWeekForSequence; - uint8_t modeForSequence; - /* TYPE WARNING: array array defaults to */ uint8_t * payload; - bool argExists[4]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 4) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(numberOfTransitionsForSequence); - break; - case 1: - TLVUnpackError = aDataTlv.Get(dayOfWeekForSequence); - break; - case 2: - TLVUnpackError = aDataTlv.Get(modeForSequence); - break; - case 3: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(payload)); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) - { - wasHandled = emberAfThermostatClusterGetWeeklyScheduleResponseCallback( - aCommandPath.mEndpointId, apCommandObj, numberOfTransitionsForSequence, dayOfWeekForSequence, modeForSequence, - payload); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace Thermostat - } // namespace Clusters void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) @@ -3962,81 +58,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - case Clusters::AccountLogin::Id: - Clusters::AccountLogin::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::ApplicationLauncher::Id: - Clusters::ApplicationLauncher::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::Channel::Id: - Clusters::Channel::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::ContentLauncher::Id: - Clusters::ContentLauncher::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::DiagnosticLogs::Id: - Clusters::DiagnosticLogs::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::DoorLock::Id: - Clusters::DoorLock::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::GeneralCommissioning::Id: - Clusters::GeneralCommissioning::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::GroupKeyManagement::Id: - Clusters::GroupKeyManagement::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::Groups::Id: - Clusters::Groups::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::Identify::Id: - Clusters::Identify::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::KeypadInput::Id: - Clusters::KeypadInput::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::MediaPlayback::Id: - Clusters::MediaPlayback::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::NetworkCommissioning::Id: - Clusters::NetworkCommissioning::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::OtaSoftwareUpdateProvider::Id: - Clusters::OtaSoftwareUpdateProvider::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::OperationalCredentials::Id: - Clusters::OperationalCredentials::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::Scenes::Id: - Clusters::Scenes::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::TargetNavigator::Id: - Clusters::TargetNavigator::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::TestCluster::Id: - Clusters::TestCluster::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::Thermostat::Id: - Clusters::Thermostat::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/door-lock-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/door-lock-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/door-lock-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/door-lock-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/door-lock-app/zap-generated/CHIPClientCallbacks.h index 4ad6af42ab6e54..fbed9690c1f3da 100644 --- a/zzz_generated/door-lock-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/door-lock-app/zap-generated/CHIPClientCallbacks.h @@ -16,5 +16,3 @@ */ // THIS FILE IS GENERATED BY ZAP - -// List specific responses diff --git a/zzz_generated/door-lock-app/zap-generated/CHIPClusters.cpp b/zzz_generated/door-lock-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/door-lock-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/door-lock-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/door-lock-app/zap-generated/IMClusterCommandHandler.cpp index beccbfdc4cac3a..296a577ecb0c1e 100644 --- a/zzz_generated/door-lock-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/door-lock-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -163,10 +155,6 @@ namespace DoorLock { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -351,10 +339,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -411,10 +395,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -499,10 +479,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -647,24 +623,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 625230556c915c..00000000000000 --- a/zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -void GroupsClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void IdentifyClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OnOffClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ScenesClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -bool emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t action, uint32_t delayedActionTime) -{ - ChipLogProgress(Zcl, "ApplyUpdateResponse:"); - ChipLogProgress(Zcl, " action: %" PRIu8 "", action); - ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); - - GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, action, delayedActionTime); - return true; -} - -bool emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t status, uint32_t delayedActionTime, - chip::CharSpan imageURI, uint32_t softwareVersion, - chip::CharSpan softwareVersionString, - chip::ByteSpan updateToken, bool userConsentNeeded, - chip::ByteSpan metadataForRequestor) -{ - ChipLogProgress(Zcl, "QueryImageResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); - ChipLogProgress(Zcl, " imageURI: %.*s", static_cast(imageURI.size()), imageURI.data()); - ChipLogProgress(Zcl, " softwareVersion: %" PRIu32 "", softwareVersion); - ChipLogProgress(Zcl, " softwareVersionString: %.*s", static_cast(softwareVersionString.size()), - softwareVersionString.data()); - ChipLogProgress(Zcl, " updateToken: %zu", updateToken.size()); - ChipLogProgress(Zcl, " userConsentNeeded: %d", userConsentNeeded); - ChipLogProgress(Zcl, " metadataForRequestor: %zu", metadataForRequestor.size()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterQueryImageResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, delayedActionTime, imageURI, softwareVersion, softwareVersionString, updateToken, - userConsentNeeded, metadataForRequestor); - return true; -} diff --git a/zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.h index ac615ac541dd1e..4cb15e66e7f865 100644 --- a/zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/light-switch-app/zap-generated/CHIPClientCallbacks.h @@ -30,17 +30,6 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks -typedef void (*OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback)(void * context, uint8_t action, - uint32_t delayedActionTime); -typedef void (*OtaSoftwareUpdateProviderClusterQueryImageResponseCallback)( - void * context, uint8_t status, uint32_t delayedActionTime, chip::CharSpan imageURI, uint32_t softwareVersion, - chip::CharSpan softwareVersionString, chip::ByteSpan updateToken, bool userConsentNeeded, chip::ByteSpan metadataForRequestor); - // List specific responses void GroupsClusterAttributeListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, chip::Callback::Cancelable * onFailureCallback); diff --git a/zzz_generated/light-switch-app/zap-generated/CHIPClusters.cpp b/zzz_generated/light-switch-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index 92e3a41d9d826c..00000000000000 --- a/zzz_generated/light-switch-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,989 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// ColorControl Cluster Commands -CHIP_ERROR ColorControlCluster::ColorLoopSet(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t updateFlags, uint8_t action, uint8_t direction, uint16_t time, - uint16_t startHue, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::ColorLoopSet::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateFlags: colorLoopUpdateFlags - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateFlags)); - // action: colorLoopAction - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), action)); - // direction: colorLoopDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // time: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), time)); - // startHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), startHue)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::EnhancedMoveHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: hueMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveToHue(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t enhancedHue, uint8_t direction, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::EnhancedMoveToHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // enhancedHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), enhancedHue)); - // direction: hueDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t enhancedHue, - uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ColorControl::Commands::EnhancedMoveToHueAndSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // enhancedHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), enhancedHue)); - // saturation: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedStepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::EnhancedStepHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: hueStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - int16_t rateX, int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveColor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // rateX: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rateX)); - // rateY: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rateY)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: hueMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: saturationMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t colorX, uint16_t colorY, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveToColor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // colorX: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorX)); - // colorY: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorY)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToColorTemperature(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t colorTemperature, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ColorControl::Commands::MoveToColorTemperature::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // colorTemperature: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperature)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t hue, uint8_t direction, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveToHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // hue: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hue)); - // direction: hueDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t hue, uint8_t saturation, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ColorControl::Commands::MoveToHueAndSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // hue: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hue)); - // saturation: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::MoveToSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::MoveToSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // saturation: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StepColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - int16_t stepX, int16_t stepY, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StepColor::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepX: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepX)); - // stepY: int16s - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepY)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StepHue::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: hueStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ColorControlCluster::StepSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ColorControl::Commands::StepSaturation::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: saturationStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Groups Cluster Commands - -// Identify Cluster Commands - -// OtaSoftwareUpdateProvider Cluster Commands -CHIP_ERROR OtaSoftwareUpdateProviderCluster::ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // newVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), newVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::QueryImage(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::VendorId vendorId, - uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::QueryImage::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // vendorId: vendorId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), vendorId)); - // productId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), productId)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - // protocolsSupported: OTADownloadProtocol - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), protocolsSupported)); - // hardwareVersion: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hardwareVersion)); - // location: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), location)); - // requestorCanConsent: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), requestorCanConsent)); - // metadataForProvider: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), metadataForProvider)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OnOff Cluster Commands - -// Scenes Cluster Commands - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/light-switch-app/zap-generated/CHIPClusters.h b/zzz_generated/light-switch-app/zap-generated/CHIPClusters.h index 5c327026f9878e..018ec5bc99f238 100644 --- a/zzz_generated/light-switch-app/zap-generated/CHIPClusters.h +++ b/zzz_generated/light-switch-app/zap-generated/CHIPClusters.h @@ -35,45 +35,6 @@ class DLL_EXPORT ColorControlCluster : public ClusterBase public: ColorControlCluster() : ClusterBase(app::Clusters::ColorControl::Id) {} ~ColorControlCluster() {} - - // Cluster Commands - CHIP_ERROR ColorLoopSet(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t updateFlags, - uint8_t action, uint8_t direction, uint16_t time, uint16_t startHue, uint8_t optionsMask, - uint8_t optionsOverride); - CHIP_ERROR EnhancedMoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR EnhancedMoveToHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t enhancedHue, uint8_t direction, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride); - CHIP_ERROR EnhancedMoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t enhancedHue, uint8_t saturation, uint16_t transitionTime, - uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR EnhancedStepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, int16_t rateX, - int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveToColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t colorX, - uint16_t colorY, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveToColorTemperature(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t colorTemperature, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride); - CHIP_ERROR MoveToHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t hue, - uint8_t direction, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR MoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t hue, uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride); - CHIP_ERROR MoveToSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR StepColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, int16_t stepX, - int16_t stepY, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR StepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR StepSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); }; class DLL_EXPORT GroupsCluster : public ClusterBase @@ -95,16 +56,6 @@ class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase public: OtaSoftwareUpdateProviderCluster() : ClusterBase(app::Clusters::OtaSoftwareUpdateProvider::Id) {} ~OtaSoftwareUpdateProviderCluster() {} - - // Cluster Commands - CHIP_ERROR ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion); - CHIP_ERROR NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion); - CHIP_ERROR QueryImage(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::VendorId vendorId, uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider); }; class DLL_EXPORT OnOffCluster : public ClusterBase diff --git a/zzz_generated/light-switch-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/light-switch-app/zap-generated/IMClusterCommandHandler.cpp index 9b5df25f79d921..fe03aba09ae71c 100644 --- a/zzz_generated/light-switch-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/light-switch-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace Binding { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -172,10 +164,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -213,10 +201,6 @@ namespace EthernetNetworkDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -254,10 +238,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -314,10 +294,6 @@ namespace Identify { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -373,10 +349,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -457,203 +429,10 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } // namespace NetworkCommissioning -namespace OtaSoftwareUpdateProvider { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::ApplyUpdateResponse::Id: { - expectArgumentCount = 2; - uint8_t action; - uint32_t delayedActionTime; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(action); - break; - case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback( - aCommandPath.mEndpointId, apCommandObj, action, delayedActionTime); - } - break; - } - case Commands::QueryImageResponse::Id: { - expectArgumentCount = 8; - uint8_t status; - uint32_t delayedActionTime; - chip::CharSpan imageURI; - uint32_t softwareVersion; - chip::CharSpan softwareVersionString; - chip::ByteSpan updateToken; - bool userConsentNeeded; - chip::ByteSpan metadataForRequestor; - bool argExists[8]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 8) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); - break; - case 2: - TLVUnpackError = aDataTlv.Get(imageURI); - break; - case 3: - TLVUnpackError = aDataTlv.Get(softwareVersion); - break; - case 4: - TLVUnpackError = aDataTlv.Get(softwareVersionString); - break; - case 5: - TLVUnpackError = aDataTlv.Get(updateToken); - break; - case 6: - TLVUnpackError = aDataTlv.Get(userConsentNeeded); - break; - case 7: - TLVUnpackError = aDataTlv.Get(metadataForRequestor); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 8 == validArgumentCount) - { - wasHandled = emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback( - aCommandPath.mEndpointId, apCommandObj, status, delayedActionTime, imageURI, softwareVersion, - softwareVersionString, updateToken, userConsentNeeded, metadataForRequestor); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace OtaSoftwareUpdateProvider - namespace OtaSoftwareUpdateRequestor { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -692,10 +471,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -805,20 +580,10 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } // namespace OperationalCredentials -namespace Scenes { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) {} - -} // namespace Scenes - namespace SoftwareDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -856,10 +621,6 @@ namespace ThreadNetworkDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -897,10 +658,6 @@ namespace WiFiNetworkDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -987,30 +744,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - case Clusters::OtaSoftwareUpdateProvider::Id: - Clusters::OtaSoftwareUpdateProvider::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::Scenes::Id: - Clusters::Scenes::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 006fc302c5615a..00000000000000 --- a/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -bool emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t action, uint32_t delayedActionTime) -{ - ChipLogProgress(Zcl, "ApplyUpdateResponse:"); - ChipLogProgress(Zcl, " action: %" PRIu8 "", action); - ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); - - GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, action, delayedActionTime); - return true; -} - -bool emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t status, uint32_t delayedActionTime, - chip::CharSpan imageURI, uint32_t softwareVersion, - chip::CharSpan softwareVersionString, - chip::ByteSpan updateToken, bool userConsentNeeded, - chip::ByteSpan metadataForRequestor) -{ - ChipLogProgress(Zcl, "QueryImageResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); - ChipLogProgress(Zcl, " imageURI: %.*s", static_cast(imageURI.size()), imageURI.data()); - ChipLogProgress(Zcl, " softwareVersion: %" PRIu32 "", softwareVersion); - ChipLogProgress(Zcl, " softwareVersionString: %.*s", static_cast(softwareVersionString.size()), - softwareVersionString.data()); - ChipLogProgress(Zcl, " updateToken: %zu", updateToken.size()); - ChipLogProgress(Zcl, " userConsentNeeded: %d", userConsentNeeded); - ChipLogProgress(Zcl, " metadataForRequestor: %zu", metadataForRequestor.size()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterQueryImageResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, delayedActionTime, imageURI, softwareVersion, softwareVersionString, updateToken, - userConsentNeeded, metadataForRequestor); - return true; -} diff --git a/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.h index d1357004d3de3a..7ce7f6e003bd31 100644 --- a/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.h @@ -30,15 +30,4 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks -typedef void (*OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback)(void * context, uint8_t action, - uint32_t delayedActionTime); -typedef void (*OtaSoftwareUpdateProviderClusterQueryImageResponseCallback)( - void * context, uint8_t status, uint32_t delayedActionTime, chip::CharSpan imageURI, uint32_t softwareVersion, - chip::CharSpan softwareVersionString, chip::ByteSpan updateToken, bool userConsentNeeded, chip::ByteSpan metadataForRequestor); - // List specific responses diff --git a/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp b/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index 90cf539961408b..00000000000000 --- a/zzz_generated/lighting-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// OtaSoftwareUpdateProvider Cluster Commands -CHIP_ERROR OtaSoftwareUpdateProviderCluster::ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // newVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), newVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::QueryImage(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::VendorId vendorId, - uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::QueryImage::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // vendorId: vendorId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), vendorId)); - // productId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), productId)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - // protocolsSupported: OTADownloadProtocol - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), protocolsSupported)); - // hardwareVersion: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hardwareVersion)); - // location: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), location)); - // requestorCanConsent: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), requestorCanConsent)); - // metadataForProvider: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), metadataForProvider)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OnOff Cluster Commands - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/lighting-app/zap-generated/CHIPClusters.h b/zzz_generated/lighting-app/zap-generated/CHIPClusters.h index df0b4acf88ec9c..252b5efc4080d6 100644 --- a/zzz_generated/lighting-app/zap-generated/CHIPClusters.h +++ b/zzz_generated/lighting-app/zap-generated/CHIPClusters.h @@ -35,16 +35,6 @@ class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase public: OtaSoftwareUpdateProviderCluster() : ClusterBase(app::Clusters::OtaSoftwareUpdateProvider::Id) {} ~OtaSoftwareUpdateProviderCluster() {} - - // Cluster Commands - CHIP_ERROR ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion); - CHIP_ERROR NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion); - CHIP_ERROR QueryImage(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::VendorId vendorId, uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider); }; class DLL_EXPORT OnOffCluster : public ClusterBase diff --git a/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp index b7956c161b8852..8c53fc9504b063 100644 --- a/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace ColorControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -326,10 +318,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -367,10 +355,6 @@ namespace EthernetNetworkDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -408,10 +392,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -468,10 +448,6 @@ namespace Groups { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -554,10 +530,6 @@ namespace Identify { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -613,10 +585,6 @@ namespace LevelControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -717,10 +685,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -801,203 +765,10 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } // namespace NetworkCommissioning -namespace OtaSoftwareUpdateProvider { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::ApplyUpdateResponse::Id: { - expectArgumentCount = 2; - uint8_t action; - uint32_t delayedActionTime; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(action); - break; - case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback( - aCommandPath.mEndpointId, apCommandObj, action, delayedActionTime); - } - break; - } - case Commands::QueryImageResponse::Id: { - expectArgumentCount = 8; - uint8_t status; - uint32_t delayedActionTime; - chip::CharSpan imageURI; - uint32_t softwareVersion; - chip::CharSpan softwareVersionString; - chip::ByteSpan updateToken; - bool userConsentNeeded; - chip::ByteSpan metadataForRequestor; - bool argExists[8]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 8) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); - break; - case 2: - TLVUnpackError = aDataTlv.Get(imageURI); - break; - case 3: - TLVUnpackError = aDataTlv.Get(softwareVersion); - break; - case 4: - TLVUnpackError = aDataTlv.Get(softwareVersionString); - break; - case 5: - TLVUnpackError = aDataTlv.Get(updateToken); - break; - case 6: - TLVUnpackError = aDataTlv.Get(userConsentNeeded); - break; - case 7: - TLVUnpackError = aDataTlv.Get(metadataForRequestor); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 8 == validArgumentCount) - { - wasHandled = emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback( - aCommandPath.mEndpointId, apCommandObj, status, delayedActionTime, imageURI, softwareVersion, - softwareVersionString, updateToken, userConsentNeeded, metadataForRequestor); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace OtaSoftwareUpdateProvider - namespace OtaSoftwareUpdateRequestor { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1036,10 +807,6 @@ namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1122,10 +889,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1239,10 +1002,6 @@ namespace SoftwareDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1280,10 +1039,6 @@ namespace ThreadNetworkDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1321,10 +1076,6 @@ namespace WiFiNetworkDiagnostics { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1420,27 +1171,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - case Clusters::OtaSoftwareUpdateProvider::Id: - Clusters::OtaSoftwareUpdateProvider::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/lock-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/lock-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/lock-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/lock-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/lock-app/zap-generated/CHIPClientCallbacks.h index 4ad6af42ab6e54..fbed9690c1f3da 100644 --- a/zzz_generated/lock-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/lock-app/zap-generated/CHIPClientCallbacks.h @@ -16,5 +16,3 @@ */ // THIS FILE IS GENERATED BY ZAP - -// List specific responses diff --git a/zzz_generated/lock-app/zap-generated/CHIPClusters.cpp b/zzz_generated/lock-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/lock-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp index a124b9cc45bf0d..0b9ad38262c358 100644 --- a/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/lock-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -163,10 +155,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -223,10 +211,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -311,10 +295,6 @@ namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -370,10 +350,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -518,24 +494,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/log-source-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/log-source-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 1aa6b5273b27ce..00000000000000 --- a/zzz_generated/log-source-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); diff --git a/zzz_generated/log-source-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/log-source-app/zap-generated/CHIPClientCallbacks.h index 249491128ed06d..7ce7f6e003bd31 100644 --- a/zzz_generated/log-source-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/log-source-app/zap-generated/CHIPClientCallbacks.h @@ -30,10 +30,4 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks - // List specific responses diff --git a/zzz_generated/log-source-app/zap-generated/CHIPClusters.cpp b/zzz_generated/log-source-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index 3254f96885db9b..00000000000000 --- a/zzz_generated/log-source-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// DiagnosticLogs Cluster Commands - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/log-source-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/log-source-app/zap-generated/IMClusterCommandHandler.cpp index 8c1aea165cc220..377af63f60ed9a 100644 --- a/zzz_generated/log-source-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/log-source-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -86,10 +82,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -146,10 +138,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -234,10 +222,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -357,24 +341,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/ota-provider-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/ota-provider-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/ota-provider-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/ota-provider-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/ota-provider-app/zap-generated/CHIPClientCallbacks.h index 4ad6af42ab6e54..fbed9690c1f3da 100644 --- a/zzz_generated/ota-provider-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/ota-provider-app/zap-generated/CHIPClientCallbacks.h @@ -16,5 +16,3 @@ */ // THIS FILE IS GENERATED BY ZAP - -// List specific responses diff --git a/zzz_generated/ota-provider-app/zap-generated/CHIPClusters.cpp b/zzz_generated/ota-provider-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/ota-provider-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/ota-provider-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/ota-provider-app/zap-generated/IMClusterCommandHandler.cpp index a53fb6184e8504..c6ef59c3be0def 100644 --- a/zzz_generated/ota-provider-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/ota-provider-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -105,10 +101,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -193,10 +185,6 @@ namespace OtaSoftwareUpdateProvider { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -254,10 +242,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -377,24 +361,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 006fc302c5615a..00000000000000 --- a/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -bool emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t action, uint32_t delayedActionTime) -{ - ChipLogProgress(Zcl, "ApplyUpdateResponse:"); - ChipLogProgress(Zcl, " action: %" PRIu8 "", action); - ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); - - GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, action, delayedActionTime); - return true; -} - -bool emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t status, uint32_t delayedActionTime, - chip::CharSpan imageURI, uint32_t softwareVersion, - chip::CharSpan softwareVersionString, - chip::ByteSpan updateToken, bool userConsentNeeded, - chip::ByteSpan metadataForRequestor) -{ - ChipLogProgress(Zcl, "QueryImageResponse:"); - ChipLogProgress(Zcl, " status: %" PRIu8 "", status); - ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime); - ChipLogProgress(Zcl, " imageURI: %.*s", static_cast(imageURI.size()), imageURI.data()); - ChipLogProgress(Zcl, " softwareVersion: %" PRIu32 "", softwareVersion); - ChipLogProgress(Zcl, " softwareVersionString: %.*s", static_cast(softwareVersionString.size()), - softwareVersionString.data()); - ChipLogProgress(Zcl, " updateToken: %zu", updateToken.size()); - ChipLogProgress(Zcl, " userConsentNeeded: %d", userConsentNeeded); - ChipLogProgress(Zcl, " metadataForRequestor: %zu", metadataForRequestor.size()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterQueryImageResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, status, delayedActionTime, imageURI, softwareVersion, softwareVersionString, updateToken, - userConsentNeeded, metadataForRequestor); - return true; -} diff --git a/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.h index d1357004d3de3a..7ce7f6e003bd31 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.h @@ -30,15 +30,4 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks -typedef void (*OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback)(void * context, uint8_t action, - uint32_t delayedActionTime); -typedef void (*OtaSoftwareUpdateProviderClusterQueryImageResponseCallback)( - void * context, uint8_t status, uint32_t delayedActionTime, chip::CharSpan imageURI, uint32_t softwareVersion, - chip::CharSpan softwareVersionString, chip::ByteSpan updateToken, bool userConsentNeeded, chip::ByteSpan metadataForRequestor); - // List specific responses diff --git a/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp b/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index 8ba83874fa6545..00000000000000 --- a/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// OtaSoftwareUpdateProvider Cluster Commands -CHIP_ERROR OtaSoftwareUpdateProviderCluster::ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // newVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), newVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateToken: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OtaSoftwareUpdateProviderCluster::QueryImage(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::VendorId vendorId, - uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OtaSoftwareUpdateProvider::Commands::QueryImage::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // vendorId: vendorId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), vendorId)); - // productId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), productId)); - // softwareVersion: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion)); - // protocolsSupported: OTADownloadProtocol - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), protocolsSupported)); - // hardwareVersion: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hardwareVersion)); - // location: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), location)); - // requestorCanConsent: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), requestorCanConsent)); - // metadataForProvider: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), metadataForProvider)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.h b/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.h index ede4e32855fc3a..15ec5aca34a215 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.h +++ b/zzz_generated/ota-requestor-app/zap-generated/CHIPClusters.h @@ -35,16 +35,6 @@ class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase public: OtaSoftwareUpdateProviderCluster() : ClusterBase(app::Clusters::OtaSoftwareUpdateProvider::Id) {} ~OtaSoftwareUpdateProviderCluster() {} - - // Cluster Commands - CHIP_ERROR ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t newVersion); - CHIP_ERROR NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan updateToken, uint32_t softwareVersion); - CHIP_ERROR QueryImage(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::VendorId vendorId, uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported, - uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent, - chip::ByteSpan metadataForProvider); }; } // namespace Controller diff --git a/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp index 3646ddc1a6ca80..e3b4d91f2e302d 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/ota-requestor-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -105,10 +101,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -189,203 +181,10 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } // namespace NetworkCommissioning -namespace OtaSoftwareUpdateProvider { - -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::ApplyUpdateResponse::Id: { - expectArgumentCount = 2; - uint8_t action; - uint32_t delayedActionTime; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(action); - break; - case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback( - aCommandPath.mEndpointId, apCommandObj, action, delayedActionTime); - } - break; - } - case Commands::QueryImageResponse::Id: { - expectArgumentCount = 8; - uint8_t status; - uint32_t delayedActionTime; - chip::CharSpan imageURI; - uint32_t softwareVersion; - chip::CharSpan softwareVersionString; - chip::ByteSpan updateToken; - bool userConsentNeeded; - chip::ByteSpan metadataForRequestor; - bool argExists[8]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 8) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); - break; - case 2: - TLVUnpackError = aDataTlv.Get(imageURI); - break; - case 3: - TLVUnpackError = aDataTlv.Get(softwareVersion); - break; - case 4: - TLVUnpackError = aDataTlv.Get(softwareVersionString); - break; - case 5: - TLVUnpackError = aDataTlv.Get(updateToken); - break; - case 6: - TLVUnpackError = aDataTlv.Get(userConsentNeeded); - break; - case 7: - TLVUnpackError = aDataTlv.Get(metadataForRequestor); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 8 == validArgumentCount) - { - wasHandled = emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback( - aCommandPath.mEndpointId, apCommandObj, status, delayedActionTime, imageURI, softwareVersion, - softwareVersionString, updateToken, userConsentNeeded, metadataForRequestor); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace OtaSoftwareUpdateProvider - namespace OtaSoftwareUpdateRequestor { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -424,10 +223,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -566,27 +361,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - case Clusters::OtaSoftwareUpdateProvider::Id: - Clusters::OtaSoftwareUpdateProvider::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/placeholder/app1/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/placeholder/app1/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 0fadb257a761de..00000000000000 --- a/zzz_generated/placeholder/app1/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -void GeneralCommissioningClusterBasicCommissioningInfoListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList< - chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfoType::DecodableType> - list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterFabricsListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterTrustedRootCertificatesListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} diff --git a/zzz_generated/placeholder/app1/zap-generated/CHIPClientCallbacks.h b/zzz_generated/placeholder/app1/zap-generated/CHIPClientCallbacks.h index 367b56ee22b9f9..b920965919b50a 100644 --- a/zzz_generated/placeholder/app1/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/placeholder/app1/zap-generated/CHIPClientCallbacks.h @@ -30,12 +30,6 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks - // List specific responses void GeneralCommissioningClusterBasicCommissioningInfoListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, diff --git a/zzz_generated/placeholder/app1/zap-generated/CHIPClusters.cpp b/zzz_generated/placeholder/app1/zap-generated/CHIPClusters.cpp deleted file mode 100644 index bd6346958aacd9..00000000000000 --- a/zzz_generated/placeholder/app1/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// GeneralCommissioning Cluster Commands -CHIP_ERROR GeneralCommissioningCluster::ArmFailSafe(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t expiryLengthSeconds, - uint64_t breadcrumb, uint32_t timeoutMs) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, GeneralCommissioning::Commands::ArmFailSafe::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // expiryLengthSeconds: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), expiryLengthSeconds)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - // timeoutMs: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GeneralCommissioningCluster::CommissioningComplete(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - GeneralCommissioning::Commands::CommissioningComplete::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GeneralCommissioningCluster::SetRegulatoryConfig(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t location, - chip::CharSpan countryCode, uint64_t breadcrumb, uint32_t timeoutMs) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - GeneralCommissioning::Commands::SetRegulatoryConfig::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // location: regulatoryLocationType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), location)); - // countryCode: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), countryCode)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - // timeoutMs: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OperationalCredentials Cluster Commands -CHIP_ERROR OperationalCredentialsCluster::AddNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan NOCValue, chip::ByteSpan ICACValue, chip::ByteSpan IPKValue, - chip::NodeId caseAdminNode, uint16_t adminVendorId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OperationalCredentials::Commands::AddNOC::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // NOCValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), NOCValue)); - // ICACValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ICACValue)); - // IPKValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), IPKValue)); - // caseAdminNode: nodeId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), caseAdminNode)); - // adminVendorId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), adminVendorId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::AddTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan rootCertificate) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::AddTrustedRootCertificate::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // rootCertificate: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rootCertificate)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::AttestationRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan attestationNonce) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::AttestationRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // attestationNonce: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), attestationNonce)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::CertificateChainRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t certificateType) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::CertificateChainRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // certificateType: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), certificateType)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::OpCSRRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan CSRNonce) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::OpCSRRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // CSRNonce: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), CSRNonce)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::RemoveFabric(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t fabricIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::RemoveFabric::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // fabricIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), fabricIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::RemoveTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan trustedRootIdentifier) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::RemoveTrustedRootCertificate::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // trustedRootIdentifier: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), trustedRootIdentifier)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::UpdateFabricLabel(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::CharSpan label) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::UpdateFabricLabel::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // label: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), label)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::UpdateNOC(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan NOCValue, - chip::ByteSpan ICACValue) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OperationalCredentials::Commands::UpdateNOC::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // NOCValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), NOCValue)); - // ICACValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ICACValue)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// TemperatureMeasurement Cluster Commands - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/placeholder/app1/zap-generated/CHIPClusters.h b/zzz_generated/placeholder/app1/zap-generated/CHIPClusters.h index 67a71ee3a029bc..28fd99fb7cbc7e 100644 --- a/zzz_generated/placeholder/app1/zap-generated/CHIPClusters.h +++ b/zzz_generated/placeholder/app1/zap-generated/CHIPClusters.h @@ -35,13 +35,6 @@ class DLL_EXPORT GeneralCommissioningCluster : public ClusterBase public: GeneralCommissioningCluster() : ClusterBase(app::Clusters::GeneralCommissioning::Id) {} ~GeneralCommissioningCluster() {} - - // Cluster Commands - CHIP_ERROR ArmFailSafe(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t expiryLengthSeconds, uint64_t breadcrumb, uint32_t timeoutMs); - CHIP_ERROR CommissioningComplete(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR SetRegulatoryConfig(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t location, chip::CharSpan countryCode, uint64_t breadcrumb, uint32_t timeoutMs); }; class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase @@ -49,26 +42,6 @@ class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase public: OperationalCredentialsCluster() : ClusterBase(app::Clusters::OperationalCredentials::Id) {} ~OperationalCredentialsCluster() {} - - // Cluster Commands - CHIP_ERROR AddNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::ByteSpan NOCValue, - chip::ByteSpan ICACValue, chip::ByteSpan IPKValue, chip::NodeId caseAdminNode, uint16_t adminVendorId); - CHIP_ERROR AddTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan rootCertificate); - CHIP_ERROR AttestationRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan attestationNonce); - CHIP_ERROR CertificateChainRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t certificateType); - CHIP_ERROR OpCSRRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan CSRNonce); - CHIP_ERROR RemoveFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t fabricIndex); - CHIP_ERROR RemoveTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan trustedRootIdentifier); - CHIP_ERROR UpdateFabricLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan label); - CHIP_ERROR UpdateNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan NOCValue, chip::ByteSpan ICACValue); }; class DLL_EXPORT TemperatureMeasurementCluster : public ClusterBase diff --git a/zzz_generated/placeholder/app1/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/placeholder/app1/zap-generated/IMClusterCommandHandler.cpp index 3e5964c889f695..88e5b13de73db0 100644 --- a/zzz_generated/placeholder/app1/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/placeholder/app1/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace ColorControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -104,10 +100,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -164,10 +156,6 @@ namespace Groups { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -250,10 +238,6 @@ namespace Identify { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -300,10 +284,6 @@ namespace LevelControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -404,10 +384,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -492,10 +468,6 @@ namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -551,10 +523,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -668,10 +636,6 @@ namespace Scenes { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -803,24 +767,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/placeholder/app2/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/placeholder/app2/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 0fadb257a761de..00000000000000 --- a/zzz_generated/placeholder/app2/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -void GeneralCommissioningClusterBasicCommissioningInfoListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList< - chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfoType::DecodableType> - list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterFabricsListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterTrustedRootCertificatesListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} diff --git a/zzz_generated/placeholder/app2/zap-generated/CHIPClientCallbacks.h b/zzz_generated/placeholder/app2/zap-generated/CHIPClientCallbacks.h index 367b56ee22b9f9..b920965919b50a 100644 --- a/zzz_generated/placeholder/app2/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/placeholder/app2/zap-generated/CHIPClientCallbacks.h @@ -30,12 +30,6 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks - // List specific responses void GeneralCommissioningClusterBasicCommissioningInfoListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, diff --git a/zzz_generated/placeholder/app2/zap-generated/CHIPClusters.cpp b/zzz_generated/placeholder/app2/zap-generated/CHIPClusters.cpp deleted file mode 100644 index bd6346958aacd9..00000000000000 --- a/zzz_generated/placeholder/app2/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// GeneralCommissioning Cluster Commands -CHIP_ERROR GeneralCommissioningCluster::ArmFailSafe(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t expiryLengthSeconds, - uint64_t breadcrumb, uint32_t timeoutMs) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, GeneralCommissioning::Commands::ArmFailSafe::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // expiryLengthSeconds: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), expiryLengthSeconds)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - // timeoutMs: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GeneralCommissioningCluster::CommissioningComplete(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - GeneralCommissioning::Commands::CommissioningComplete::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GeneralCommissioningCluster::SetRegulatoryConfig(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t location, - chip::CharSpan countryCode, uint64_t breadcrumb, uint32_t timeoutMs) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - GeneralCommissioning::Commands::SetRegulatoryConfig::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // location: regulatoryLocationType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), location)); - // countryCode: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), countryCode)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - // timeoutMs: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OperationalCredentials Cluster Commands -CHIP_ERROR OperationalCredentialsCluster::AddNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan NOCValue, chip::ByteSpan ICACValue, chip::ByteSpan IPKValue, - chip::NodeId caseAdminNode, uint16_t adminVendorId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OperationalCredentials::Commands::AddNOC::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // NOCValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), NOCValue)); - // ICACValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ICACValue)); - // IPKValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), IPKValue)); - // caseAdminNode: nodeId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), caseAdminNode)); - // adminVendorId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), adminVendorId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::AddTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan rootCertificate) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::AddTrustedRootCertificate::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // rootCertificate: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rootCertificate)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::AttestationRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan attestationNonce) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::AttestationRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // attestationNonce: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), attestationNonce)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::CertificateChainRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t certificateType) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::CertificateChainRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // certificateType: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), certificateType)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::OpCSRRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan CSRNonce) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::OpCSRRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // CSRNonce: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), CSRNonce)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::RemoveFabric(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t fabricIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::RemoveFabric::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // fabricIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), fabricIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::RemoveTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan trustedRootIdentifier) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::RemoveTrustedRootCertificate::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // trustedRootIdentifier: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), trustedRootIdentifier)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::UpdateFabricLabel(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::CharSpan label) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::UpdateFabricLabel::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // label: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), label)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::UpdateNOC(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan NOCValue, - chip::ByteSpan ICACValue) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OperationalCredentials::Commands::UpdateNOC::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // NOCValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), NOCValue)); - // ICACValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ICACValue)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// TemperatureMeasurement Cluster Commands - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/placeholder/app2/zap-generated/CHIPClusters.h b/zzz_generated/placeholder/app2/zap-generated/CHIPClusters.h index 67a71ee3a029bc..28fd99fb7cbc7e 100644 --- a/zzz_generated/placeholder/app2/zap-generated/CHIPClusters.h +++ b/zzz_generated/placeholder/app2/zap-generated/CHIPClusters.h @@ -35,13 +35,6 @@ class DLL_EXPORT GeneralCommissioningCluster : public ClusterBase public: GeneralCommissioningCluster() : ClusterBase(app::Clusters::GeneralCommissioning::Id) {} ~GeneralCommissioningCluster() {} - - // Cluster Commands - CHIP_ERROR ArmFailSafe(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t expiryLengthSeconds, uint64_t breadcrumb, uint32_t timeoutMs); - CHIP_ERROR CommissioningComplete(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR SetRegulatoryConfig(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t location, chip::CharSpan countryCode, uint64_t breadcrumb, uint32_t timeoutMs); }; class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase @@ -49,26 +42,6 @@ class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase public: OperationalCredentialsCluster() : ClusterBase(app::Clusters::OperationalCredentials::Id) {} ~OperationalCredentialsCluster() {} - - // Cluster Commands - CHIP_ERROR AddNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::ByteSpan NOCValue, - chip::ByteSpan ICACValue, chip::ByteSpan IPKValue, chip::NodeId caseAdminNode, uint16_t adminVendorId); - CHIP_ERROR AddTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan rootCertificate); - CHIP_ERROR AttestationRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan attestationNonce); - CHIP_ERROR CertificateChainRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t certificateType); - CHIP_ERROR OpCSRRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan CSRNonce); - CHIP_ERROR RemoveFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t fabricIndex); - CHIP_ERROR RemoveTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan trustedRootIdentifier); - CHIP_ERROR UpdateFabricLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan label); - CHIP_ERROR UpdateNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan NOCValue, chip::ByteSpan ICACValue); }; class DLL_EXPORT TemperatureMeasurementCluster : public ClusterBase diff --git a/zzz_generated/placeholder/app2/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/placeholder/app2/zap-generated/IMClusterCommandHandler.cpp index 3e5964c889f695..88e5b13de73db0 100644 --- a/zzz_generated/placeholder/app2/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/placeholder/app2/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace ColorControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -104,10 +100,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -164,10 +156,6 @@ namespace Groups { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -250,10 +238,6 @@ namespace Identify { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -300,10 +284,6 @@ namespace LevelControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -404,10 +384,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -492,10 +468,6 @@ namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -551,10 +523,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -668,10 +636,6 @@ namespace Scenes { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -803,24 +767,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 1aa6b5273b27ce..00000000000000 --- a/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); diff --git a/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.h index 249491128ed06d..7ce7f6e003bd31 100644 --- a/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.h @@ -30,10 +30,4 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks - // List specific responses diff --git a/zzz_generated/pump-app/zap-generated/CHIPClusters.cpp b/zzz_generated/pump-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index 49417070cd9004..00000000000000 --- a/zzz_generated/pump-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// FlowMeasurement Cluster Commands - -// PressureMeasurement Cluster Commands - -// TemperatureMeasurement Cluster Commands - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/pump-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/pump-app/zap-generated/IMClusterCommandHandler.cpp index de1b328a27519d..eee972c808955e 100644 --- a/zzz_generated/pump-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/pump-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -163,10 +155,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -223,10 +211,6 @@ namespace LevelControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -327,10 +311,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -415,10 +395,6 @@ namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -474,10 +450,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -625,24 +597,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 1aa6b5273b27ce..00000000000000 --- a/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); diff --git a/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.h index 249491128ed06d..7ce7f6e003bd31 100644 --- a/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.h @@ -30,10 +30,4 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks - // List specific responses diff --git a/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.cpp b/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index 70e24d51d6e020..00000000000000 --- a/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,519 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// FlowMeasurement Cluster Commands - -// LevelControl Cluster Commands -CHIP_ERROR LevelControlCluster::Move(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint8_t rate, uint8_t optionMask, uint8_t optionOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::Move::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: moveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); - // optionOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::MoveToLevel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t level, uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::MoveToLevel::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // level: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), level)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); - // optionOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::MoveToLevelWithOnOff(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t level, - uint16_t transitionTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::MoveToLevelWithOnOff::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // level: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), level)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::MoveWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint8_t rate) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::MoveWithOnOff::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: moveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::Step(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint8_t stepSize, uint16_t transitionTime, uint8_t optionMask, - uint8_t optionOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::Step::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: stepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); - // optionOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::StepWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint8_t stepSize, uint16_t transitionTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::StepWithOnOff::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: stepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::Stop(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t optionMask, uint8_t optionOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::Stop::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // optionMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); - // optionOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR LevelControlCluster::StopWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, LevelControl::Commands::StopWithOnOff::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OnOff Cluster Commands -CHIP_ERROR OnOffCluster::Off(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::Off::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::On(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::On::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OnOffCluster::Toggle(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OnOff::Commands::Toggle::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// PressureMeasurement Cluster Commands - -// PumpConfigurationAndControl Cluster Commands - -// TemperatureMeasurement Cluster Commands - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.h b/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.h index f3ba17c7c8f2bc..89278b783a8d78 100644 --- a/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.h +++ b/zzz_generated/pump-controller-app/zap-generated/CHIPClusters.h @@ -42,23 +42,6 @@ class DLL_EXPORT LevelControlCluster : public ClusterBase public: LevelControlCluster() : ClusterBase(app::Clusters::LevelControl::Id) {} ~LevelControlCluster() {} - - // Cluster Commands - CHIP_ERROR Move(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint8_t rate, uint8_t optionMask, uint8_t optionOverride); - CHIP_ERROR MoveToLevel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t level, - uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride); - CHIP_ERROR MoveToLevelWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t level, uint16_t transitionTime); - CHIP_ERROR MoveWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint8_t rate); - CHIP_ERROR Step(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint8_t stepSize, uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride); - CHIP_ERROR StepWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint8_t stepSize, uint16_t transitionTime); - CHIP_ERROR Stop(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t optionMask, - uint8_t optionOverride); - CHIP_ERROR StopWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT OnOffCluster : public ClusterBase @@ -66,11 +49,6 @@ class DLL_EXPORT OnOffCluster : public ClusterBase public: OnOffCluster() : ClusterBase(app::Clusters::OnOff::Id) {} ~OnOffCluster() {} - - // Cluster Commands - CHIP_ERROR Off(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR On(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR Toggle(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT PressureMeasurementCluster : public ClusterBase diff --git a/zzz_generated/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp index 3bb2f7ee6ebade..3c623331d1aaab 100644 --- a/zzz_generated/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -163,10 +155,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -223,10 +211,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -311,10 +295,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -456,24 +436,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/temperature-measurement-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/temperature-measurement-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/temperature-measurement-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/temperature-measurement-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/temperature-measurement-app/zap-generated/CHIPClientCallbacks.h index 4ad6af42ab6e54..fbed9690c1f3da 100644 --- a/zzz_generated/temperature-measurement-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/temperature-measurement-app/zap-generated/CHIPClientCallbacks.h @@ -16,5 +16,3 @@ */ // THIS FILE IS GENERATED BY ZAP - -// List specific responses diff --git a/zzz_generated/temperature-measurement-app/zap-generated/CHIPClusters.cpp b/zzz_generated/temperature-measurement-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/temperature-measurement-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/temperature-measurement-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/temperature-measurement-app/zap-generated/IMClusterCommandHandler.cpp index 02dfac89c50474..2842246820801a 100644 --- a/zzz_generated/temperature-measurement-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/temperature-measurement-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -163,10 +155,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -223,10 +211,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -301,10 +285,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -446,24 +426,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 09df8416c8d06b..00000000000000 --- a/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -bool emberAfIdentifyClusterIdentifyQueryResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint16_t timeout) -{ - ChipLogProgress(Zcl, "IdentifyQueryResponse:"); - ChipLogProgress(Zcl, " timeout: %" PRIu16 "", timeout); - - GET_CLUSTER_RESPONSE_CALLBACKS("IdentifyClusterIdentifyQueryResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, timeout); - return true; -} diff --git a/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.h b/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.h index 88ed9dfb5f809d..7ce7f6e003bd31 100644 --- a/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.h @@ -30,11 +30,4 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks -typedef void (*IdentifyClusterIdentifyQueryResponseCallback)(void * context, uint16_t timeout); - // List specific responses diff --git a/zzz_generated/thermostat/zap-generated/CHIPClusters.cpp b/zzz_generated/thermostat/zap-generated/CHIPClusters.cpp deleted file mode 100644 index 887713349f8011..00000000000000 --- a/zzz_generated/thermostat/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// Identify Cluster Commands -CHIP_ERROR IdentifyCluster::Identify(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t identifyTime) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Identify::Commands::Identify::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // identifyTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), identifyTime)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR IdentifyCluster::IdentifyQuery(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Identify::Commands::IdentifyQuery::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/thermostat/zap-generated/CHIPClusters.h b/zzz_generated/thermostat/zap-generated/CHIPClusters.h index ea4d0ccfe3209d..720e7b79d6c033 100644 --- a/zzz_generated/thermostat/zap-generated/CHIPClusters.h +++ b/zzz_generated/thermostat/zap-generated/CHIPClusters.h @@ -35,10 +35,6 @@ class DLL_EXPORT IdentifyCluster : public ClusterBase public: IdentifyCluster() : ClusterBase(app::Clusters::Identify::Id) {} ~IdentifyCluster() {} - - // Cluster Commands - CHIP_ERROR Identify(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t identifyTime); - CHIP_ERROR IdentifyQuery(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; } // namespace Controller diff --git a/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp index 71249ca584665d..4ba8854fc988ea 100644 --- a/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/thermostat/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace Binding { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -172,10 +164,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -213,10 +201,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -273,10 +257,6 @@ namespace Groups { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -357,108 +337,8 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP namespace Identify { -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::IdentifyQueryResponse::Id: { - expectArgumentCount = 1; - uint16_t timeout; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(timeout); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = emberAfIdentifyClusterIdentifyQueryResponseCallback(aCommandPath.mEndpointId, apCommandObj, timeout); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace Identify - -namespace Identify { - void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -505,10 +385,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -593,10 +469,6 @@ namespace OtaSoftwareUpdateProvider { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -654,10 +526,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -771,10 +639,6 @@ namespace Scenes { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -866,10 +730,6 @@ namespace Thermostat { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -989,27 +849,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - case Clusters::Identify::Id: - Clusters::Identify::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 72365cba8d105e..00000000000000 --- a/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -void GeneralCommissioningClusterBasicCommissioningInfoListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList< - chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfoType::DecodableType> - list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void NetworkCommissioningClusterNetworksListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterNOCsListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterFabricsListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void OperationalCredentialsClusterTrustedRootCertificatesListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -bool emberAfGeneralCommissioningClusterArmFailSafeResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t errorCode, chip::CharSpan debugText) -{ - ChipLogProgress(Zcl, "ArmFailSafeResponse:"); - ChipLogProgress(Zcl, " errorCode: %" PRIu8 "", errorCode); - ChipLogProgress(Zcl, " debugText: %.*s", static_cast(debugText.size()), debugText.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("GeneralCommissioningClusterArmFailSafeResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, errorCode, debugText); - return true; -} - -bool emberAfGeneralCommissioningClusterCommissioningCompleteResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t errorCode, chip::CharSpan debugText) -{ - ChipLogProgress(Zcl, "CommissioningCompleteResponse:"); - ChipLogProgress(Zcl, " errorCode: %" PRIu8 "", errorCode); - ChipLogProgress(Zcl, " debugText: %.*s", static_cast(debugText.size()), debugText.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("GeneralCommissioningClusterCommissioningCompleteResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, errorCode, debugText); - return true; -} - -bool emberAfGeneralCommissioningClusterSetRegulatoryConfigResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t errorCode, chip::CharSpan debugText) -{ - ChipLogProgress(Zcl, "SetRegulatoryConfigResponse:"); - ChipLogProgress(Zcl, " errorCode: %" PRIu8 "", errorCode); - ChipLogProgress(Zcl, " debugText: %.*s", static_cast(debugText.size()), debugText.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("GeneralCommissioningClusterSetRegulatoryConfigResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, errorCode, debugText); - return true; -} - -bool emberAfNetworkCommissioningClusterConnectNetworkResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t NetworkingStatus, chip::CharSpan DebugText, - int32_t ErrorValue) -{ - ChipLogProgress(Zcl, "ConnectNetworkResponse:"); - ChipLogProgress(Zcl, " NetworkingStatus: %" PRIu8 "", NetworkingStatus); - ChipLogProgress(Zcl, " DebugText: %.*s", static_cast(DebugText.size()), DebugText.data()); - ChipLogProgress(Zcl, " ErrorValue: %" PRId32 "", ErrorValue); - - GET_CLUSTER_RESPONSE_CALLBACKS("NetworkCommissioningClusterConnectNetworkResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, NetworkingStatus, DebugText, ErrorValue); - return true; -} - -bool emberAfNetworkCommissioningClusterNetworkConfigResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t NetworkingStatus, chip::CharSpan DebugText) -{ - ChipLogProgress(Zcl, "NetworkConfigResponse:"); - ChipLogProgress(Zcl, " NetworkingStatus: %" PRIu8 "", NetworkingStatus); - ChipLogProgress(Zcl, " DebugText: %.*s", static_cast(DebugText.size()), DebugText.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("NetworkCommissioningClusterNetworkConfigResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, NetworkingStatus, DebugText); - return true; -} - -bool emberAfNetworkCommissioningClusterScanNetworksResponseCallback( - EndpointId endpoint, app::CommandSender * commandObj, uint8_t NetworkingStatus, chip::CharSpan DebugText, - /* TYPE WARNING: array array defaults to */ uint8_t * WiFiScanResults, - /* TYPE WARNING: array array defaults to */ uint8_t * ThreadScanResults) -{ - ChipLogProgress(Zcl, "ScanNetworksResponse:"); - ChipLogProgress(Zcl, " NetworkingStatus: %" PRIu8 "", NetworkingStatus); - ChipLogProgress(Zcl, " DebugText: %.*s", static_cast(DebugText.size()), DebugText.data()); - ChipLogProgress(Zcl, " WiFiScanResults: %p", WiFiScanResults); - ChipLogProgress(Zcl, " ThreadScanResults: %p", ThreadScanResults); - - GET_CLUSTER_RESPONSE_CALLBACKS("NetworkCommissioningClusterScanNetworksResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, NetworkingStatus, DebugText, WiFiScanResults, ThreadScanResults); - return true; -} - -bool emberAfOperationalCredentialsClusterAttestationResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - chip::ByteSpan AttestationElements, chip::ByteSpan Signature) -{ - ChipLogProgress(Zcl, "AttestationResponse:"); - ChipLogProgress(Zcl, " AttestationElements: %zu", AttestationElements.size()); - ChipLogProgress(Zcl, " Signature: %zu", Signature.size()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OperationalCredentialsClusterAttestationResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, AttestationElements, Signature); - return true; -} - -bool emberAfOperationalCredentialsClusterCertificateChainResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - chip::ByteSpan Certificate) -{ - ChipLogProgress(Zcl, "CertificateChainResponse:"); - ChipLogProgress(Zcl, " Certificate: %zu", Certificate.size()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OperationalCredentialsClusterCertificateChainResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, Certificate); - return true; -} - -bool emberAfOperationalCredentialsClusterNOCResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - uint8_t StatusCode, uint8_t FabricIndex, chip::CharSpan DebugText) -{ - ChipLogProgress(Zcl, "NOCResponse:"); - ChipLogProgress(Zcl, " StatusCode: %" PRIu8 "", StatusCode); - ChipLogProgress(Zcl, " FabricIndex: %" PRIu8 "", FabricIndex); - ChipLogProgress(Zcl, " DebugText: %.*s", static_cast(DebugText.size()), DebugText.data()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OperationalCredentialsClusterNOCResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, StatusCode, FabricIndex, DebugText); - return true; -} - -bool emberAfOperationalCredentialsClusterOpCSRResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, - chip::ByteSpan NOCSRElements, chip::ByteSpan AttestationSignature) -{ - ChipLogProgress(Zcl, "OpCSRResponse:"); - ChipLogProgress(Zcl, " NOCSRElements: %zu", NOCSRElements.size()); - ChipLogProgress(Zcl, " AttestationSignature: %zu", AttestationSignature.size()); - - GET_CLUSTER_RESPONSE_CALLBACKS("OperationalCredentialsClusterOpCSRResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, NOCSRElements, AttestationSignature); - return true; -} diff --git a/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.h index 2506041e81c1fc..e95c92af820b21 100644 --- a/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.h @@ -30,32 +30,6 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks -typedef void (*GeneralCommissioningClusterArmFailSafeResponseCallback)(void * context, uint8_t errorCode, chip::CharSpan debugText); -typedef void (*GeneralCommissioningClusterCommissioningCompleteResponseCallback)(void * context, uint8_t errorCode, - chip::CharSpan debugText); -typedef void (*GeneralCommissioningClusterSetRegulatoryConfigResponseCallback)(void * context, uint8_t errorCode, - chip::CharSpan debugText); -typedef void (*NetworkCommissioningClusterConnectNetworkResponseCallback)(void * context, uint8_t NetworkingStatus, - chip::CharSpan DebugText, int32_t ErrorValue); -typedef void (*NetworkCommissioningClusterNetworkConfigResponseCallback)(void * context, uint8_t NetworkingStatus, - chip::CharSpan DebugText); -typedef void (*NetworkCommissioningClusterScanNetworksResponseCallback)( - void * context, uint8_t NetworkingStatus, chip::CharSpan DebugText, - /* TYPE WARNING: array array defaults to */ uint8_t * WiFiScanResults, - /* TYPE WARNING: array array defaults to */ uint8_t * ThreadScanResults); -typedef void (*OperationalCredentialsClusterAttestationResponseCallback)(void * context, chip::ByteSpan AttestationElements, - chip::ByteSpan Signature); -typedef void (*OperationalCredentialsClusterCertificateChainResponseCallback)(void * context, chip::ByteSpan Certificate); -typedef void (*OperationalCredentialsClusterNOCResponseCallback)(void * context, uint8_t StatusCode, uint8_t FabricIndex, - chip::CharSpan DebugText); -typedef void (*OperationalCredentialsClusterOpCSRResponseCallback)(void * context, chip::ByteSpan NOCSRElements, - chip::ByteSpan AttestationSignature); - // List specific responses void GeneralCommissioningClusterBasicCommissioningInfoListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, diff --git a/zzz_generated/tv-app/zap-generated/CHIPClusters.cpp b/zzz_generated/tv-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index 0e57a26e5f23dc..00000000000000 --- a/zzz_generated/tv-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,848 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// Binding Cluster Commands -CHIP_ERROR BindingCluster::Bind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::NodeId nodeId, chip::GroupId groupId, chip::EndpointId endpointId, chip::ClusterId clusterId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Binding::Commands::Bind::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // nodeId: nodeId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), nodeId)); - // groupId: groupId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // endpointId: endpointNo - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), endpointId)); - // clusterId: clusterId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), clusterId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR BindingCluster::Unbind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::NodeId nodeId, chip::GroupId groupId, chip::EndpointId endpointId, - chip::ClusterId clusterId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Binding::Commands::Unbind::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // nodeId: nodeId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), nodeId)); - // groupId: groupId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - // endpointId: endpointNo - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), endpointId)); - // clusterId: clusterId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), clusterId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// GeneralCommissioning Cluster Commands -CHIP_ERROR GeneralCommissioningCluster::ArmFailSafe(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t expiryLengthSeconds, - uint64_t breadcrumb, uint32_t timeoutMs) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, GeneralCommissioning::Commands::ArmFailSafe::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // expiryLengthSeconds: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), expiryLengthSeconds)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - // timeoutMs: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GeneralCommissioningCluster::CommissioningComplete(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - GeneralCommissioning::Commands::CommissioningComplete::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR GeneralCommissioningCluster::SetRegulatoryConfig(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t location, - chip::CharSpan countryCode, uint64_t breadcrumb, uint32_t timeoutMs) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - GeneralCommissioning::Commands::SetRegulatoryConfig::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // location: regulatoryLocationType - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), location)); - // countryCode: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), countryCode)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - // timeoutMs: int32u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// NetworkCommissioning Cluster Commands -CHIP_ERROR NetworkCommissioningCluster::AddOrUpdateThreadNetwork(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan operationalDataset, uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - NetworkCommissioning::Commands::AddOrUpdateThreadNetwork::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // operationalDataset: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), operationalDataset)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR NetworkCommissioningCluster::AddOrUpdateWiFiNetwork(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid, - chip::ByteSpan credentials, uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - NetworkCommissioning::Commands::AddOrUpdateWiFiNetwork::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // ssid: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ssid)); - // credentials: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), credentials)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR NetworkCommissioningCluster::ConnectNetwork(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID, - uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - NetworkCommissioning::Commands::ConnectNetwork::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // networkID: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), networkID)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR NetworkCommissioningCluster::RemoveNetwork(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID, - uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, NetworkCommissioning::Commands::RemoveNetwork::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // networkID: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), networkID)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR NetworkCommissioningCluster::ReorderNetwork(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID, - uint8_t networkIndex, uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - NetworkCommissioning::Commands::ReorderNetwork::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // networkID: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), networkID)); - // networkIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), networkIndex)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR NetworkCommissioningCluster::ScanNetworks(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid, - uint64_t breadcrumb) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, NetworkCommissioning::Commands::ScanNetworks::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // ssid: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ssid)); - // breadcrumb: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// OperationalCredentials Cluster Commands -CHIP_ERROR OperationalCredentialsCluster::AddNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan NOCValue, chip::ByteSpan ICACValue, chip::ByteSpan IPKValue, - chip::NodeId caseAdminNode, uint16_t adminVendorId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, OperationalCredentials::Commands::AddNOC::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // NOCValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), NOCValue)); - // ICACValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), ICACValue)); - // IPKValue: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), IPKValue)); - // caseAdminNode: nodeId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), caseAdminNode)); - // adminVendorId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), adminVendorId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::AddTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan rootCertificate) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::AddTrustedRootCertificate::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // rootCertificate: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rootCertificate)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::AttestationRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, - chip::ByteSpan attestationNonce) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::AttestationRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // attestationNonce: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), attestationNonce)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::CertificateChainRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t certificateType) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::CertificateChainRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // certificateType: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), certificateType)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::OpCSRRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::ByteSpan CSRNonce) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::OpCSRRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // CSRNonce: octetString - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), CSRNonce)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::RemoveFabric(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t fabricIndex) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::RemoveFabric::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // fabricIndex: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), fabricIndex)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR OperationalCredentialsCluster::UpdateFabricLabel(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::CharSpan label) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - OperationalCredentials::Commands::UpdateFabricLabel::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // label: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), label)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/tv-app/zap-generated/CHIPClusters.h b/zzz_generated/tv-app/zap-generated/CHIPClusters.h index 4ee44fb6b867b0..3c1e36bb52eeb8 100644 --- a/zzz_generated/tv-app/zap-generated/CHIPClusters.h +++ b/zzz_generated/tv-app/zap-generated/CHIPClusters.h @@ -35,12 +35,6 @@ class DLL_EXPORT BindingCluster : public ClusterBase public: BindingCluster() : ClusterBase(app::Clusters::Binding::Id) {} ~BindingCluster() {} - - // Cluster Commands - CHIP_ERROR Bind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::NodeId nodeId, - chip::GroupId groupId, chip::EndpointId endpointId, chip::ClusterId clusterId); - CHIP_ERROR Unbind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::NodeId nodeId, - chip::GroupId groupId, chip::EndpointId endpointId, chip::ClusterId clusterId); }; class DLL_EXPORT GeneralCommissioningCluster : public ClusterBase @@ -48,13 +42,6 @@ class DLL_EXPORT GeneralCommissioningCluster : public ClusterBase public: GeneralCommissioningCluster() : ClusterBase(app::Clusters::GeneralCommissioning::Id) {} ~GeneralCommissioningCluster() {} - - // Cluster Commands - CHIP_ERROR ArmFailSafe(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t expiryLengthSeconds, uint64_t breadcrumb, uint32_t timeoutMs); - CHIP_ERROR CommissioningComplete(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR SetRegulatoryConfig(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t location, chip::CharSpan countryCode, uint64_t breadcrumb, uint32_t timeoutMs); }; class DLL_EXPORT NetworkCommissioningCluster : public ClusterBase @@ -62,20 +49,6 @@ class DLL_EXPORT NetworkCommissioningCluster : public ClusterBase public: NetworkCommissioningCluster() : ClusterBase(app::Clusters::NetworkCommissioning::Id) {} ~NetworkCommissioningCluster() {} - - // Cluster Commands - CHIP_ERROR AddOrUpdateThreadNetwork(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan operationalDataset, uint64_t breadcrumb); - CHIP_ERROR AddOrUpdateWiFiNetwork(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan ssid, chip::ByteSpan credentials, uint64_t breadcrumb); - CHIP_ERROR ConnectNetwork(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan networkID, uint64_t breadcrumb); - CHIP_ERROR RemoveNetwork(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan networkID, uint64_t breadcrumb); - CHIP_ERROR ReorderNetwork(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan networkID, uint8_t networkIndex, uint64_t breadcrumb); - CHIP_ERROR ScanNetworks(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid, - uint64_t breadcrumb); }; class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase @@ -83,22 +56,6 @@ class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase public: OperationalCredentialsCluster() : ClusterBase(app::Clusters::OperationalCredentials::Id) {} ~OperationalCredentialsCluster() {} - - // Cluster Commands - CHIP_ERROR AddNOC(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::ByteSpan NOCValue, - chip::ByteSpan ICACValue, chip::ByteSpan IPKValue, chip::NodeId caseAdminNode, uint16_t adminVendorId); - CHIP_ERROR AddTrustedRootCertificate(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan rootCertificate); - CHIP_ERROR AttestationRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan attestationNonce); - CHIP_ERROR CertificateChainRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t certificateType); - CHIP_ERROR OpCSRRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::ByteSpan CSRNonce); - CHIP_ERROR RemoveFabric(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t fabricIndex); - CHIP_ERROR UpdateFabricLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan label); }; } // namespace Controller diff --git a/zzz_generated/tv-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/tv-app/zap-generated/IMClusterCommandHandler.cpp index 97f9af1ea45307..69b0532448513e 100644 --- a/zzz_generated/tv-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/tv-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AccountLogin { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -119,10 +115,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -196,10 +188,6 @@ namespace ApplicationLauncher { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -255,10 +243,6 @@ namespace AudioOutput { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -305,10 +289,6 @@ namespace Binding { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -355,10 +335,6 @@ namespace Channel { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -414,10 +390,6 @@ namespace ContentLauncher { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -464,10 +436,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -503,239 +471,8 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP namespace GeneralCommissioning { -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::ArmFailSafeResponse::Id: { - expectArgumentCount = 2; - uint8_t errorCode; - chip::CharSpan debugText; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - TLVUnpackError = aDataTlv.Get(debugText); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfGeneralCommissioningClusterArmFailSafeResponseCallback(aCommandPath.mEndpointId, apCommandObj, - errorCode, debugText); - } - break; - } - case Commands::CommissioningCompleteResponse::Id: { - expectArgumentCount = 2; - uint8_t errorCode; - chip::CharSpan debugText; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - TLVUnpackError = aDataTlv.Get(debugText); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfGeneralCommissioningClusterCommissioningCompleteResponseCallback( - aCommandPath.mEndpointId, apCommandObj, errorCode, debugText); - } - break; - } - case Commands::SetRegulatoryConfigResponse::Id: { - expectArgumentCount = 2; - uint8_t errorCode; - chip::CharSpan debugText; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - TLVUnpackError = aDataTlv.Get(debugText); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfGeneralCommissioningClusterSetRegulatoryConfigResponseCallback( - aCommandPath.mEndpointId, apCommandObj, errorCode, debugText); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace GeneralCommissioning - -namespace GeneralCommissioning { - void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -792,10 +529,6 @@ namespace KeypadInput { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -833,10 +566,6 @@ namespace LevelControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -937,10 +666,6 @@ namespace LowPower { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -978,10 +703,6 @@ namespace MediaInput { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1046,10 +767,6 @@ namespace MediaPlayback { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1175,253 +892,8 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP namespace NetworkCommissioning { -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::ConnectNetworkResponse::Id: { - expectArgumentCount = 3; - uint8_t NetworkingStatus; - chip::CharSpan DebugText; - int32_t ErrorValue; - bool argExists[3]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(NetworkingStatus); - break; - case 1: - TLVUnpackError = aDataTlv.Get(DebugText); - break; - case 2: - TLVUnpackError = aDataTlv.Get(ErrorValue); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) - { - wasHandled = emberAfNetworkCommissioningClusterConnectNetworkResponseCallback( - aCommandPath.mEndpointId, apCommandObj, NetworkingStatus, DebugText, ErrorValue); - } - break; - } - case Commands::NetworkConfigResponse::Id: { - expectArgumentCount = 2; - uint8_t NetworkingStatus; - chip::CharSpan DebugText; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(NetworkingStatus); - break; - case 1: - TLVUnpackError = aDataTlv.Get(DebugText); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfNetworkCommissioningClusterNetworkConfigResponseCallback(aCommandPath.mEndpointId, apCommandObj, - NetworkingStatus, DebugText); - } - break; - } - case Commands::ScanNetworksResponse::Id: { - expectArgumentCount = 4; - uint8_t NetworkingStatus; - chip::CharSpan DebugText; - /* TYPE WARNING: array array defaults to */ uint8_t * WiFiScanResults; - /* TYPE WARNING: array array defaults to */ uint8_t * ThreadScanResults; - bool argExists[4]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 4) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(NetworkingStatus); - break; - case 1: - TLVUnpackError = aDataTlv.Get(DebugText); - break; - case 2: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(WiFiScanResults)); - break; - case 3: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(ThreadScanResults)); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) - { - wasHandled = emberAfNetworkCommissioningClusterScanNetworksResponseCallback( - aCommandPath.mEndpointId, apCommandObj, NetworkingStatus, DebugText, WiFiScanResults, ThreadScanResults); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace NetworkCommissioning - -namespace NetworkCommissioning { - void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1506,10 +978,6 @@ namespace OtaSoftwareUpdateProvider { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1567,10 +1035,6 @@ namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1624,302 +1088,8 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP namespace OperationalCredentials { -void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandPath.mCommandId) - { - case Commands::AttestationResponse::Id: { - expectArgumentCount = 2; - chip::ByteSpan AttestationElements; - chip::ByteSpan Signature; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(AttestationElements); - break; - case 1: - TLVUnpackError = aDataTlv.Get(Signature); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfOperationalCredentialsClusterAttestationResponseCallback(aCommandPath.mEndpointId, apCommandObj, - AttestationElements, Signature); - } - break; - } - case Commands::CertificateChainResponse::Id: { - expectArgumentCount = 1; - chip::ByteSpan Certificate; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(Certificate); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - wasHandled = emberAfOperationalCredentialsClusterCertificateChainResponseCallback(aCommandPath.mEndpointId, - apCommandObj, Certificate); - } - break; - } - case Commands::NOCResponse::Id: { - expectArgumentCount = 3; - uint8_t StatusCode; - uint8_t FabricIndex; - chip::CharSpan DebugText; - bool argExists[3]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(StatusCode); - break; - case 1: - TLVUnpackError = aDataTlv.Get(FabricIndex); - break; - case 2: - TLVUnpackError = aDataTlv.Get(DebugText); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) - { - wasHandled = emberAfOperationalCredentialsClusterNOCResponseCallback(aCommandPath.mEndpointId, apCommandObj, - StatusCode, FabricIndex, DebugText); - } - break; - } - case Commands::OpCSRResponse::Id: { - expectArgumentCount = 2; - chip::ByteSpan NOCSRElements; - chip::ByteSpan AttestationSignature; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); - - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: - TLVUnpackError = aDataTlv.Get(NOCSRElements); - break; - case 1: - TLVUnpackError = aDataTlv.Get(AttestationSignature); - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) - { - wasHandled = emberAfOperationalCredentialsClusterOpCSRResponseCallback(aCommandPath.mEndpointId, apCommandObj, - NOCSRElements, AttestationSignature); - } - break; - } - default: { - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace OperationalCredentials - -namespace OperationalCredentials { - void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -2033,10 +1203,6 @@ namespace TargetNavigator { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -2144,33 +1310,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - case Clusters::GeneralCommissioning::Id: - Clusters::GeneralCommissioning::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::NetworkCommissioning::Id: - Clusters::NetworkCommissioning::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - case Clusters::OperationalCredentials::Id: - Clusters::OperationalCredentials::DispatchClientCommand(apCommandObj, aCommandPath, aReader); - break; - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/tv-casting-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/tv-casting-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index 7a2f98f076babf..00000000000000 --- a/zzz_generated/tv-casting-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace ::chip; -using namespace ::chip::app::DataModel; - -namespace { -[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -} // namespace - -#define CHECK_STATUS_WITH_RETVAL(error, retval) \ - if (CHIP_NO_ERROR != error) \ - { \ - ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } - -#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) -#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) - -#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ - if (!CanCastTo(value)) \ - { \ - ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - if (messageLen < value) \ - { \ - ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \ - if (onFailureCallback != nullptr) \ - { \ - Callback::Callback * cb = \ - Callback::Callback::FromCancelable(onFailureCallback); \ - cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ - } \ - return retval; \ - } \ - \ - messageLen = static_cast(messageLen - static_cast(value)); - -#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) -#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) - -#define GET_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \ - uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \ - Callback::Cancelable * onSuccessCallback = nullptr; \ - Callback::Cancelable * onFailureCallback = nullptr; \ - NodeId sourceIdentifier = reinterpret_cast(commandObj); \ - /* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \ - CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \ - \ - if (CHIP_NO_ERROR != err) \ - { \ - if (onSuccessCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing success callback", name); \ - } \ - \ - if (onFailureCallback == nullptr) \ - { \ - ChipLogDetail(Zcl, "%s: Missing failure callback", name); \ - } \ - \ - return true; \ - } - -// Singleton instance of the callbacks manager -app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance(); - -void ApplicationLauncherClusterApplicationLauncherListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void AudioOutputClusterAudioOutputListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ChannelClusterChannelListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void ContentLauncherClusterAcceptHeaderListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void MediaInputClusterMediaInputListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} - -void TargetNavigatorClusterTargetNavigatorListListAttributeFilter(TLV::TLVReader * tlvData, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::DataModel::DecodableList list; - CHIP_ERROR err = Decode(*tlvData, list); - if (err != CHIP_NO_ERROR) - { - if (onFailureCallback != nullptr) - { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - } - return; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, list); -} diff --git a/zzz_generated/tv-casting-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/tv-casting-app/zap-generated/CHIPClientCallbacks.h index 3b4b83df36856b..59da302f526b6b 100644 --- a/zzz_generated/tv-casting-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/tv-casting-app/zap-generated/CHIPClientCallbacks.h @@ -30,12 +30,6 @@ #include #include -// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus -// instead of IM status code. -// #6308 should handle IM error code on the application side, either modify this function or remove this. - -// Cluster Specific Response Callbacks - // List specific responses void ApplicationLauncherClusterApplicationLauncherListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, diff --git a/zzz_generated/tv-casting-app/zap-generated/CHIPClusters.cpp b/zzz_generated/tv-casting-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index 7bc8d07a33696e..00000000000000 --- a/zzz_generated/tv-casting-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,1285 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include "CHIPClusters.h" - -#include -#include - -namespace chip { - -using namespace app::Clusters; -using namespace System; -using namespace Encoding::LittleEndian; - -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -// AccountLogin Cluster Commands -CHIP_ERROR AccountLoginCluster::GetSetupPINRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::CharSpan tempAccountIdentifier) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, AccountLogin::Commands::GetSetupPINRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // tempAccountIdentifier: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), tempAccountIdentifier)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR AccountLoginCluster::LoginRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan tempAccountIdentifier, chip::CharSpan setupPIN) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, AccountLogin::Commands::LoginRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // tempAccountIdentifier: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), tempAccountIdentifier)); - // setupPIN: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), setupPIN)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR AccountLoginCluster::LogoutRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, AccountLogin::Commands::LogoutRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// ApplicationBasic Cluster Commands - -// ApplicationLauncher Cluster Commands -CHIP_ERROR ApplicationLauncherCluster::HideAppRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t catalogVendorId, - chip::CharSpan applicationId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ApplicationLauncher::Commands::HideAppRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // catalogVendorId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), catalogVendorId)); - // applicationId: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), applicationId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ApplicationLauncherCluster::LaunchAppRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::CharSpan data, - uint16_t catalogVendorId, chip::CharSpan applicationId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ApplicationLauncher::Commands::LaunchAppRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // data: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), data)); - // catalogVendorId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), catalogVendorId)); - // applicationId: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), applicationId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ApplicationLauncherCluster::StopAppRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t catalogVendorId, - chip::CharSpan applicationId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ApplicationLauncher::Commands::StopAppRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // catalogVendorId: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), catalogVendorId)); - // applicationId: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), applicationId)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// AudioOutput Cluster Commands -CHIP_ERROR AudioOutputCluster::RenameOutputRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t index, chip::CharSpan name) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, AudioOutput::Commands::RenameOutputRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // index: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), index)); - // name: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), name)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR AudioOutputCluster::SelectOutputRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t index) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, AudioOutput::Commands::SelectOutputRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // index: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), index)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// Channel Cluster Commands -CHIP_ERROR ChannelCluster::ChangeChannelByNumberRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t majorNumber, - uint16_t minorNumber) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - Channel::Commands::ChangeChannelByNumberRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // majorNumber: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), majorNumber)); - // minorNumber: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), minorNumber)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ChannelCluster::ChangeChannelRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan match) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Channel::Commands::ChangeChannelRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // match: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), match)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ChannelCluster::SkipChannelRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t count) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, Channel::Commands::SkipChannelRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // count: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), count)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// ContentLauncher Cluster Commands -CHIP_ERROR ContentLauncherCluster::LaunchContentRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, bool autoPlay, - chip::CharSpan data) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - ContentLauncher::Commands::LaunchContentRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // autoPlay: boolean - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), autoPlay)); - // data: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), data)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR ContentLauncherCluster::LaunchURLRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, chip::CharSpan contentURL, - chip::CharSpan displayString, chip::CharSpan providerName) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, ContentLauncher::Commands::LaunchURLRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // contentURL: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), contentURL)); - // displayString: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), displayString)); - // providerName: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), providerName)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// KeypadInput Cluster Commands -CHIP_ERROR KeypadInputCluster::SendKeyRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t keyCode) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, KeypadInput::Commands::SendKeyRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // keyCode: cecKeyCode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), keyCode)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// MediaInput Cluster Commands -CHIP_ERROR MediaInputCluster::HideInputStatusRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaInput::Commands::HideInputStatusRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaInputCluster::RenameInputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t index, chip::CharSpan name) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaInput::Commands::RenameInputRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // index: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), index)); - // name: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), name)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaInputCluster::SelectInputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t index) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaInput::Commands::SelectInputRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // index: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), index)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaInputCluster::ShowInputStatusRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaInput::Commands::ShowInputStatusRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// MediaPlayback Cluster Commands -CHIP_ERROR MediaPlaybackCluster::FastForwardRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::FastForwardRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::NextRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::NextRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::PauseRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::PauseRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::PlayRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::PlayRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::PreviousRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::PreviousRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::RewindRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::RewindRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::SeekRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint64_t position) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::SeekRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // position: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), position)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::SkipBackwardRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::SkipBackwardRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // deltaPositionMilliseconds: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), deltaPositionMilliseconds)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::SkipForwardRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::SkipForwardRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // deltaPositionMilliseconds: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), deltaPositionMilliseconds)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::StartOverRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::StartOverRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -CHIP_ERROR MediaPlaybackCluster::StopRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, MediaPlayback::Commands::StopRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - // Command takes no arguments. - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -// TargetNavigator Cluster Commands -CHIP_ERROR TargetNavigatorCluster::NavigateTargetRequest(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint8_t target, - chip::CharSpan data) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, - TargetNavigator::Commands::NavigateTargetRequest::Id, - (app::CommandPathFlags::kEndpointIdValid) }; - - CommandSenderHandle sender( - Platform::New(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager())); - - VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // target: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), target)); - // data: charString - SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), data)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback); - - SuccessOrExit(err = mDevice->SendCommands(sender.get(), mTimeout)); - - // We have successfully sent the command, and the callback handler will be responsible to free the object, release the object - // now. - sender.release(); -exit: - return err; -} - -} // namespace Controller -} // namespace chip diff --git a/zzz_generated/tv-casting-app/zap-generated/CHIPClusters.h b/zzz_generated/tv-casting-app/zap-generated/CHIPClusters.h index 0536b398a10577..08eb57afb372b9 100644 --- a/zzz_generated/tv-casting-app/zap-generated/CHIPClusters.h +++ b/zzz_generated/tv-casting-app/zap-generated/CHIPClusters.h @@ -35,13 +35,6 @@ class DLL_EXPORT AccountLoginCluster : public ClusterBase public: AccountLoginCluster() : ClusterBase(app::Clusters::AccountLogin::Id) {} ~AccountLoginCluster() {} - - // Cluster Commands - CHIP_ERROR GetSetupPINRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan tempAccountIdentifier); - CHIP_ERROR LoginRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan tempAccountIdentifier, chip::CharSpan setupPIN); - CHIP_ERROR LogoutRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT ApplicationBasicCluster : public ClusterBase @@ -56,14 +49,6 @@ class DLL_EXPORT ApplicationLauncherCluster : public ClusterBase public: ApplicationLauncherCluster() : ClusterBase(app::Clusters::ApplicationLauncher::Id) {} ~ApplicationLauncherCluster() {} - - // Cluster Commands - CHIP_ERROR HideAppRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t catalogVendorId, chip::CharSpan applicationId); - CHIP_ERROR LaunchAppRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan data, uint16_t catalogVendorId, chip::CharSpan applicationId); - CHIP_ERROR StopAppRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t catalogVendorId, chip::CharSpan applicationId); }; class DLL_EXPORT AudioOutputCluster : public ClusterBase @@ -71,12 +56,6 @@ class DLL_EXPORT AudioOutputCluster : public ClusterBase public: AudioOutputCluster() : ClusterBase(app::Clusters::AudioOutput::Id) {} ~AudioOutputCluster() {} - - // Cluster Commands - CHIP_ERROR RenameOutputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t index, chip::CharSpan name); - CHIP_ERROR SelectOutputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t index); }; class DLL_EXPORT ChannelCluster : public ClusterBase @@ -84,14 +63,6 @@ class DLL_EXPORT ChannelCluster : public ClusterBase public: ChannelCluster() : ClusterBase(app::Clusters::Channel::Id) {} ~ChannelCluster() {} - - // Cluster Commands - CHIP_ERROR ChangeChannelByNumberRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t majorNumber, uint16_t minorNumber); - CHIP_ERROR ChangeChannelRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan match); - CHIP_ERROR SkipChannelRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t count); }; class DLL_EXPORT ContentLauncherCluster : public ClusterBase @@ -99,12 +70,6 @@ class DLL_EXPORT ContentLauncherCluster : public ClusterBase public: ContentLauncherCluster() : ClusterBase(app::Clusters::ContentLauncher::Id) {} ~ContentLauncherCluster() {} - - // Cluster Commands - CHIP_ERROR LaunchContentRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - bool autoPlay, chip::CharSpan data); - CHIP_ERROR LaunchURLRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::CharSpan contentURL, chip::CharSpan displayString, chip::CharSpan providerName); }; class DLL_EXPORT KeypadInputCluster : public ClusterBase @@ -112,9 +77,6 @@ class DLL_EXPORT KeypadInputCluster : public ClusterBase public: KeypadInputCluster() : ClusterBase(app::Clusters::KeypadInput::Id) {} ~KeypadInputCluster() {} - - // Cluster Commands - CHIP_ERROR SendKeyRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t keyCode); }; class DLL_EXPORT MediaInputCluster : public ClusterBase @@ -122,14 +84,6 @@ class DLL_EXPORT MediaInputCluster : public ClusterBase public: MediaInputCluster() : ClusterBase(app::Clusters::MediaInput::Id) {} ~MediaInputCluster() {} - - // Cluster Commands - CHIP_ERROR HideInputStatusRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR RenameInputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t index, - chip::CharSpan name); - CHIP_ERROR SelectInputRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t index); - CHIP_ERROR ShowInputStatusRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT MediaPlaybackCluster : public ClusterBase @@ -137,21 +91,6 @@ class DLL_EXPORT MediaPlaybackCluster : public ClusterBase public: MediaPlaybackCluster() : ClusterBase(app::Clusters::MediaPlayback::Id) {} ~MediaPlaybackCluster() {} - - // Cluster Commands - CHIP_ERROR FastForwardRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR NextRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR PauseRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR PlayRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR PreviousRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR RewindRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR SeekRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint64_t position); - CHIP_ERROR SkipBackwardRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint64_t deltaPositionMilliseconds); - CHIP_ERROR SkipForwardRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint64_t deltaPositionMilliseconds); - CHIP_ERROR StartOverRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR StopRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); }; class DLL_EXPORT TargetNavigatorCluster : public ClusterBase @@ -159,10 +98,6 @@ class DLL_EXPORT TargetNavigatorCluster : public ClusterBase public: TargetNavigatorCluster() : ClusterBase(app::Clusters::TargetNavigator::Id) {} ~TargetNavigatorCluster() {} - - // Cluster Commands - CHIP_ERROR NavigateTargetRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t target, chip::CharSpan data); }; } // namespace Controller diff --git a/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp index 05d8a793840a8a..c4691a36c9a2b5 100644 --- a/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/tv-casting-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace BarrierControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -172,10 +164,6 @@ namespace Binding { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -222,10 +210,6 @@ namespace ColorControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -380,10 +364,6 @@ namespace DiagnosticLogs { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -421,10 +401,6 @@ namespace DoorLock { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -555,10 +531,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -615,10 +587,6 @@ namespace Groups { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -701,10 +669,6 @@ namespace IasZone { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -742,10 +706,6 @@ namespace Identify { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -792,10 +752,6 @@ namespace LevelControl { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -896,10 +852,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -984,10 +936,6 @@ namespace OtaSoftwareUpdateProvider { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1045,10 +993,6 @@ namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1104,10 +1048,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1221,10 +1161,6 @@ namespace Scenes { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1316,10 +1252,6 @@ namespace TestCluster { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -1439,24 +1371,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip diff --git a/zzz_generated/window-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/window-app/zap-generated/CHIPClientCallbacks.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/window-app/zap-generated/CHIPClientCallbacks.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/window-app/zap-generated/CHIPClientCallbacks.h b/zzz_generated/window-app/zap-generated/CHIPClientCallbacks.h index 4ad6af42ab6e54..fbed9690c1f3da 100644 --- a/zzz_generated/window-app/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/window-app/zap-generated/CHIPClientCallbacks.h @@ -16,5 +16,3 @@ */ // THIS FILE IS GENERATED BY ZAP - -// List specific responses diff --git a/zzz_generated/window-app/zap-generated/CHIPClusters.cpp b/zzz_generated/window-app/zap-generated/CHIPClusters.cpp deleted file mode 100644 index fbed9690c1f3da..00000000000000 --- a/zzz_generated/window-app/zap-generated/CHIPClusters.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP diff --git a/zzz_generated/window-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/window-app/zap-generated/IMClusterCommandHandler.cpp index f5408c384f2acb..f36890cc82c9ab 100644 --- a/zzz_generated/window-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/window-app/zap-generated/IMClusterCommandHandler.cpp @@ -45,10 +45,6 @@ namespace AdministratorCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -122,10 +118,6 @@ namespace GeneralCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -182,10 +174,6 @@ namespace Identify { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -241,10 +229,6 @@ namespace NetworkCommissioning { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -329,10 +313,6 @@ namespace OperationalCredentials { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -446,10 +426,6 @@ namespace WindowCovering { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) { - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. CHIP_ERROR TLVError = CHIP_NO_ERROR; bool wasHandled = false; { @@ -572,24 +548,5 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: Compatibility::ResetEmberAfObjects(); } -void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, - CommandSender * apCommandObj) -{ - Compatibility::SetupEmberAfCommandSender(apCommandObj, aCommandPath); - - TLV::TLVType dataTlvType; - SuccessOrExit(aReader.EnterContainer(dataTlvType)); - switch (aCommandPath.mClusterId) - { - default: - ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); - break; - } - -exit: - aReader.ExitContainer(dataTlvType); - Compatibility::ResetEmberAfObjects(); -} - } // namespace app } // namespace chip