diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index f788cd00658130..629f086e63e0c3 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -14220,6 +14220,54 @@ "source": "client", "incoming": 1, "outgoing": 0 + }, + { + "name": "TestStructArgumentRequest", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "TestNestedStructArgumentRequest", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "TestListStructArgumentRequest", + "code": 9, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "TestListInt8UArgumentRequest", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "TestNestedStructListgumentRequest", + "code": 11, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "TestListNestedStructListInt8UArgumentRequest", + "code": 12, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 } ], "attributes": [ diff --git a/src/app/clusters/test-cluster-server/test-cluster-server.cpp b/src/app/clusters/test-cluster-server/test-cluster-server.cpp index 53c5eca918a37e..22311c1b4fbc10 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -269,6 +270,123 @@ bool emberAfTestClusterClusterTestAddArgumentsCallback(CommandHandler * apComman return true; } +bool emberAfTestClusterClusterTestStructArgumentRequestCallback( + app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, + const Commands::TestStructArgumentRequest::DecodableType & commandData) +{ + emberAfSendImmediateDefaultResponse(commandData.arg1.b ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); + return true; +} + +bool emberAfTestClusterClusterTestNestedStructArgumentRequestCallback( + app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, + const Commands::TestNestedStructArgumentRequest::DecodableType & commandData) +{ + emberAfSendImmediateDefaultResponse(commandData.arg1.c.b ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); + return true; +} + +bool emberAfTestClusterClusterTestListStructArgumentRequestCallback( + app::CommandHandler * commandObj, app::ConcreteCommandPath const & commandPath, + Commands::TestListStructArgumentRequest::DecodableType const & commandData) +{ + bool shouldReturnTrue = true; + + auto structIterator = commandData.arg1.begin(); + while (structIterator.Next()) + { + auto & structValue = structIterator.GetValue(); + shouldReturnTrue = shouldReturnTrue && structValue.b; + } + + if (CHIP_NO_ERROR != structIterator.GetStatus()) + { + shouldReturnTrue = false; + } + + emberAfSendImmediateDefaultResponse(shouldReturnTrue ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); + return true; +} + +bool emberAfTestClusterClusterTestListInt8UArgumentRequestCallback( + app::CommandHandler * commandObj, app::ConcreteCommandPath const & commandPath, + Commands::TestListInt8UArgumentRequest::DecodableType const & commandData) +{ + bool shouldReturnTrue = true; + + auto uint8Iterator = commandData.arg1.begin(); + while (uint8Iterator.Next()) + { + auto & value = uint8Iterator.GetValue(); + shouldReturnTrue = shouldReturnTrue && (value != 0); + } + + if (CHIP_NO_ERROR != uint8Iterator.GetStatus()) + { + shouldReturnTrue = false; + } + + emberAfSendImmediateDefaultResponse(shouldReturnTrue ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); + return true; +} + +bool emberAfTestClusterClusterTestNestedStructListArgumentRequestCallback( + app::CommandHandler * commandObj, app::ConcreteCommandPath const & commandPath, + Commands::TestNestedStructListArgumentRequest::DecodableType const & commandData) +{ + bool shouldReturnTrue = commandData.arg1.c.b; + + auto structIterator = commandData.arg1.d.begin(); + while (structIterator.Next()) + { + auto & structValue = structIterator.GetValue(); + shouldReturnTrue = shouldReturnTrue && structValue.b; + } + + if (CHIP_NO_ERROR != structIterator.GetStatus()) + { + shouldReturnTrue = false; + } + + emberAfSendImmediateDefaultResponse(shouldReturnTrue ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); + return true; +} + +bool emberAfTestClusterClusterTestListNestedStructListArgumentRequestCallback( + app::CommandHandler * commandObj, app::ConcreteCommandPath const & commandPath, + Commands::TestListNestedStructListArgumentRequest::DecodableType const & commandData) +{ + bool shouldReturnTrue = true; + + auto structIterator = commandData.arg1.begin(); + while (structIterator.Next()) + { + auto & structValue = structIterator.GetValue(); + shouldReturnTrue = shouldReturnTrue && structValue.c.b; + + auto subStructIterator = structValue.d.begin(); + while (subStructIterator.Next()) + { + auto & subStructValue = subStructIterator.GetValue(); + shouldReturnTrue = shouldReturnTrue && subStructValue.b; + } + + if (CHIP_NO_ERROR != subStructIterator.GetStatus()) + { + shouldReturnTrue = false; + break; + } + } + + if (CHIP_NO_ERROR != structIterator.GetStatus()) + { + shouldReturnTrue = false; + } + + emberAfSendImmediateDefaultResponse(shouldReturnTrue ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); + return true; +} + // ----------------------------------------------------------------------------- // Plugin initialization diff --git a/src/app/zap-templates/templates/app/callback.zapt b/src/app/zap-templates/templates/app/callback.zapt index 0ec8af5977eaed..c17b37e27b8c73 100644 --- a/src/app/zap-templates/templates/app/callback.zapt +++ b/src/app/zap-templates/templates/app/callback.zapt @@ -155,7 +155,7 @@ void emberAf{{asUpperCamelCase label}}ClusterClientTickCallback(chip::EndpointId {{#if (isServer source)}} bool emberAf{{asUpperCamelCase parent.label}}Cluster{{asUpperCamelCase name}}Callback(chip::EndpointId endpoint, chip::app::CommandSender * commandObj - {{#zcl_command_arguments}}, {{asUnderlyingZclType type}} {{asSymbol label}}{{/zcl_command_arguments}}); + {{#zcl_command_arguments}}, {{#if isArray}}{{asUnderlyingZclType type}}{{else}}{{#if_is_struct type}}{{zapTypeToDecodableClusterObjectType type ns=parent.parent.label}}{{else}}{{asUnderlyingZclType type}}{{/if_is_struct}}{{/if}} {{asSymbol label}}{{/zcl_command_arguments}}); {{else}} bool emberAf{{asUpperCamelCase parent.label}}Cluster{{asUpperCamelCase name}}Callback(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, diff --git a/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml index ea1b6780b14895..eee1deb9d0daf0 100644 --- a/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml @@ -168,6 +168,76 @@ limitations under the License. + + + + Command that takes an argument which is struct + + + + + + + + Command that takes an argument which is nested struct + + + + + + + + Command that takes an argument which is a list of struct + + + + + + + + Command that takes an argument which is a list of INT8U + + + + + + + + Command that takes an argument which is a Nested Struct List + + + + + + + + Command that takes an argument which is a list of Nested Struct List + + + + Simple response for TestWithResponse with a simple return value diff --git a/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp index 4b73b1b4c588a2..52c6b5dd3767df 100644 --- a/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp @@ -1607,6 +1607,55 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } break; } + case Commands::TestListInt8UArgumentRequest::Id: { + Commands::TestListInt8UArgumentRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfTestClusterClusterTestListInt8UArgumentRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::TestListNestedStructListArgumentRequest::Id: { + Commands::TestListNestedStructListArgumentRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfTestClusterClusterTestListNestedStructListArgumentRequestCallback(apCommandObj, aCommandPath, + commandData); + } + break; + } + case Commands::TestListStructArgumentRequest::Id: { + Commands::TestListStructArgumentRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfTestClusterClusterTestListStructArgumentRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::TestNestedStructArgumentRequest::Id: { + Commands::TestNestedStructArgumentRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfTestClusterClusterTestNestedStructArgumentRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::TestNestedStructListArgumentRequest::Id: { + Commands::TestNestedStructListArgumentRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfTestClusterClusterTestNestedStructListArgumentRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } case Commands::TestNotHandled::Id: { Commands::TestNotHandled::DecodableType commandData; TLVError = DataModel::Decode(aDataTlv, commandData); @@ -1625,6 +1674,15 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } break; } + case Commands::TestStructArgumentRequest::Id: { + Commands::TestStructArgumentRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfTestClusterClusterTestStructArgumentRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } default: { // Unrecognized command ID, error status will apply. ReportCommandUnsupported(apCommandObj, aCommandPath); diff --git a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h index 37a2cde20c00dc..767adf6a6a50c9 100644 --- a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h +++ b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h @@ -3168,7 +3168,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (219) +#define EMBER_AF_GENERATED_COMMAND_COUNT (225) #define GENERATED_COMMANDS \ { \ \ @@ -3458,6 +3458,12 @@ { 0x050F, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* TestAddArgumentsResponse */ \ { 0x050F, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* TestSpecific */ \ { 0x050F, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* TestAddArguments */ \ + { 0x050F, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* TestStructArgumentRequest */ \ + { 0x050F, 0x08, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* TestNestedStructArgumentRequest */ \ + { 0x050F, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* TestListStructArgumentRequest */ \ + { 0x050F, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* TestListInt8UArgumentRequest */ \ + { 0x050F, 0x0B, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* TestNestedStructListArgumentRequest */ \ + { 0x050F, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* TestListNestedStructListArgumentRequest */ \ \ /* Endpoint: 1, Cluster: Binding (server) */ \ { 0xF000, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Bind */ \ diff --git a/zzz_generated/app-common/app-common/zap-generated/callback.h b/zzz_generated/app-common/app-common/zap-generated/callback.h index d0188795af16af..952087f0f4deb7 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -13894,6 +13894,42 @@ bool emberAfTestClusterClusterTestSimpleArgumentRequestCallback( bool emberAfTestClusterClusterTestStructArrayArgumentRequestCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::TestCluster::Commands::TestStructArrayArgumentRequest::DecodableType & commandData); +/** + * @brief Test Cluster Cluster TestStructArgumentRequest Command callback (from client) + */ +bool emberAfTestClusterClusterTestStructArgumentRequestCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TestCluster::Commands::TestStructArgumentRequest::DecodableType & commandData); +/** + * @brief Test Cluster Cluster TestNestedStructArgumentRequest Command callback (from client) + */ +bool emberAfTestClusterClusterTestNestedStructArgumentRequestCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TestCluster::Commands::TestNestedStructArgumentRequest::DecodableType & commandData); +/** + * @brief Test Cluster Cluster TestListStructArgumentRequest Command callback (from client) + */ +bool emberAfTestClusterClusterTestListStructArgumentRequestCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TestCluster::Commands::TestListStructArgumentRequest::DecodableType & commandData); +/** + * @brief Test Cluster Cluster TestListInt8UArgumentRequest Command callback (from client) + */ +bool emberAfTestClusterClusterTestListInt8UArgumentRequestCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TestCluster::Commands::TestListInt8UArgumentRequest::DecodableType & commandData); +/** + * @brief Test Cluster Cluster TestNestedStructListArgumentRequest Command callback (from client) + */ +bool emberAfTestClusterClusterTestNestedStructListArgumentRequestCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TestCluster::Commands::TestNestedStructListArgumentRequest::DecodableType & commandData); +/** + * @brief Test Cluster Cluster TestListNestedStructListArgumentRequest Command callback (from client) + */ +bool emberAfTestClusterClusterTestListNestedStructListArgumentRequestCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::TestCluster::Commands::TestListNestedStructListArgumentRequest::DecodableType & commandData); /** * @brief Messaging Cluster DisplayMessage Command callback (from server) */ diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 0058f4c329b6d2..05e4358d19b69a 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -15108,6 +15108,216 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) return CHIP_NO_ERROR; } } // namespace TestStructArrayArgumentRequest. +namespace TestStructArgumentRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg1)), arg1)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kArg1): + ReturnErrorOnFailure(DataModel::Decode(reader, arg1)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace TestStructArgumentRequest. +namespace TestNestedStructArgumentRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg1)), arg1)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kArg1): + ReturnErrorOnFailure(DataModel::Decode(reader, arg1)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace TestNestedStructArgumentRequest. +namespace TestListStructArgumentRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg1)), arg1)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kArg1): + ReturnErrorOnFailure(DataModel::Decode(reader, arg1)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace TestListStructArgumentRequest. +namespace TestListInt8UArgumentRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg1)), arg1)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kArg1): + ReturnErrorOnFailure(DataModel::Decode(reader, arg1)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace TestListInt8UArgumentRequest. +namespace TestNestedStructListArgumentRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg1)), arg1)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kArg1): + ReturnErrorOnFailure(DataModel::Decode(reader, arg1)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace TestNestedStructListArgumentRequest. +namespace TestListNestedStructListArgumentRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kArg1)), arg1)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kArg1): + ReturnErrorOnFailure(DataModel::Decode(reader, arg1)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace TestListNestedStructListArgumentRequest. } // namespace Commands } // namespace TestCluster namespace Messaging { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 70b3354e240c19..79a26af4d2eee4 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -20547,6 +20547,174 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace TestStructArrayArgumentRequest +namespace TestStructArgumentRequest { +enum class Fields +{ + kArg1 = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return TestStructArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + Structs::SimpleStruct::Type arg1; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return TestStructArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + Structs::SimpleStruct::DecodableType arg1; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace TestStructArgumentRequest +namespace TestNestedStructArgumentRequest { +enum class Fields +{ + kArg1 = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return TestNestedStructArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + Structs::NestedStruct::Type arg1; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return TestNestedStructArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + Structs::NestedStruct::DecodableType arg1; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace TestNestedStructArgumentRequest +namespace TestListStructArgumentRequest { +enum class Fields +{ + kArg1 = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return TestListStructArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + DataModel::List arg1; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return TestListStructArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + DataModel::DecodableList arg1; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace TestListStructArgumentRequest +namespace TestListInt8UArgumentRequest { +enum class Fields +{ + kArg1 = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return TestListInt8UArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + DataModel::List arg1; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return TestListInt8UArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + DataModel::DecodableList arg1; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace TestListInt8UArgumentRequest +namespace TestNestedStructListArgumentRequest { +enum class Fields +{ + kArg1 = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return TestNestedStructListArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + Structs::NestedStructList::Type arg1; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return TestNestedStructListArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + Structs::NestedStructList::DecodableType arg1; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace TestNestedStructListArgumentRequest +namespace TestListNestedStructListArgumentRequest { +enum class Fields +{ + kArg1 = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return TestListNestedStructListArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + DataModel::List arg1; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return TestListNestedStructListArgumentRequest::Id; } + static constexpr ClusterId GetClusterId() { return TestCluster::Id; } + + DataModel::DecodableList arg1; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace TestListNestedStructListArgumentRequest } // namespace Commands namespace Attributes { diff --git a/zzz_generated/app-common/app-common/zap-generated/command-id.h b/zzz_generated/app-common/app-common/zap-generated/command-id.h index 6eca30fd960768..49f69166703cef 100644 --- a/zzz_generated/app-common/app-common/zap-generated/command-id.h +++ b/zzz_generated/app-common/app-common/zap-generated/command-id.h @@ -449,6 +449,12 @@ #define ZCL_TEST_ADD_ARGUMENTS_COMMAND_ID (0x04) #define ZCL_TEST_SIMPLE_ARGUMENT_REQUEST_COMMAND_ID (0x05) #define ZCL_TEST_STRUCT_ARRAY_ARGUMENT_REQUEST_COMMAND_ID (0x06) +#define ZCL_TEST_STRUCT_ARGUMENT_REQUEST_COMMAND_ID (0x07) +#define ZCL_TEST_NESTED_STRUCT_ARGUMENT_REQUEST_COMMAND_ID (0x08) +#define ZCL_TEST_LIST_STRUCT_ARGUMENT_REQUEST_COMMAND_ID (0x09) +#define ZCL_TEST_LIST_INT8_U_ARGUMENT_REQUEST_COMMAND_ID (0x0A) +#define ZCL_TEST_NESTED_STRUCT_LIST_ARGUMENT_REQUEST_COMMAND_ID (0x0B) +#define ZCL_TEST_LIST_NESTED_STRUCT_LIST_ARGUMENT_REQUEST_COMMAND_ID (0x0C) // Commands for cluster: Messaging #define ZCL_DISPLAY_MESSAGE_COMMAND_ID (0x00) diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h index 366480938900f8..eab321aad42695 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h @@ -1580,6 +1580,30 @@ namespace TestStructArrayArgumentRequest { static constexpr CommandId Id = 0x00000006; } // namespace TestStructArrayArgumentRequest +namespace TestStructArgumentRequest { +static constexpr CommandId Id = 0x00000007; +} // namespace TestStructArgumentRequest + +namespace TestNestedStructArgumentRequest { +static constexpr CommandId Id = 0x00000008; +} // namespace TestNestedStructArgumentRequest + +namespace TestListStructArgumentRequest { +static constexpr CommandId Id = 0x00000009; +} // namespace TestListStructArgumentRequest + +namespace TestListInt8UArgumentRequest { +static constexpr CommandId Id = 0x0000000A; +} // namespace TestListInt8UArgumentRequest + +namespace TestNestedStructListArgumentRequest { +static constexpr CommandId Id = 0x0000000B; +} // namespace TestNestedStructListArgumentRequest + +namespace TestListNestedStructListArgumentRequest { +static constexpr CommandId Id = 0x0000000C; +} // namespace TestListNestedStructListArgumentRequest + } // namespace Commands } // namespace TestCluster