From e981f2c92898bbca5bb21e9d04962e1f8155eafa Mon Sep 17 00:00:00 2001 From: Song Guo Date: Mon, 19 Apr 2021 15:53:38 +0800 Subject: [PATCH] Run Codegen --- .../gen/IMClusterCommandHandler.cpp | 4 + .../all-clusters-common/gen/endpoint_config.h | 26 +- .../gen/IMClusterCommandHandler.cpp | 4 + .../chip-tool/gen/IMClusterCommandHandler.cpp | 4 + .../gen/IMClusterCommandHandler.cpp | 4 + .../gen/IMClusterCommandHandler.cpp | 4 + .../main/gen/IMClusterCommandHandler.cpp | 4 + .../tv-common/gen/IMClusterCommandHandler.cpp | 4 + .../common/gen/IMClusterCommandHandler.cpp | 4 + src/controller/CHIPClusters.cpp | 1493 ++++++----------- .../python/gen/IMClusterCommandHandler.cpp | 4 + .../CHIP/gen/IMClusterCommandHandler.cpp | 4 + 12 files changed, 605 insertions(+), 954 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp b/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp index 5397b7a22e3589..ec977effa14080 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp @@ -7657,6 +7657,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId, aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { case ZCL_BARRIER_CONTROL_CLUSTER_ID: @@ -7711,7 +7713,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId); break; } +exit: Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); } } // namespace app diff --git a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h index ec94fcadafead2..c764fd86134349 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h @@ -518,10 +518,10 @@ #define GENERATED_ATTRIBUTE_COUNT 133 #define GENERATED_ATTRIBUTES \ { \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Descriptor (server): cluster revision */ \ - { 0x0000, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(0) }, /* Descriptor (server): device list */ \ + { 0x0000, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(0) }, /* Descriptor (server): device list */ \ { 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(254) }, /* Descriptor (server): server list */ \ { 0x0002, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(508) }, /* Descriptor (server): client list */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Descriptor (server): cluster revision */ \ { 0x0003, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(762) }, /* Descriptor (server): parts list */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), \ ZAP_SIMPLE_DEFAULT(3) }, /* Basic (server): cluster revision */ \ @@ -544,18 +544,18 @@ { 0x0009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(SINGLETON), \ ZAP_LONG_DEFAULTS_INDEX(1192) }, /* Basic (server): SoftwareVersion */ \ { 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), \ - ZAP_LONG_DEFAULTS_INDEX(1196) }, /* Basic (server): SoftwareVersionString */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* General Commissioning (server): cluster revision */ \ + ZAP_LONG_DEFAULTS_INDEX(1196) }, /* Basic (server): SoftwareVersionString */ \ { 0x0000, ZAP_TYPE(OCTET_STRING), 8, 0, \ ZAP_LONG_DEFAULTS_INDEX(1260) }, /* General Commissioning (server): FabricId */ \ { 0x0001, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), \ ZAP_LONG_DEFAULTS_INDEX(1268) }, /* General Commissioning (server): Breadcrumb */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* General Commissioning (server): cluster revision */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Network Commissioning (server): cluster revision */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Binding (server): cluster revision */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Group Key Management (server): cluster revision */ \ { 0x0000, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(1276) }, /* Group Key Management (server): groups */ \ { 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(1530) }, /* Group Key Management (server): group keys */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(2) }, /* Identify (server): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Group Key Management (server): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(2) }, /* Identify (server): cluster revision */ \ { 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), \ ZAP_SIMPLE_DEFAULT(0x0000) }, /* Identify (server): identify time */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* Groups (server): cluster revision */ \ @@ -570,10 +570,10 @@ { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* On/off (server): on/off */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* Level Control (server): cluster revision */ \ { 0x0000, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* Level Control (server): current level */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Descriptor (server): cluster revision */ \ { 0x0000, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(1784) }, /* Descriptor (server): device list */ \ { 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(2038) }, /* Descriptor (server): server list */ \ { 0x0002, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(2292) }, /* Descriptor (server): client list */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Descriptor (server): cluster revision */ \ { 0x0003, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(2546) }, /* Descriptor (server): parts list */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, \ ZAP_SIMPLE_DEFAULT(0x0001) }, /* OTA Software Update Server (server): cluster revision */ \ @@ -675,15 +675,15 @@ { 0x0001, ZAP_TYPE(ENUM16), 2, 0, ZAP_EMPTY_DEFAULT() }, /* IAS Zone (server): zone type */ \ { 0x0002, ZAP_TYPE(BITMAP16), 2, 0, ZAP_SIMPLE_DEFAULT(0x0000) }, /* IAS Zone (server): zone status */ \ { 0x0010, ZAP_TYPE(IEEE_ADDRESS), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), \ - ZAP_LONG_DEFAULTS_INDEX(3054) }, /* IAS Zone (server): IAS CIE address */ \ - { 0x0011, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0xff) }, /* IAS Zone (server): Zone ID */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Low Power (server): cluster revision */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Application Basic (server): cluster revision */ \ + ZAP_LONG_DEFAULTS_INDEX(3054) }, /* IAS Zone (server): IAS CIE address */ \ + { 0x0011, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0xff) }, /* IAS Zone (server): Zone ID */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Low Power (server): cluster revision */ \ { 0x0000, ZAP_TYPE(CHAR_STRING), 32, 0, ZAP_LONG_DEFAULTS_INDEX(3062) }, /* Application Basic (server): vendor name */ \ { 0x0001, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): vendor id */ \ { 0x0002, ZAP_TYPE(CHAR_STRING), 32, 0, \ - ZAP_LONG_DEFAULTS_INDEX(3094) }, /* Application Basic (server): application name */ \ - { 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): product id */ \ + ZAP_LONG_DEFAULTS_INDEX(3094) }, /* Application Basic (server): application name */ \ + { 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): product id */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Application Basic (server): cluster revision */ \ { 0x0005, ZAP_TYPE(CHAR_STRING), 32, 0, \ ZAP_LONG_DEFAULTS_INDEX(3126) }, /* Application Basic (server): application id */ \ { 0x0006, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): catalog vendor id */ \ diff --git a/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp b/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp index 517ede632664ad..7f05185ca03577 100644 --- a/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp +++ b/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp @@ -1771,6 +1771,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId, aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { case ZCL_LEVEL_CONTROL_CLUSTER_ID: @@ -1789,7 +1791,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId); break; } +exit: Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); } } // namespace app diff --git a/examples/chip-tool/gen/IMClusterCommandHandler.cpp b/examples/chip-tool/gen/IMClusterCommandHandler.cpp index cfe0c3769017b3..aea0bf951e06cd 100644 --- a/examples/chip-tool/gen/IMClusterCommandHandler.cpp +++ b/examples/chip-tool/gen/IMClusterCommandHandler.cpp @@ -4502,6 +4502,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId, aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { default: @@ -4511,7 +4513,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId); break; } +exit: Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); } } // namespace app diff --git a/examples/lighting-app/lighting-common/gen/IMClusterCommandHandler.cpp b/examples/lighting-app/lighting-common/gen/IMClusterCommandHandler.cpp index 517ede632664ad..7f05185ca03577 100644 --- a/examples/lighting-app/lighting-common/gen/IMClusterCommandHandler.cpp +++ b/examples/lighting-app/lighting-common/gen/IMClusterCommandHandler.cpp @@ -1771,6 +1771,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId, aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { case ZCL_LEVEL_CONTROL_CLUSTER_ID: @@ -1789,7 +1791,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId); break; } +exit: Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); } } // namespace app diff --git a/examples/lock-app/lock-common/gen/IMClusterCommandHandler.cpp b/examples/lock-app/lock-common/gen/IMClusterCommandHandler.cpp index e8cc481cfb81d5..37abf4728b12be 100644 --- a/examples/lock-app/lock-common/gen/IMClusterCommandHandler.cpp +++ b/examples/lock-app/lock-common/gen/IMClusterCommandHandler.cpp @@ -1036,6 +1036,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId, aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: @@ -1051,7 +1053,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId); break; } +exit: Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); } } // namespace app diff --git a/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp b/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp index ae9c40556bf518..7a33d53c25e967 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp @@ -998,6 +998,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId, aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: @@ -1010,7 +1012,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId); break; } +exit: Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); } } // namespace app diff --git a/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp b/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp index ddc32c2ef2adfe..bccccf96e6eb24 100644 --- a/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp +++ b/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp @@ -6920,6 +6920,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId, aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { case ZCL_BARRIER_CONTROL_CLUSTER_ID: @@ -6977,7 +6979,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId); break; } +exit: Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); } } // namespace app diff --git a/examples/window-app/common/gen/IMClusterCommandHandler.cpp b/examples/window-app/common/gen/IMClusterCommandHandler.cpp index c94cbd2bc8be59..1d3de1ea616a9a 100644 --- a/examples/window-app/common/gen/IMClusterCommandHandler.cpp +++ b/examples/window-app/common/gen/IMClusterCommandHandler.cpp @@ -353,6 +353,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId, aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { case ZCL_WINDOW_COVERING_CLUSTER_ID: @@ -365,7 +367,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId); break; } +exit: Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); } } // namespace app diff --git a/src/controller/CHIPClusters.cpp b/src/controller/CHIPClusters.cpp index 53e4da0dfd63ac..0b6f7dbe1cd0a8 100644 --- a/src/controller/CHIPClusters.cpp +++ b/src/controller/CHIPClusters.cpp @@ -116,18 +116,14 @@ CHIP_ERROR BarrierControlCluster::BarrierControlGoToPercent(Callback::Cancelable (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // percentOpen: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), percentOpen)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), percentOpen)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -150,16 +146,11 @@ CHIP_ERROR BarrierControlCluster::BarrierControlStop(Callback::Cancelable * onSu (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -229,16 +220,11 @@ CHIP_ERROR BasicCluster::MfgSpecificPing(Callback::Cancelable * onSuccessCallbac (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -375,24 +361,20 @@ CHIP_ERROR BindingCluster::Bind(Callback::Cancelable * onSuccessCallback, Callba (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // nodeId: nodeId - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), nodeId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), nodeId)); // groupId: groupId - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); // endpointId: endpointId - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), endpointId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), endpointId)); // clusterId: clusterId - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), clusterId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), clusterId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -416,24 +398,20 @@ CHIP_ERROR BindingCluster::Unbind(Callback::Cancelable * onSuccessCallback, Call (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // nodeId: nodeId - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), nodeId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), nodeId)); // groupId: groupId - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); // endpointId: endpointId - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), endpointId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), endpointId)); // clusterId: clusterId - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), clusterId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), clusterId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -472,24 +450,20 @@ CHIP_ERROR ColorControlCluster::MoveColor(Callback::Cancelable * onSuccessCallba (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // rateX: int16s - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), rateX)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rateX)); // rateY: int16s - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), rateY)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rateY)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -514,28 +488,24 @@ CHIP_ERROR ColorControlCluster::MoveColorTemperature(Callback::Cancelable * onSu (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // moveMode: hueMoveMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), moveMode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); // rate: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), rate)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rate)); // colorTemperatureMinimum: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMinimum)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMinimum)); // colorTemperatureMaximum: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMaximum)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMaximum)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -558,24 +528,20 @@ CHIP_ERROR ColorControlCluster::MoveHue(Callback::Cancelable * onSuccessCallback (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // moveMode: hueMoveMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), moveMode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); // rate: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), rate)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rate)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -598,24 +564,20 @@ CHIP_ERROR ColorControlCluster::MoveSaturation(Callback::Cancelable * onSuccessC (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // moveMode: saturationMoveMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), moveMode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); // rate: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), rate)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rate)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -639,26 +601,22 @@ CHIP_ERROR ColorControlCluster::MoveToColor(Callback::Cancelable * onSuccessCall (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // colorX: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), colorX)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorX)); // colorY: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), colorY)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorY)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -682,24 +640,20 @@ CHIP_ERROR ColorControlCluster::MoveToColorTemperature(Callback::Cancelable * on (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // colorTemperature: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), colorTemperature)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperature)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -723,26 +677,22 @@ CHIP_ERROR ColorControlCluster::MoveToHue(Callback::Cancelable * onSuccessCallba (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // hue: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), hue)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), hue)); // direction: hueDirection - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), direction)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), direction)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -766,26 +716,22 @@ CHIP_ERROR ColorControlCluster::MoveToHueAndSaturation(Callback::Cancelable * on (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // hue: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), hue)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), hue)); // saturation: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), saturation)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -809,24 +755,20 @@ CHIP_ERROR ColorControlCluster::MoveToSaturation(Callback::Cancelable * onSucces (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // saturation: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), saturation)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -850,26 +792,22 @@ CHIP_ERROR ColorControlCluster::StepColor(Callback::Cancelable * onSuccessCallba (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // stepX: int16s - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepX)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepX)); // stepY: int16s - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepY)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepY)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -894,30 +832,26 @@ CHIP_ERROR ColorControlCluster::StepColorTemperature(Callback::Cancelable * onSu (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // stepMode: hueStepMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepMode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); // stepSize: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepSize)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // colorTemperatureMinimum: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMinimum)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMinimum)); // colorTemperatureMaximum: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMaximum)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), colorTemperatureMaximum)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -942,26 +876,22 @@ CHIP_ERROR ColorControlCluster::StepHue(Callback::Cancelable * onSuccessCallback (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // stepMode: hueStepMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepMode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); // stepSize: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepSize)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); // transitionTime: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -985,26 +915,22 @@ CHIP_ERROR ColorControlCluster::StepSaturation(Callback::Cancelable * onSuccessC (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // stepMode: saturationStepMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepMode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); // stepSize: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepSize)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); // transitionTime: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -1027,20 +953,16 @@ CHIP_ERROR ColorControlCluster::StopMoveStep(Callback::Cancelable * onSuccessCal (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // optionsMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); // optionsOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -1714,16 +1636,11 @@ CHIP_ERROR DoorLockCluster::ClearAllPins(Callback::Cancelable * onSuccessCallbac (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -1744,16 +1661,11 @@ CHIP_ERROR DoorLockCluster::ClearAllRfids(Callback::Cancelable * onSuccessCallba (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -1775,18 +1687,14 @@ CHIP_ERROR DoorLockCluster::ClearHolidaySchedule(Callback::Cancelable * onSucces (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // scheduleId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), scheduleId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -1808,18 +1716,14 @@ CHIP_ERROR DoorLockCluster::ClearPin(Callback::Cancelable * onSuccessCallback, C (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -1841,18 +1745,14 @@ CHIP_ERROR DoorLockCluster::ClearRfid(Callback::Cancelable * onSuccessCallback, (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -1874,20 +1774,16 @@ CHIP_ERROR DoorLockCluster::ClearWeekdaySchedule(Callback::Cancelable * onSucces (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // scheduleId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), scheduleId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId)); // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -1910,20 +1806,16 @@ CHIP_ERROR DoorLockCluster::ClearYeardaySchedule(Callback::Cancelable * onSucces (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // scheduleId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), scheduleId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId)); // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -1946,18 +1838,14 @@ CHIP_ERROR DoorLockCluster::GetHolidaySchedule(Callback::Cancelable * onSuccessC (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // scheduleId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), scheduleId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -1979,18 +1867,14 @@ CHIP_ERROR DoorLockCluster::GetLogRecord(Callback::Cancelable * onSuccessCallbac (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // logIndex: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), logIndex)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), logIndex)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2012,18 +1896,14 @@ CHIP_ERROR DoorLockCluster::GetPin(Callback::Cancelable * onSuccessCallback, Cal (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2045,18 +1925,14 @@ CHIP_ERROR DoorLockCluster::GetRfid(Callback::Cancelable * onSuccessCallback, Ca (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2078,18 +1954,14 @@ CHIP_ERROR DoorLockCluster::GetUserType(Callback::Cancelable * onSuccessCallback (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2111,20 +1983,16 @@ CHIP_ERROR DoorLockCluster::GetWeekdaySchedule(Callback::Cancelable * onSuccessC (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // scheduleId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), scheduleId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId)); // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2147,20 +2015,16 @@ CHIP_ERROR DoorLockCluster::GetYeardaySchedule(Callback::Cancelable * onSuccessC (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // scheduleId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), scheduleId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId)); // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2183,18 +2047,14 @@ CHIP_ERROR DoorLockCluster::LockDoor(Callback::Cancelable * onSuccessCallback, C (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // pin: charString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), pin)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), pin)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2217,24 +2077,20 @@ CHIP_ERROR DoorLockCluster::SetHolidaySchedule(Callback::Cancelable * onSuccessC (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // scheduleId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), scheduleId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId)); // localStartTime: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), localStartTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), localStartTime)); // localEndTime: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), localEndTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), localEndTime)); // operatingModeDuringHoliday: enum8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), operatingModeDuringHoliday)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), operatingModeDuringHoliday)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2257,24 +2113,20 @@ CHIP_ERROR DoorLockCluster::SetPin(Callback::Cancelable * onSuccessCallback, Cal (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); // userStatus: doorLockUserStatus - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userStatus)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userStatus)); // userType: doorLockUserType - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userType)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userType)); // pin: charString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), pin)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), pin)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2297,24 +2149,20 @@ CHIP_ERROR DoorLockCluster::SetRfid(Callback::Cancelable * onSuccessCallback, Ca (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); // userStatus: doorLockUserStatus - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userStatus)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userStatus)); // userType: doorLockUserType - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userType)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userType)); // id: charString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), id)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), id)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2337,20 +2185,16 @@ CHIP_ERROR DoorLockCluster::SetUserType(Callback::Cancelable * onSuccessCallback (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); // userType: doorLockUserType - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userType)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userType)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2373,30 +2217,26 @@ CHIP_ERROR DoorLockCluster::SetWeekdaySchedule(Callback::Cancelable * onSuccessC (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // scheduleId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), scheduleId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId)); // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); // daysMask: doorLockDayOfWeek - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), daysMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), daysMask)); // startHour: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), startHour)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), startHour)); // startMinute: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), startMinute)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), startMinute)); // endHour: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), endHour)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), endHour)); // endMinute: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), endMinute)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), endMinute)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2419,24 +2259,20 @@ CHIP_ERROR DoorLockCluster::SetYeardaySchedule(Callback::Cancelable * onSuccessC (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // scheduleId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), scheduleId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), scheduleId)); // userId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), userId)); // localStartTime: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), localStartTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), localStartTime)); // localEndTime: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), localEndTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), localEndTime)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2459,18 +2295,14 @@ CHIP_ERROR DoorLockCluster::UnlockDoor(Callback::Cancelable * onSuccessCallback, (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // pin: charString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), pin)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), pin)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2492,20 +2324,16 @@ CHIP_ERROR DoorLockCluster::UnlockWithTimeout(Callback::Cancelable * onSuccessCa (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // timeoutInSeconds: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutInSeconds)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutInSeconds)); // pin: charString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), pin)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), pin)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2584,22 +2412,18 @@ CHIP_ERROR GeneralCommissioningCluster::ArmFailSafe(Callback::Cancelable * onSuc (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // expiryLengthSeconds: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), expiryLengthSeconds)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), expiryLengthSeconds)); // breadcrumb: int64u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2622,16 +2446,11 @@ CHIP_ERROR GeneralCommissioningCluster::CommissioningComplete(Callback::Cancelab (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2654,24 +2473,20 @@ CHIP_ERROR GeneralCommissioningCluster::SetFabric(Callback::Cancelable * onSucce (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // fabricId: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), fabricId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), fabricId)); // fabricSecret: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), fabricSecret)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), fabricSecret)); // breadcrumb: int64u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2768,20 +2583,16 @@ CHIP_ERROR GroupsCluster::AddGroup(Callback::Cancelable * onSuccessCallback, Cal (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); // groupName: charString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupName)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupName)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2803,20 +2614,16 @@ CHIP_ERROR GroupsCluster::AddGroupIfIdentifying(Callback::Cancelable * onSuccess (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); // groupName: charString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupName)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupName)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2839,20 +2646,16 @@ CHIP_ERROR GroupsCluster::GetGroupMembership(Callback::Cancelable * onSuccessCal (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupCount: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupCount)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupCount)); // groupList: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupList)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupList)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2874,16 +2677,11 @@ CHIP_ERROR GroupsCluster::RemoveAllGroups(Callback::Cancelable * onSuccessCallba (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2905,18 +2703,14 @@ CHIP_ERROR GroupsCluster::RemoveGroup(Callback::Cancelable * onSuccessCallback, (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -2938,18 +2732,14 @@ CHIP_ERROR GroupsCluster::ViewGroup(Callback::Cancelable * onSuccessCallback, Ca (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3057,18 +2847,14 @@ CHIP_ERROR IdentifyCluster::Identify(Callback::Cancelable * onSuccessCallback, C (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // identifyTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), identifyTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), identifyTime)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3089,16 +2875,11 @@ CHIP_ERROR IdentifyCluster::IdentifyQuery(Callback::Cancelable * onSuccessCallba (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3152,24 +2933,20 @@ CHIP_ERROR LevelControlCluster::Move(Callback::Cancelable * onSuccessCallback, C (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // moveMode: moveMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), moveMode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); // rate: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), rate)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rate)); // optionMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); // optionOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3192,24 +2969,20 @@ CHIP_ERROR LevelControlCluster::MoveToLevel(Callback::Cancelable * onSuccessCall (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // level: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), level)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), level)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // optionMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); // optionOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3233,20 +3006,16 @@ CHIP_ERROR LevelControlCluster::MoveToLevelWithOnOff(Callback::Cancelable * onSu (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // level: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), level)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), level)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3269,20 +3038,16 @@ CHIP_ERROR LevelControlCluster::MoveWithOnOff(Callback::Cancelable * onSuccessCa (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // moveMode: moveMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), moveMode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); // rate: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), rate)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3305,26 +3070,22 @@ CHIP_ERROR LevelControlCluster::Step(Callback::Cancelable * onSuccessCallback, C (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // stepMode: stepMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepMode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); // stepSize: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepSize)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // optionMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); // optionOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3347,22 +3108,18 @@ CHIP_ERROR LevelControlCluster::StepWithOnOff(Callback::Cancelable * onSuccessCa (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // stepMode: stepMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepMode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); // stepSize: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), stepSize)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3385,20 +3142,16 @@ CHIP_ERROR LevelControlCluster::Stop(Callback::Cancelable * onSuccessCallback, C (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // optionMask: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionMask)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionMask)); // optionOverride: bitmap8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), optionOverride)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), optionOverride)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3419,16 +3172,11 @@ CHIP_ERROR LevelControlCluster::StopWithOnOff(Callback::Cancelable * onSuccessCa (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3489,16 +3237,11 @@ CHIP_ERROR LowPowerCluster::Sleep(Callback::Cancelable * onSuccessCallback, Call (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3537,22 +3280,18 @@ CHIP_ERROR NetworkCommissioningCluster::AddThreadNetwork(Callback::Cancelable * (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // operationalDataset: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), operationalDataset)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), operationalDataset)); // breadcrumb: int64u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3576,24 +3315,20 @@ CHIP_ERROR NetworkCommissioningCluster::AddWiFiNetwork(Callback::Cancelable * on (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // ssid: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), ssid)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), ssid)); // credentials: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), credentials)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), credentials)); // breadcrumb: int64u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3617,22 +3352,18 @@ CHIP_ERROR NetworkCommissioningCluster::DisableNetwork(Callback::Cancelable * on (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // networkID: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), networkID)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), networkID)); // breadcrumb: int64u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3656,22 +3387,18 @@ CHIP_ERROR NetworkCommissioningCluster::EnableNetwork(Callback::Cancelable * onS (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // networkID: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), networkID)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), networkID)); // breadcrumb: int64u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3695,18 +3422,14 @@ CHIP_ERROR NetworkCommissioningCluster::GetLastNetworkCommissioningResult(Callba (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3730,22 +3453,18 @@ CHIP_ERROR NetworkCommissioningCluster::RemoveNetwork(Callback::Cancelable * onS (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // networkID: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), networkID)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), networkID)); // breadcrumb: int64u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3769,22 +3488,18 @@ CHIP_ERROR NetworkCommissioningCluster::ScanNetworks(Callback::Cancelable * onSu (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // ssid: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), ssid)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), ssid)); // breadcrumb: int64u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3809,22 +3524,18 @@ CHIP_ERROR NetworkCommissioningCluster::UpdateThreadNetwork(Callback::Cancelable (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // operationalDataset: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), operationalDataset)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), operationalDataset)); // breadcrumb: int64u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3848,24 +3559,20 @@ CHIP_ERROR NetworkCommissioningCluster::UpdateWiFiNetwork(Callback::Cancelable * (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // ssid: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), ssid)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), ssid)); // credentials: octetString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), credentials)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), credentials)); // breadcrumb: int64u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), breadcrumb)); // timeoutMs: int32u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), timeoutMs)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3904,16 +3611,11 @@ CHIP_ERROR OnOffCluster::Off(Callback::Cancelable * onSuccessCallback, Callback: (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3934,16 +3636,11 @@ CHIP_ERROR OnOffCluster::On(Callback::Cancelable * onSuccessCallback, Callback:: (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -3964,16 +3661,11 @@ CHIP_ERROR OnOffCluster::Toggle(Callback::Cancelable * onSuccessCallback, Callba (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4033,30 +3725,26 @@ CHIP_ERROR ScenesCluster::AddScene(Callback::Cancelable * onSuccessCallback, Cal (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); // sceneId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), sceneId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); // sceneName: charString - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), sceneName)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneName)); // clusterId: clusterId - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), clusterId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), clusterId)); // length: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), length)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), length)); // value: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), value)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), value)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4079,18 +3767,14 @@ CHIP_ERROR ScenesCluster::GetSceneMembership(Callback::Cancelable * onSuccessCal (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4112,22 +3796,18 @@ CHIP_ERROR ScenesCluster::RecallScene(Callback::Cancelable * onSuccessCallback, (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); // sceneId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), sceneId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); // transitionTime: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4150,18 +3830,14 @@ CHIP_ERROR ScenesCluster::RemoveAllScenes(Callback::Cancelable * onSuccessCallba (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4183,20 +3859,16 @@ CHIP_ERROR ScenesCluster::RemoveScene(Callback::Cancelable * onSuccessCallback, (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); // sceneId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), sceneId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4218,20 +3890,16 @@ CHIP_ERROR ScenesCluster::StoreScene(Callback::Cancelable * onSuccessCallback, C (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); // sceneId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), sceneId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4253,20 +3921,16 @@ CHIP_ERROR ScenesCluster::ViewScene(Callback::Cancelable * onSuccessCallback, Ca (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // groupId: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), groupId)); // sceneId: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), sceneId)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), sceneId)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4401,16 +4065,11 @@ CHIP_ERROR ThermostatCluster::ClearWeeklySchedule(Callback::Cancelable * onSucce (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4431,16 +4090,11 @@ CHIP_ERROR ThermostatCluster::GetRelayStatusLog(Callback::Cancelable * onSuccess (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4462,20 +4116,16 @@ CHIP_ERROR ThermostatCluster::GetWeeklySchedule(Callback::Cancelable * onSuccess (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // daysToReturn: dayOfWeek - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), daysToReturn)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), daysToReturn)); // modeToReturn: modeForSequence - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), modeToReturn)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), modeToReturn)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4499,24 +4149,20 @@ CHIP_ERROR ThermostatCluster::SetWeeklySchedule(Callback::Cancelable * onSuccess (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // numberOfTransitionsForSequence: enum8 - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), numberOfTransitionsForSequence)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), numberOfTransitionsForSequence)); // dayOfWeekForSequence: dayOfWeek - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), dayOfWeekForSequence)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), dayOfWeekForSequence)); // modeForSequence: modeForSequence - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), modeForSequence)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), modeForSequence)); // payload: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), payload)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), payload)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4539,20 +4185,16 @@ CHIP_ERROR ThermostatCluster::SetpointRaiseLower(Callback::Cancelable * onSucces (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // mode: setpointAdjustMode - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), mode)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), mode)); // amount: int8s - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), amount)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), amount)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4680,16 +4322,11 @@ CHIP_ERROR WindowCoveringCluster::WindowCoveringDownClose(Callback::Cancelable * (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4712,18 +4349,14 @@ CHIP_ERROR WindowCoveringCluster::WindowCoveringGoToLiftPercentage(Callback::Can (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // percentageLiftValue: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), percentageLiftValue)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), percentageLiftValue)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4746,18 +4379,14 @@ CHIP_ERROR WindowCoveringCluster::WindowCoveringGoToLiftValue(Callback::Cancelab (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); - - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // liftValue: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), liftValue)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), liftValue)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4781,18 +4410,14 @@ CHIP_ERROR WindowCoveringCluster::WindowCoveringGoToTiltPercentage(Callback::Can (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // percentageTiltValue: int8u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), percentageTiltValue)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), percentageTiltValue)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4815,18 +4440,14 @@ CHIP_ERROR WindowCoveringCluster::WindowCoveringGoToTiltValue(Callback::Cancelab (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); - uint8_t argSeqNumber = 0; + TLV::TLVWriter * writer = ZCLcommand->GetCommandDataElementTLVWriter(); + uint8_t argSeqNumber = 0; // tiltValue: int16u - ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), tiltValue)); + ReturnErrorOnFailure(writer->Put(TLV::ContextTag(argSeqNumber++), tiltValue)); - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4849,16 +4470,11 @@ CHIP_ERROR WindowCoveringCluster::WindowCoveringStop(Callback::Cancelable * onSu (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else @@ -4880,16 +4496,11 @@ CHIP_ERROR WindowCoveringCluster::WindowCoveringUpOpen(Callback::Cancelable * on (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); - - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); + ReturnErrorOnFailure(ZCLcommand->PrepareCommand(&cmdParams)); // Command takes no arguments. - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); + ReturnErrorOnFailure(ZCLcommand->FinishCommand()); return mDevice->SendCommands(); #else diff --git a/src/controller/python/gen/IMClusterCommandHandler.cpp b/src/controller/python/gen/IMClusterCommandHandler.cpp index 574aeb84b0d42f..8715b564b1031f 100644 --- a/src/controller/python/gen/IMClusterCommandHandler.cpp +++ b/src/controller/python/gen/IMClusterCommandHandler.cpp @@ -3490,6 +3490,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId, aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { default: @@ -3499,7 +3501,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId); break; } +exit: Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); } } // namespace app diff --git a/src/darwin/Framework/CHIP/gen/IMClusterCommandHandler.cpp b/src/darwin/Framework/CHIP/gen/IMClusterCommandHandler.cpp index 96a8be3f1c5de1..7185b0730c1374 100644 --- a/src/darwin/Framework/CHIP/gen/IMClusterCommandHandler.cpp +++ b/src/darwin/Framework/CHIP/gen/IMClusterCommandHandler.cpp @@ -4217,6 +4217,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId, aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { default: @@ -4226,7 +4228,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId); break; } +exit: Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); } } // namespace app