From 80ddf152951fd5182e3e7e43a93a1a118b657eef Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 27 Oct 2021 21:32:52 -0400 Subject: [PATCH] Make attributes whose values are lists of structs that have nullables/optionals at least compile. This doesn't give us correct behavior across all of our bindings (chip-tool command line, yaml, darwin, python, java). But it at least allows code generation to produce output and allows that output to compile. More work is needed to address the various TODO issues. --- .../all-clusters-common/all-clusters-app.zap | 15 + examples/chip-tool/templates/commands.zapt | 34 +- .../test-cluster-server.cpp | 16 + .../zcl/data-model/chip/test-cluster.xml | 2 + .../data_model/controller-clusters.zap | 15 + .../java/templates/CHIPClusters-JNI.zapt | 27 +- .../java/templates/ChipClusters-java.zapt | 30 +- .../java/zap-generated/CHIPClusters-JNI.cpp | 170 +++++- .../chip/devicecontroller/ChipClusters.java | 19 + .../python/chip/clusters/CHIPClusters.cpp | 221 +++++++- .../python/chip/clusters/CHIPClusters.py | 12 + .../python/chip/clusters/Objects.py | 13 + .../templates/python-CHIPClusters-cpp.zapt | 32 +- .../partials/CHIPCallbackBridge.zapt | 13 +- .../CHIP/zap-generated/CHIPCallbackBridge.mm | 48 ++ .../CHIPCallbackBridge_internal.h | 14 + .../CHIP/zap-generated/CHIPClustersObjc.h | 2 + .../CHIP/zap-generated/CHIPClustersObjc.mm | 8 + .../zap-generated/attribute-size.cpp | 71 +++ .../zap-generated/endpoint_config.h | 18 +- .../app-common/zap-generated/attribute-id.h | 1 + .../zap-generated/cluster-objects.h | 10 + .../app-common/zap-generated/ids/Attributes.h | 4 + .../zap-generated/cluster/Commands.h | 524 ++++++++++++------ .../zap-generated/CHIPClientCallbacks.cpp | 25 + .../zap-generated/CHIPClientCallbacks.h | 7 + .../zap-generated/CHIPClusters.cpp | 12 + .../zap-generated/CHIPClusters.h | 2 + 28 files changed, 1116 insertions(+), 249 deletions(-) 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 3df6139ab84e95..a2bdd2c6bfff0d 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 @@ -15486,6 +15486,21 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "list_nullables_and_optionals_struct", + "code": 35, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "ClusterRevision", "code": 65533, diff --git a/examples/chip-tool/templates/commands.zapt b/examples/chip-tool/templates/commands.zapt index e1e814eb5b5590..e73032b1d3a75b 100644 --- a/examples/chip-tool/templates/commands.zapt +++ b/examples/chip-tool/templates/commands.zapt @@ -151,19 +151,40 @@ static void On{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}ListAttri uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; {{#if isStruct}} ChipLogProgress(chipTool, "{{type}}[%" PRIu16 "]:", i); {{#chip_attribute_list_entryTypes}} - {{#if (isOctetString type)}} - ChipLogProgress(Zcl, " {{asSymbol label}}: %zu", entry.{{asLowerCamelCase name}}.size()); + {{~#*inline "field"}}entry.{{asLowerCamelCase name}}{{#if isOptional}}.Value(){{/if}}{{/inline~}} + {{~#*inline "fieldValue"}}{{>field}}{{#if isNullable}}.Value(){{/if}}{{/inline~}} + {{#if isOptional}} + if (entry.{{asLowerCamelCase name}}.HasValue()) { + {{/if}} + {{#if isNullable}} + if ({{>field}}.IsNull()) { + ChipLogProgress(chipTool, " {{asSymbol label}}: null"); + } else { + {{/if}} + {{#if isArray}} + {{! TODO: Add support for printing list member of struct element of list attribute }} + ChipLogProgress(chipTool, " {{asSymbol label}}: list member of struct element of list attribute printing not supported yet"); + {{else if (isOctetString type)}} + ChipLogProgress(Zcl, " {{asSymbol label}}: %zu", {{>fieldValue}}.size()); {{else if (isCharString type)}} - ChipLogProgress(Zcl, " {{asSymbol label}}: %.*s", static_cast(entry.{{asLowerCamelCase name}}.size()), entry.{{asLowerCamelCase name}}.data()); + ChipLogProgress(Zcl, " {{asSymbol label}}: %.*s", static_cast({{>fieldValue}}.size()), {{>fieldValue}}.data()); + {{else if isStruct}} + {{! TODO: Add support for printing struct member of struct element of list attribute }} + ChipLogProgress(chipTool, " {{asSymbol label}}: struct member of struct element of list attribute printing not supported yet"); {{else}} - ChipLogProgress(chipTool, " {{asLowerCamelCase name}}: {{asPrintFormat type}}", entry.{{asLowerCamelCase name}}); + ChipLogProgress(chipTool, " {{asSymbol label}}: {{asPrintFormat type}}", {{>fieldValue}}); + {{/if}} + {{#if isNullable}} + } + {{/if}} + {{#if isOptional}} + } {{/if}} {{/chip_attribute_list_entryTypes}} {{else}} @@ -175,6 +196,7 @@ static void On{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}ListAttri ChipLogProgress(chipTool, "{{type}}[%" PRIu16 "]: {{asPrintFormat type}}", i, entry); {{/if}} {{/if}} +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } 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 44075196b30534..d4bf81190281ba 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -58,6 +58,7 @@ class TestAttrAccess : public AttributeAccessInterface CHIP_ERROR ReadListInt8uAttribute(AttributeValueEncoder & aEncoder); CHIP_ERROR ReadListOctetStringAttribute(AttributeValueEncoder & aEncoder); CHIP_ERROR ReadListStructOctetStringAttribute(AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadListNullablesAndOptionalsStructAttribute(AttributeValueEncoder & aEncoder); }; TestAttrAccess gAttrAccess; @@ -75,6 +76,9 @@ CHIP_ERROR TestAttrAccess::Read(const ConcreteAttributePath & aPath, AttributeVa case ListStructOctetString::Id: { return ReadListStructOctetStringAttribute(aEncoder); } + case ListNullablesAndOptionalsStruct::Id: { + return ReadListNullablesAndOptionalsStructAttribute(aEncoder); + } default: { break; } @@ -221,6 +225,18 @@ CHIP_ERROR TestAttrAccess::ReadListStructOctetStringAttribute(AttributeValueEnco return CHIP_NO_ERROR; }); } + +CHIP_ERROR TestAttrAccess::ReadListNullablesAndOptionalsStructAttribute(AttributeValueEncoder & aEncoder) +{ + return aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR { + // Just encode a single default-initialized + // entry for now. + Structs::NullablesAndOptionalsStruct::Type entry; + ReturnErrorOnFailure(encoder.Encode(entry)); + return CHIP_NO_ERROR; + }); +} + } // namespace bool emberAfTestClusterClusterTestCallback(app::CommandHandler *, const 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 7d751f3dbd543d..cf2ef210144b20 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 @@ -135,6 +135,8 @@ limitations under the License. epoch_s vendor_id + list_nullables_and_optionals_struct diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index 66a26e0ea8e401..5bf895dab6fc65 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -11699,6 +11699,21 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "list_nullables_and_optionals_struct", + "code": 35, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "unsupported", "code": 255, diff --git a/src/controller/java/templates/CHIPClusters-JNI.zapt b/src/controller/java/templates/CHIPClusters-JNI.zapt index 492ae5df6e8ea2..29779dd77787c9 100644 --- a/src/controller/java/templates/CHIPClusters-JNI.zapt +++ b/src/controller/java/templates/CHIPClusters-JNI.zapt @@ -448,7 +448,7 @@ class CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCall VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find class chip/devicecontroller/ChipClusters${{asUpperCamelCase parent.name}}Cluster${{asUpperCamelCase name}}Attribute")); JniClass attributeJniClass(attributeClass); jmethodID attributeCtor = env->GetMethodID(attributeClass, "" - , "({{#chip_attribute_list_entryTypes}}{{#if (isString type)}}{{#if (isOctetString type)}}[B{{else}}Ljava/lang/String;{{/if}}{{else}}{{asJniSignature type}}{{/if}}{{/chip_attribute_list_entryTypes}})V"); + , "({{#chip_attribute_list_entryTypes}}{{#if isOptional}}{{! TODO: Add support for optional types here }}{{else if isNullable}}{{! TODO: Add support for nullable types here }}{{else if isArray}}{{! TODO: Add support for lists here }}{{else if isStruct}}{{! TODO: Add support for structs here }}{{else if (isString type)}}{{#if (isOctetString type)}}[B{{else}}Ljava/lang/String;{{/if}}{{else}}{{asJniSignature type}}{{/if}}{{/chip_attribute_list_entryTypes}})V"); VerifyOrReturn(attributeCtor != nullptr, ChipLogError(Zcl, "Could not find {{asUpperCamelCase name}}Attribute constructor")); {{/if}} @@ -457,8 +457,17 @@ class CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCall { auto & entry = iter.GetValue(); {{#if isStruct}} + (void)entry; {{! In case all our struct members are not supported yet }} {{#chip_attribute_list_entryTypes}} - {{#if (isOctetString type)}} + {{#if isOptional}} + {{! TODO: Add support for optional types here }} + {{else if isNullable}} + {{! TODO: Add support for nullable types here }} + {{else if isArray}} + {{! TODO: Add support for lists here }} + {{else if isStruct}} + {{! TODO: Add support for structs here }} + {{else if (isOctetString type)}} jbyteArray {{asLowerCamelCase name}} = env->NewByteArray(entry.{{asLowerCamelCase name}}.size()); env->SetByteArrayRegion({{asLowerCamelCase name}}, 0, entry.{{asLowerCamelCase name}}.size(), reinterpret_cast(entry.{{asLowerCamelCase name}}.data())); {{else if (isCharString type)}} @@ -469,9 +478,19 @@ class CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCall {{/if}} {{/chip_attribute_list_entryTypes}} - jobject attributeObj = env->NewObject(attributeClass, attributeCtor, + jobject attributeObj = env->NewObject(attributeClass, attributeCtor {{#chip_attribute_list_entryTypes}} - {{asLowerCamelCase name}}{{#not_last}}, {{/not_last}} + {{#if isOptional}} + {{! TODO: Add support for optional types here }} + {{else if isNullable}} + {{! TODO: Add support for nullable types here }} + {{else if isArray}} + {{! TODO: Add support for lists here }} + {{else if isStruct}} + {{! TODO: Add support for structs here }} + {{else}} + , {{asLowerCamelCase name}} + {{/if}} {{/chip_attribute_list_entryTypes}} ); VerifyOrReturn(attributeObj != nullptr, ChipLogError(Zcl, "Could not create {{asUpperCamelCase name}}Attribute object")); diff --git a/src/controller/java/templates/ChipClusters-java.zapt b/src/controller/java/templates/ChipClusters-java.zapt index 2e72749ad6dd4b..34dc0805c40266 100644 --- a/src/controller/java/templates/ChipClusters-java.zapt +++ b/src/controller/java/templates/ChipClusters-java.zapt @@ -110,7 +110,15 @@ public class ChipClusters { {{#if isStruct}} public static class {{asUpperCamelCase name}}Attribute { {{#chip_attribute_list_entryTypes}} - {{#if (isOctetString type)}} + {{#if isOptional}} + {{! TODO: Add support for optional types here }} + {{else if isNullable}} + {{! TODO: Add support for nullable types here }} + {{else if isArray}} + {{! TODO: Add support for lists here }} + {{else if isStruct}} + {{! TODO: Add support for structs here }} + {{else if (isOctetString type)}} public byte[] {{asLowerCamelCase name}}; {{else if (isCharString type)}} public String {{asLowerCamelCase name}}; @@ -121,7 +129,15 @@ public class ChipClusters { public {{asUpperCamelCase name}}Attribute( {{#chip_attribute_list_entryTypes}} - {{#if (isOctetString type)}} + {{#if isOptional}} + {{! TODO: Add support for optional types here }} + {{else if isNullable}} + {{! TODO: Add support for nullable types here }} + {{else if isArray}} + {{! TODO: Add support for lists here }} + {{else if isStruct}} + {{! TODO: Add support for structs here }} + {{else if (isOctetString type)}} byte[] {{asLowerCamelCase name}}{{#not_last}},{{/not_last}} {{else if (isCharString type)}} String {{asLowerCamelCase name}}{{#not_last}},{{/not_last}} @@ -131,7 +147,17 @@ public class ChipClusters { {{/chip_attribute_list_entryTypes}} ) { {{#chip_attribute_list_entryTypes}} + {{#if isOptional}} + {{! TODO: Add support for optional types here }} + {{else if isNullable}} + {{! TODO: Add support for nullable types here }} + {{else if isArray}} + {{! TODO: Add support for lists here }} + {{else if isStruct}} + {{! TODO: Add support for structs here }} + {{else}} this.{{asLowerCamelCase name}} = {{asLowerCamelCase name}}; + {{/if}} {{/chip_attribute_list_entryTypes}} } } diff --git a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp index aba0a78fd2c673..57eaf8959a053b 100644 --- a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp +++ b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp @@ -6320,7 +6320,8 @@ class CHIPAudioOutputAudioOutputListAttributeCallback : public Callback::Callbac auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jint index = entry.index; jint outputType = entry.outputType; UtfString nameStr(env, entry.name); @@ -6410,7 +6411,8 @@ class CHIPBridgedActionsActionListAttributeCallback : public Callback::Callback< auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jint actionID = entry.actionID; UtfString nameStr(env, entry.name); jstring name(nameStr.jniValue()); @@ -6506,7 +6508,8 @@ class CHIPBridgedActionsEndpointListAttributeCallback : public Callback::Callbac auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jint endpointListID = entry.endpointListID; UtfString nameStr(env, entry.name); jstring name(nameStr.jniValue()); @@ -6748,7 +6751,8 @@ class CHIPDescriptorDeviceListAttributeCallback : public Callback::CallbackNewObject(attributeClass, attributeCtor, failSafeExpiryLengthMs); @@ -7246,6 +7252,7 @@ class CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallback while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; UtfString nameStr(env, entry.name); jstring name(nameStr.jniValue()); jboolean fabricConnected = entry.fabricConnected; @@ -7343,7 +7350,8 @@ class CHIPGroupKeyManagementGroupsAttributeCallback : public Callback::Callback< auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jint vendorId = entry.vendorId; jint vendorGroupId = entry.vendorGroupId; jint groupKeySetIndex = entry.groupKeySetIndex; @@ -7432,7 +7440,8 @@ class CHIPGroupKeyManagementGroupKeysAttributeCallback : public Callback::Callba auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jint vendorId = entry.vendorId; jint groupKeyIndex = entry.groupKeyIndex; jbyteArray groupKeyRoot = env->NewByteArray(entry.groupKeyRoot.size()); @@ -7526,7 +7535,8 @@ class CHIPMediaInputMediaInputListAttributeCallback : public Callback::Callback< auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jint index = entry.index; jint inputType = entry.inputType; UtfString nameStr(env, entry.name); @@ -7620,7 +7630,8 @@ class CHIPOperationalCredentialsFabricsListAttributeCallback auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jint fabricIndex = entry.fabricIndex; jbyteArray rootPublicKey = env->NewByteArray(entry.rootPublicKey.size()); env->SetByteArrayRegion(rootPublicKey, 0, entry.rootPublicKey.size(), @@ -7865,7 +7876,8 @@ class CHIPTvChannelTvChannelListAttributeCallback : public Callback::CallbackNewByteArray(entry.operationalCert.size()); env->SetByteArrayRegion(operationalCert, 0, entry.operationalCert.size(), @@ -8224,6 +8238,98 @@ class CHIPTestClusterListStructOctetStringAttributeCallback jobject javaCallbackRef; }; +class CHIPTestClusterListNullablesAndOptionalsStructAttributeCallback + : public Callback::Callback +{ +public: + CHIPTestClusterListNullablesAndOptionalsStructAttributeCallback(jobject javaCallback) : + Callback::Callback(CallbackFn, this) + { + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } + } + + static void CallbackFn(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::TestCluster::Structs::NullablesAndOptionalsStruct::DecodableType> & list) + { + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + + std::unique_ptr cppCallback( + reinterpret_cast(context)); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jclass arrayListClass; + err = JniReferences::GetInstance().GetClassRef(env, "java/util/ArrayList", arrayListClass); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error using Java ArrayList")); + JniClass arrayListJniClass(arrayListClass); + jmethodID arrayListCtor = env->GetMethodID(arrayListClass, "", "()V"); + jmethodID arrayListAddMethod = env->GetMethodID(arrayListClass, "add", "(Ljava/lang/Object;)Z"); + VerifyOrReturn(arrayListCtor != nullptr && arrayListAddMethod != nullptr, + ChipLogError(Zcl, "Error finding Java ArrayList methods")); + jobject arrayListObj = env->NewObject(arrayListClass, arrayListCtor); + VerifyOrReturn(arrayListObj != nullptr, ChipLogError(Zcl, "Error creating Java ArrayList")); + + jmethodID javaMethod; + err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jclass attributeClass; + err = JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipClusters$TestClusterCluster$ListNullablesAndOptionalsStructAttribute", attributeClass); + VerifyOrReturn( + err == CHIP_NO_ERROR, + ChipLogError(Zcl, + "Could not find class " + "chip/devicecontroller/ChipClusters$TestClusterCluster$ListNullablesAndOptionalsStructAttribute")); + JniClass attributeJniClass(attributeClass); + jmethodID attributeCtor = env->GetMethodID(attributeClass, "", "()V"); + VerifyOrReturn(attributeCtor != nullptr, + ChipLogError(Zcl, "Could not find ListNullablesAndOptionalsStructAttribute constructor")); + + auto iter = list.begin(); + while (iter.Next()) + { + auto & entry = iter.GetValue(); + (void) entry; + + jobject attributeObj = env->NewObject(attributeClass, attributeCtor); + VerifyOrReturn(attributeObj != nullptr, + ChipLogError(Zcl, "Could not create ListNullablesAndOptionalsStructAttribute object")); + + env->CallBooleanMethod(arrayListObj, arrayListAddMethod, attributeObj); + } + VerifyOrReturn(iter.GetStatus() == CHIP_NO_ERROR, + ChipLogError(Zcl, "Error decoding ListNullablesAndOptionalsStructAttribute value: %" CHIP_ERROR_FORMAT, + iter.GetStatus().Format())); + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); + } + +private: + jobject javaCallbackRef; +}; + class CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallback : public Callback::Callback { @@ -8294,7 +8400,8 @@ class CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallback auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jlong extAddress = entry.extAddress; jlong age = entry.age; jint rloc16 = entry.rloc16; @@ -8399,7 +8506,8 @@ class CHIPThreadNetworkDiagnosticsRouteTableListAttributeCallback auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jlong extAddress = entry.extAddress; jint rloc16 = entry.rloc16; jint routerId = entry.routerId; @@ -8499,7 +8607,8 @@ class CHIPThreadNetworkDiagnosticsSecurityPolicyAttributeCallback auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jint rotationTime = entry.rotationTime; jint flags = entry.flags; @@ -8594,7 +8703,8 @@ class CHIPThreadNetworkDiagnosticsOperationalDatasetComponentsAttributeCallback auto iter = list.begin(); while (iter.Next()) { - auto & entry = iter.GetValue(); + auto & entry = iter.GetValue(); + (void) entry; jboolean activeTimestampPresent = entry.activeTimestampPresent; jboolean pendingTimestampPresent = entry.pendingTimestampPresent; jboolean masterKeyPresent = entry.masterKeyPresent; @@ -27963,6 +28073,34 @@ JNI_METHOD(void, TestClusterCluster, writeVendorIdAttribute) onFailure.release(); } +JNI_METHOD(void, TestClusterCluster, readListNullablesAndOptionalsStructAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) +{ + chip::DeviceLayer::StackLock lock; + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + Platform::New(callback), Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + TestClusterCluster * cppCluster = reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + err = cppCluster->ReadAttributeListNullablesAndOptionalsStruct(onSuccess->Cancel(), onFailure->Cancel()); + VerifyOrReturn(err == CHIP_NO_ERROR, ReturnIllegalStateException(env, callback, "Error reading attribute", err)); + + onSuccess.release(); + onFailure.release(); +} + JNI_METHOD(void, TestClusterCluster, readUnsupportedAttribute)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) { chip::DeviceLayer::StackLock lock; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java index fb8376fc6499d3..f38c0aa74ccc1b 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -6088,6 +6088,17 @@ public interface ListStructOctetStringAttributeCallback { void onError(Exception ex); } + public static class ListNullablesAndOptionalsStructAttribute { + + public ListNullablesAndOptionalsStructAttribute() {} + } + + public interface ListNullablesAndOptionalsStructAttributeCallback { + void onSuccess(List valueList); + + void onError(Exception ex); + } + public void readBooleanAttribute(BooleanAttributeCallback callback) { readBooleanAttribute(chipClusterPtr, callback); } @@ -6277,6 +6288,11 @@ public void writeVendorIdAttribute(DefaultClusterCallback callback, int value) { writeVendorIdAttribute(chipClusterPtr, callback, value); } + public void readListNullablesAndOptionalsStructAttribute( + ListNullablesAndOptionalsStructAttributeCallback callback) { + readListNullablesAndOptionalsStructAttribute(chipClusterPtr, callback); + } + public void readUnsupportedAttribute(BooleanAttributeCallback callback) { readUnsupportedAttribute(chipClusterPtr, callback); } @@ -6416,6 +6432,9 @@ private native void readVendorIdAttribute( private native void writeVendorIdAttribute( long chipClusterPtr, DefaultClusterCallback callback, int value); + private native void readListNullablesAndOptionalsStructAttribute( + long chipClusterPtr, ListNullablesAndOptionalsStructAttributeCallback callback); + private native void readUnsupportedAttribute( long chipClusterPtr, BooleanAttributeCallback callback); diff --git a/src/controller/python/chip/clusters/CHIPClusters.cpp b/src/controller/python/chip/clusters/CHIPClusters.cpp index 5c135139113eb0..2404b10be70fe0 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.cpp +++ b/src/controller/python/chip/clusters/CHIPClusters.cpp @@ -126,8 +126,8 @@ OnApplicationLauncherApplicationLauncherListListAttributeResponse(void * context { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %" PRIu16 ",", entry); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -173,12 +173,12 @@ static void OnAudioOutputAudioOutputListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " index: %" PRIu8 ",", entry.index); ChipLogProgress(Zcl, " outputType: %" PRIu8 ",", entry.outputType); ChipLogProgress(Zcl, " name: %.*s,", static_cast(entry.name.size()), entry.name.data()); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -223,7 +223,6 @@ static void OnBridgedActionsActionListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " ActionID: %" PRIu16 ",", entry.actionID); ChipLogProgress(Zcl, " Name: %.*s,", static_cast(entry.name.size()), entry.name.data()); @@ -232,6 +231,7 @@ static void OnBridgedActionsActionListListAttributeResponse( ChipLogProgress(Zcl, " SupportedCommands: %" PRIu16 ",", entry.supportedCommands); ChipLogProgress(Zcl, " Status: %" PRIu8 ",", entry.status); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -277,13 +277,13 @@ static void OnBridgedActionsEndpointListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " EndpointListID: %" PRIu16 ",", entry.endpointListID); ChipLogProgress(Zcl, " Name: %.*s,", static_cast(entry.name.size()), entry.name.data()); ChipLogProgress(Zcl, " Type: %" PRIu8 ",", entry.type); ChipLogProgress(Zcl, " Endpoints: %s,", ByteSpanToString(entry.endpoints).c_str()); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -328,8 +328,8 @@ OnContentLauncherAcceptsHeaderListListAttributeResponse(void * context, { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %s,", ByteSpanToString(entry).c_str()); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -373,8 +373,8 @@ static void OnContentLauncherSupportedStreamingTypesListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %" PRIu8 ",", entry); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -419,11 +419,11 @@ static void OnDescriptorDeviceListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " type: %" PRIu32 ",", entry.type); ChipLogProgress(Zcl, " revision: %" PRIu16 ",", entry.revision); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -467,8 +467,8 @@ static void OnDescriptorServerListListAttributeResponse(void * context, { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %" PRIu32 ",", entry); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -512,8 +512,8 @@ static void OnDescriptorClientListListAttributeResponse(void * context, { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %" PRIu32 ",", entry); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -557,8 +557,8 @@ static void OnDescriptorPartsListListAttributeResponse(void * context, { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %" PRIu16 ",", entry); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -603,11 +603,11 @@ static void OnFixedLabelLabelListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " label: %.*s,", static_cast(entry.label.size()), entry.label.data()); ChipLogProgress(Zcl, " value: %.*s,", static_cast(entry.value.size()), entry.value.data()); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -653,10 +653,10 @@ static void OnGeneralCommissioningBasicCommissioningInfoListListAttributeRespons { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " FailSafeExpiryLengthMs: %" PRIu32 ",", entry.failSafeExpiryLengthMs); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -703,7 +703,6 @@ static void OnGeneralDiagnosticsNetworkInterfacesListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " Name: %.*s,", static_cast(entry.name.size()), entry.name.data()); ChipLogProgress(Zcl, " FabricConnected: %d,", entry.fabricConnected); @@ -712,6 +711,7 @@ static void OnGeneralDiagnosticsNetworkInterfacesListAttributeResponse( ChipLogProgress(Zcl, " HardwareAddress: %s,", ByteSpanToString(entry.hardwareAddress).c_str()); ChipLogProgress(Zcl, " Type: %" PRIu8 ",", entry.type); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -756,12 +756,12 @@ static void OnGroupKeyManagementGroupsListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " VendorId: %" PRIu16 ",", entry.vendorId); ChipLogProgress(Zcl, " VendorGroupId: %" PRIu16 ",", entry.vendorGroupId); ChipLogProgress(Zcl, " GroupKeySetIndex: %" PRIu16 ",", entry.groupKeySetIndex); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -806,7 +806,6 @@ static void OnGroupKeyManagementGroupKeysListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " VendorId: %" PRIu16 ",", entry.vendorId); ChipLogProgress(Zcl, " GroupKeyIndex: %" PRIu16 ",", entry.groupKeyIndex); @@ -814,6 +813,7 @@ static void OnGroupKeyManagementGroupKeysListAttributeResponse( ChipLogProgress(Zcl, " GroupKeyEpochStartTime: %" PRIu64 ",", entry.groupKeyEpochStartTime); ChipLogProgress(Zcl, " GroupKeySecurityPolicy: %" PRIu8 ",", entry.groupKeySecurityPolicy); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -858,13 +858,13 @@ static void OnMediaInputMediaInputListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " index: %" PRIu8 ",", entry.index); ChipLogProgress(Zcl, " inputType: %" PRIu8 ",", entry.inputType); ChipLogProgress(Zcl, " name: %.*s,", static_cast(entry.name.size()), entry.name.data()); ChipLogProgress(Zcl, " description: %.*s,", static_cast(entry.description.size()), entry.description.data()); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -910,7 +910,6 @@ static void OnOperationalCredentialsFabricsListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " FabricIndex: %" PRIu8 ",", entry.fabricIndex); ChipLogProgress(Zcl, " RootPublicKey: %s,", ByteSpanToString(entry.rootPublicKey).c_str()); @@ -919,6 +918,7 @@ static void OnOperationalCredentialsFabricsListListAttributeResponse( ChipLogProgress(Zcl, " NodeId: %" PRIu64 ",", entry.nodeId); ChipLogProgress(Zcl, " Label: %.*s,", static_cast(entry.label.size()), entry.label.data()); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -961,8 +961,8 @@ static void OnOperationalCredentialsTrustedRootCertificatesListAttributeResponse { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %s,", ByteSpanToString(entry).c_str()); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1007,8 +1007,8 @@ static void OnPowerSourceActiveBatteryFaultsListAttributeResponse(void * context { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %" PRIu8 ",", entry); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1053,7 +1053,6 @@ static void OnTvChannelTvChannelListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " majorNumber: %" PRIu16 ",", entry.majorNumber); ChipLogProgress(Zcl, " minorNumber: %" PRIu16 ",", entry.minorNumber); @@ -1062,6 +1061,7 @@ static void OnTvChannelTvChannelListListAttributeResponse( ChipLogProgress(Zcl, " affiliateCallSign: %.*s,", static_cast(entry.affiliateCallSign.size()), entry.affiliateCallSign.data()); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1107,11 +1107,11 @@ static void OnTargetNavigatorTargetNavigatorListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " identifier: %" PRIu8 ",", entry.identifier); ChipLogProgress(Zcl, " name: %.*s,", static_cast(entry.name.size()), entry.name.data()); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1153,8 +1153,8 @@ static void OnTestClusterListInt8uListAttributeResponse(void * context, const ch { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %" PRIu8 ",", entry); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1198,8 +1198,8 @@ static void OnTestClusterListOctetStringListAttributeResponse(void * context, { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %s,", ByteSpanToString(entry).c_str()); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1244,11 +1244,11 @@ static void OnTestClusterListStructOctetStringListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " fabricIndex: %" PRIu64 ",", entry.fabricIndex); ChipLogProgress(Zcl, " operationalCert: %s,", ByteSpanToString(entry.operationalCert).c_str()); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1267,6 +1267,156 @@ static void OnTestClusterListStructOctetStringListAttributeResponse( } chip::Callback::Callback gTestClusterListStructOctetStringListAttributeCallback{ OnTestClusterListStructOctetStringListAttributeResponse, nullptr }; +static void OnTestClusterListNullablesAndOptionalsStructListAttributeResponse( + void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::TestCluster::Structs::NullablesAndOptionalsStruct::DecodableType> & list) +{ + size_t count = 0; + CHIP_ERROR err = list.ComputeSize(&count); + if (err != CHIP_NO_ERROR) + { + if (gFailureResponseDelegate != nullptr) + { + gFailureResponseDelegate(EMBER_ZCL_STATUS_INVALID_VALUE); + } + return; + } + + ChipLogProgress(Zcl, " attributeValue:%s", count > 0 ? "" : " []"); + + if (count > 0) + ChipLogProgress(Zcl, " ["); + + auto iter = list.begin(); + while (iter.Next()) + { +#if CHIP_PROGRESS_LOGGING + auto & entry = iter.GetValue(); + ChipLogProgress(Zcl, " {"); + if (entry.nullableInt.IsNull()) + { + ChipLogProgress(chipTool, " NullableInt: null"); + } + else + { + ChipLogProgress(Zcl, " NullableInt: %" PRIu16 ",", entry.nullableInt.Value()); + } + if (entry.optionalInt.HasValue()) + { + ChipLogProgress(Zcl, " OptionalInt: %" PRIu16 ",", entry.optionalInt.Value()); + } + if (entry.nullableOptionalInt.HasValue()) + { + if (entry.nullableOptionalInt.Value().IsNull()) + { + ChipLogProgress(chipTool, " NullableOptionalInt: null"); + } + else + { + ChipLogProgress(Zcl, " NullableOptionalInt: %" PRIu16 ",", entry.nullableOptionalInt.Value().Value()); + } + } + if (entry.nullableString.IsNull()) + { + ChipLogProgress(chipTool, " NullableString: null"); + } + else + { + ChipLogProgress(Zcl, " NullableString: %.*s,", static_cast(entry.nullableString.Value().size()), + entry.nullableString.Value().data()); + } + if (entry.optionalString.HasValue()) + { + ChipLogProgress(Zcl, " OptionalString: %.*s,", static_cast(entry.optionalString.Value().size()), + entry.optionalString.Value().data()); + } + if (entry.nullableOptionalString.HasValue()) + { + if (entry.nullableOptionalString.Value().IsNull()) + { + ChipLogProgress(chipTool, " NullableOptionalString: null"); + } + else + { + ChipLogProgress(Zcl, " NullableOptionalString: %.*s,", + static_cast(entry.nullableOptionalString.Value().Value().size()), + entry.nullableOptionalString.Value().Value().data()); + } + } + if (entry.nullableStruct.IsNull()) + { + ChipLogProgress(chipTool, " NullableStruct: null"); + } + else + { + ChipLogProgress(chipTool, + " NullableStruct: struct member of struct element of list attribute printing not supported yet"); + } + if (entry.optionalStruct.HasValue()) + { + ChipLogProgress(chipTool, + " OptionalStruct: struct member of struct element of list attribute printing not supported yet"); + } + if (entry.nullableOptionalStruct.HasValue()) + { + if (entry.nullableOptionalStruct.Value().IsNull()) + { + ChipLogProgress(chipTool, " NullableOptionalStruct: null"); + } + else + { + ChipLogProgress( + chipTool, + " NullableOptionalStruct: struct member of struct element of list attribute printing not supported yet"); + } + } + if (entry.nullableList.IsNull()) + { + ChipLogProgress(chipTool, " NullableList: null"); + } + else + { + ChipLogProgress(chipTool, " NullableList: list member of struct element of list attribute printing not supported yet"); + } + if (entry.optionalList.HasValue()) + { + ChipLogProgress(chipTool, " OptionalList: list member of struct element of list attribute printing not supported yet"); + } + if (entry.nullableOptionalList.HasValue()) + { + if (entry.nullableOptionalList.Value().IsNull()) + { + ChipLogProgress(chipTool, " NullableOptionalList: null"); + } + else + { + ChipLogProgress( + chipTool, " NullableOptionalList: list member of struct element of list attribute printing not supported yet"); + } + } + ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING + } + if (iter.GetStatus() != CHIP_NO_ERROR) + { + if (gFailureResponseDelegate != nullptr) + { + gFailureResponseDelegate(EMBER_ZCL_STATUS_INVALID_VALUE); + } + return; + } + + if (count > 0) + ChipLogProgress(Zcl, " ]"); + + if (gSuccessResponseDelegate != nullptr) + gSuccessResponseDelegate(); +} +chip::Callback::Callback + gTestClusterListNullablesAndOptionalsStructListAttributeCallback{ + OnTestClusterListNullablesAndOptionalsStructListAttributeResponse, nullptr + }; static void OnThreadNetworkDiagnosticsNeighborTableListListAttributeResponse( void * context, const chip::app::DataModel::DecodableList< @@ -1293,7 +1443,6 @@ static void OnThreadNetworkDiagnosticsNeighborTableListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " ExtAddress: %" PRIu64 ",", entry.extAddress); ChipLogProgress(Zcl, " Age: %" PRIu32 ",", entry.age); @@ -1310,6 +1459,7 @@ static void OnThreadNetworkDiagnosticsNeighborTableListListAttributeResponse( ChipLogProgress(Zcl, " FullNetworkData: %d,", entry.fullNetworkData); ChipLogProgress(Zcl, " IsChild: %d,", entry.isChild); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1356,7 +1506,6 @@ static void OnThreadNetworkDiagnosticsRouteTableListListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " ExtAddress: %" PRIu64 ",", entry.extAddress); ChipLogProgress(Zcl, " Rloc16: %" PRIu16 ",", entry.rloc16); @@ -1369,6 +1518,7 @@ static void OnThreadNetworkDiagnosticsRouteTableListListAttributeResponse( ChipLogProgress(Zcl, " Allocated: %d,", entry.allocated); ChipLogProgress(Zcl, " LinkEstablished: %d,", entry.linkEstablished); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1414,11 +1564,11 @@ static void OnThreadNetworkDiagnosticsSecurityPolicyListAttributeResponse( { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " RotationTime: %" PRIu16 ",", entry.rotationTime); ChipLogProgress(Zcl, " Flags: %" PRIu16 ",", entry.flags); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1464,7 +1614,6 @@ static void OnThreadNetworkDiagnosticsOperationalDatasetComponentsListAttributeR { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " {"); ChipLogProgress(Zcl, " ActiveTimestampPresent: %d,", entry.activeTimestampPresent); ChipLogProgress(Zcl, " PendingTimestampPresent: %d,", entry.pendingTimestampPresent); @@ -1479,6 +1628,7 @@ static void OnThreadNetworkDiagnosticsOperationalDatasetComponentsListAttributeR ChipLogProgress(Zcl, " SecurityPolicyPresent: %d,", entry.securityPolicyPresent); ChipLogProgress(Zcl, " ChannelMaskPresent: %d,", entry.channelMaskPresent); ChipLogProgress(Zcl, " },"); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -1523,8 +1673,8 @@ static void OnThreadNetworkDiagnosticsActiveNetworkFaultsListListAttributeRespon { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING ChipLogProgress(Zcl, " %" PRIu8 ",", entry); +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -7518,6 +7668,19 @@ chip::ChipError::StorageType chip_ime_WriteAttribute_TestCluster_VendorId(chip:: cluster.Associate(device, ZCLendpointId); return cluster.WriteAttributeVendorId(gDefaultSuccessCallback.Cancel(), gDefaultFailureCallback.Cancel(), value).AsInteger(); } +chip::ChipError::StorageType chip_ime_ReadAttribute_TestCluster_ListNullablesAndOptionalsStruct(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT.AsInteger()); + chip::Controller::TestClusterCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster + .ReadAttributeListNullablesAndOptionalsStruct(gTestClusterListNullablesAndOptionalsStructListAttributeCallback.Cancel(), + gDefaultFailureCallback.Cancel()) + .AsInteger(); +} + chip::ChipError::StorageType chip_ime_ReadAttribute_TestCluster_Unsupported(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId /* ZCLgroupId */) diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 7ebf65ead14596..113bfb127722f0 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -3476,6 +3476,11 @@ class ChipClusters: "type": "int", "writable": True, }, + 0x00000023: { + "attributeName": "ListNullablesAndOptionalsStruct", + "attributeId": 0x00000023, + "type": "", + }, 0x000000FF: { "attributeName": "Unsupported", "attributeId": 0x000000FF, @@ -6607,6 +6612,9 @@ def ClusterTestCluster_ReadAttributeVendorId(self, device: ctypes.c_void_p, ZCLe def ClusterTestCluster_WriteAttributeVendorId(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, value: int): return self._chipLib.chip_ime_WriteAttribute_TestCluster_VendorId(device, ZCLendpoint, ZCLgroupid, value) + def ClusterTestCluster_ReadAttributeListNullablesAndOptionalsStruct(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_TestCluster_ListNullablesAndOptionalsStruct(device, ZCLendpoint, ZCLgroupid) + def ClusterTestCluster_ReadAttributeUnsupported(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): return self._chipLib.chip_ime_ReadAttribute_TestCluster_Unsupported(device, ZCLendpoint, ZCLgroupid) @@ -9392,6 +9400,10 @@ def InitLib(self, chipLib): self._chipLib.chip_ime_WriteAttribute_TestCluster_VendorId.argtypes = [ ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16] self._chipLib.chip_ime_WriteAttribute_TestCluster_VendorId.restype = ctypes.c_uint32 + # Cluster TestCluster ReadAttribute ListNullablesAndOptionalsStruct + self._chipLib.chip_ime_ReadAttribute_TestCluster_ListNullablesAndOptionalsStruct.argtypes = [ + ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_TestCluster_ListNullablesAndOptionalsStruct.restype = ctypes.c_uint32 # Cluster TestCluster ReadAttribute Unsupported self._chipLib.chip_ime_ReadAttribute_TestCluster_Unsupported.argtypes = [ ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index d6d792285e69ee..c80e8b943c191f 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -21512,6 +21512,19 @@ def attribute_id(cls) -> int: def attribute_type(cls) -> ClusterObjectFieldDescriptor: return ClusterObjectFieldDescriptor(Type=uint) + class ListNullablesAndOptionalsStruct(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x050F + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x0023 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=TestCluster.Structs.NullablesAndOptionalsStruct, IsArray=True) + class Unsupported(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: diff --git a/src/controller/python/templates/python-CHIPClusters-cpp.zapt b/src/controller/python/templates/python-CHIPClusters-cpp.zapt index 3bf3017ff65295..7a64abacf92363 100644 --- a/src/controller/python/templates/python-CHIPClusters-cpp.zapt +++ b/src/controller/python/templates/python-CHIPClusters-cpp.zapt @@ -111,16 +111,37 @@ static void On{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}ListAttri { #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING {{#if isStruct}} ChipLogProgress(Zcl, " {"); {{#chip_attribute_list_entryTypes}} - {{#if (isOctetString type)}} - ChipLogProgress(Zcl, " {{asSymbol label}}: %s,", ByteSpanToString(entry.{{asLowerCamelCase name}}).c_str()); + {{~#*inline "field"}}entry.{{asLowerCamelCase name}}{{#if isOptional}}.Value(){{/if}}{{/inline~}} + {{~#*inline "fieldValue"}}{{>field}}{{#if isNullable}}.Value(){{/if}}{{/inline~}} + {{#if isOptional}} + if (entry.{{asLowerCamelCase name}}.HasValue()) { + {{/if}} + {{#if isNullable}} + if ({{>field}}.IsNull()) { + ChipLogProgress(chipTool, " {{asSymbol label}}: null"); + } else { + {{/if}} + {{#if isArray}} + {{! TODO: Add support for printing list member of struct element of list attribute }} + ChipLogProgress(chipTool, " {{asSymbol label}}: list member of struct element of list attribute printing not supported yet"); + {{else if (isOctetString type)}} + ChipLogProgress(Zcl, " {{asSymbol label}}: %s,", ByteSpanToString({{>fieldValue}}).c_str()); {{else if (isCharString type)}} - ChipLogProgress(Zcl, " {{asSymbol label}}: %.*s,", static_cast(entry.{{asLowerCamelCase name}}.size()), entry.{{asLowerCamelCase name}}.data()); + ChipLogProgress(Zcl, " {{asSymbol label}}: %.*s,", static_cast({{>fieldValue}}.size()), {{>fieldValue}}.data()); + {{else if isStruct}} + {{! TODO: Add support for printing struct member of struct element of list attribute }} + ChipLogProgress(chipTool, " {{asSymbol label}}: struct member of struct element of list attribute printing not supported yet"); {{else}} - ChipLogProgress(Zcl, " {{asSymbol label}}: {{asPrintFormat type}},", entry.{{asLowerCamelCase name}}); + ChipLogProgress(Zcl, " {{asSymbol label}}: {{asPrintFormat type}},", {{>fieldValue}}); + {{/if}} + {{#if isNullable}} + } + {{/if}} + {{#if isOptional}} + } {{/if}} {{/chip_attribute_list_entryTypes}} ChipLogProgress(Zcl, " },"); @@ -131,6 +152,7 @@ static void On{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}ListAttri {{else}} ChipLogProgress(Zcl, " {{asPrintFormat type}},", entry); {{/if}} +#endif // CHIP_PROGRESS_LOGGING } if (iter.GetStatus() != CHIP_NO_ERROR) { diff --git a/src/darwin/Framework/CHIP/templates/partials/CHIPCallbackBridge.zapt b/src/darwin/Framework/CHIP/templates/partials/CHIPCallbackBridge.zapt index d089aba436bea3..2bf8ca04a0ee21 100644 --- a/src/darwin/Framework/CHIP/templates/partials/CHIPCallbackBridge.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/CHIPCallbackBridge.zapt @@ -50,13 +50,24 @@ void CHIP{{> @partial-block}}Bridge::OnSuccessFn(void * context while (iter.Next()) { auto & entry = iter.GetValue(); + (void)entry; // All our types below might be unsupported {{#if isStruct}} [array addObject:@{ {{#chip_attribute_list_entryTypes}} - {{#if (isOctetString type)}} + {{#if isOptional}} + {{! TODO: Add support for optional types, probably by having a templated ToObjectiveCType function }} + {{else if isNullable}} + {{! TODO: Add support for nullable types, probably by having a templated ToObjectiveCType function }} + {{else if isArray}} + {{! TODO: Add support for list members of structs in list attributes }} + @"{{name}}": [[NSMutableArray alloc] init], + {{else if (isOctetString type)}} @"{{name}}" : [NSData dataWithBytes:entry.{{asLowerCamelCase name}}.data() length:entry.{{asLowerCamelCase name}}.size()], {{else if (isCharString type)}} @"{{name}}" : [[NSString alloc] initWithBytes:entry.{{asLowerCamelCase name}}.data() length:entry.{{asLowerCamelCase name}}.size() encoding:NSUTF8StringEncoding], + {{else if isStruct}} + {{! TODO: Add support for struct members of structs in list attributes }} + @"{{name}}": @{} {{else}} @"{{name}}" : [NSNumber numberWith{{asObjectiveCNumberType label type false}}:entry.{{asLowerCamelCase name}}], {{/if}} diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm index a52e71564494d9..797b491b40df88 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm @@ -84,6 +84,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSNumber numberWithUnsignedShort:entry]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -101,6 +102,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"index" : [NSNumber numberWithUnsignedChar:entry.index], @"outputType" : [NSNumber numberWithUnsignedChar:entry.outputType], @@ -122,6 +124,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"ActionID" : [NSNumber numberWithUnsignedShort:entry.actionID], @"Name" : [[NSString alloc] initWithBytes:entry.name.data() length:entry.name.size() encoding:NSUTF8StringEncoding], @@ -147,6 +150,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"EndpointListID" : [NSNumber numberWithUnsignedShort:entry.endpointListID], @"Name" : [[NSString alloc] initWithBytes:entry.name.data() length:entry.name.size() encoding:NSUTF8StringEncoding], @@ -169,6 +173,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSData dataWithBytes:entry.data() length:entry.size()]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -186,6 +191,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSNumber numberWithUnsignedChar:entry]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -203,6 +209,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"type" : [NSNumber numberWithUnsignedLong:entry.type], @"revision" : [NSNumber numberWithUnsignedShort:entry.revision], @@ -223,6 +230,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSNumber numberWithUnsignedLong:entry]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -240,6 +248,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSNumber numberWithUnsignedLong:entry]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -257,6 +266,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSNumber numberWithUnsignedShort:entry]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -274,6 +284,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"label" : [[NSString alloc] initWithBytes:entry.label.data() length:entry.label.size() encoding:NSUTF8StringEncoding], @"value" : [[NSString alloc] initWithBytes:entry.value.data() length:entry.value.size() encoding:NSUTF8StringEncoding], @@ -295,6 +306,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"FailSafeExpiryLengthMs" : [NSNumber numberWithUnsignedLong:entry.failSafeExpiryLengthMs], }]; @@ -315,6 +327,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"Name" : [[NSString alloc] initWithBytes:entry.name.data() length:entry.name.size() encoding:NSUTF8StringEncoding], @"FabricConnected" : [NSNumber numberWithBool:entry.fabricConnected], @@ -339,6 +352,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"VendorId" : [NSNumber numberWithUnsignedShort:entry.vendorId], @"VendorGroupId" : [NSNumber numberWithUnsignedShort:entry.vendorGroupId], @@ -360,6 +374,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"VendorId" : [NSNumber numberWithUnsignedShort:entry.vendorId], @"GroupKeyIndex" : [NSNumber numberWithUnsignedShort:entry.groupKeyIndex], @@ -383,6 +398,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"index" : [NSNumber numberWithUnsignedChar:entry.index], @"inputType" : [NSNumber numberWithUnsignedChar:entry.inputType], @@ -408,6 +424,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"FabricIndex" : [NSNumber numberWithUnsignedChar:entry.fabricIndex], @"RootPublicKey" : [NSData dataWithBytes:entry.rootPublicKey.data() length:entry.rootPublicKey.size()], @@ -432,6 +449,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSData dataWithBytes:entry.data() length:entry.size()]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -449,6 +467,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSNumber numberWithUnsignedChar:entry]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -466,6 +485,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"majorNumber" : [NSNumber numberWithUnsignedShort:entry.majorNumber], @"minorNumber" : [NSNumber numberWithUnsignedShort:entry.minorNumber], @@ -494,6 +514,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"identifier" : [NSNumber numberWithUnsignedChar:entry.identifier], @"name" : [[NSString alloc] initWithBytes:entry.name.data() length:entry.name.size() encoding:NSUTF8StringEncoding], @@ -514,6 +535,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSNumber numberWithUnsignedChar:entry]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -531,6 +553,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSData dataWithBytes:entry.data() length:entry.size()]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { @@ -548,6 +571,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"fabricIndex" : [NSNumber numberWithUnsignedLongLong:entry.fabricIndex], @"operationalCert" : [NSData dataWithBytes:entry.operationalCert.data() length:entry.operationalCert.size()], @@ -561,6 +585,25 @@ DispatchSuccess(context, @ { @"value" : array }); }; +void CHIPTestClusterListNullablesAndOptionalsStructListAttributeCallbackBridge::OnSuccessFn(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::TestCluster::Structs::NullablesAndOptionalsStruct::DecodableType> & list) +{ + id array = [[NSMutableArray alloc] init]; + auto iter = list.begin(); + while (iter.Next()) { + auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported + [array addObject:@ {}]; + } + if (iter.GetStatus() != CHIP_NO_ERROR) { + OnFailureFn(context, EMBER_ZCL_STATUS_INVALID_VALUE); + return; + } + + DispatchSuccess(context, @ { @"value" : array }); +}; + void CHIPThreadNetworkDiagnosticsNeighborTableListListAttributeCallbackBridge::OnSuccessFn(void * context, const chip::app::DataModel::DecodableList< chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::DecodableType> & list) @@ -569,6 +612,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"ExtAddress" : [NSNumber numberWithUnsignedLongLong:entry.extAddress], @"Age" : [NSNumber numberWithUnsignedLong:entry.age], @@ -602,6 +646,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"ExtAddress" : [NSNumber numberWithUnsignedLongLong:entry.extAddress], @"Rloc16" : [NSNumber numberWithUnsignedShort:entry.rloc16], @@ -631,6 +676,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"RotationTime" : [NSNumber numberWithUnsignedShort:entry.rotationTime], @"Flags" : [NSNumber numberWithUnsignedShort:entry.flags], @@ -652,6 +698,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:@ { @"ActiveTimestampPresent" : [NSNumber numberWithBool:entry.activeTimestampPresent], @"PendingTimestampPresent" : [NSNumber numberWithBool:entry.pendingTimestampPresent], @@ -682,6 +729,7 @@ auto iter = list.begin(); while (iter.Next()) { auto & entry = iter.GetValue(); + (void) entry; // All our types below might be unsupported [array addObject:[NSNumber numberWithUnsignedChar:entry]]; } if (iter.GetStatus() != CHIP_NO_ERROR) { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h index 6fc46dddefc907..7656ac5a8e5520 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h @@ -444,6 +444,20 @@ class CHIPTestClusterListStructOctetStringListAttributeCallbackBridge list); }; +class CHIPTestClusterListNullablesAndOptionalsStructListAttributeCallbackBridge + : public CHIPCallbackBridge +{ +public: + CHIPTestClusterListNullablesAndOptionalsStructListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + CHIPActionBlock action, bool keepAlive = false) : + CHIPCallbackBridge(queue, handler, action, OnSuccessFn, + keepAlive){}; + + static void OnSuccessFn(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::TestCluster::Structs::NullablesAndOptionalsStruct::DecodableType> & list); +}; + class CHIPThreadNetworkDiagnosticsNeighborTableListListAttributeCallbackBridge : public CHIPCallbackBridge { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h index 56cee2c269fe33..b41ea8a46b307c 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h @@ -1669,6 +1669,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)readAttributeVendorIdWithResponseHandler:(ResponseHandler)responseHandler; - (void)writeAttributeVendorIdWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeListNullablesAndOptionalsStructWithResponseHandler:(ResponseHandler)responseHandler; + - (void)readAttributeUnsupportedWithResponseHandler:(ResponseHandler)responseHandler; - (void)writeAttributeUnsupportedWithValue:(bool)value responseHandler:(ResponseHandler)responseHandler; diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm index af528a7cd6719a..d9e065a1d08ea5 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm @@ -5096,6 +5096,14 @@ new CHIPDefaultSuccessCallbackBridge(self.callbackQueue, responseHandler, ^(Canc }); } +- (void)readAttributeListNullablesAndOptionalsStructWithResponseHandler:(ResponseHandler)responseHandler +{ + new CHIPTestClusterListNullablesAndOptionalsStructListAttributeCallbackBridge( + self.callbackQueue, responseHandler, ^(Cancelable * success, Cancelable * failure) { + return self.cppCluster.ReadAttributeListNullablesAndOptionalsStruct(success, failure); + }); +} + - (void)readAttributeUnsupportedWithResponseHandler:(ResponseHandler)responseHandler { new CHIPBooleanAttributeCallbackBridge(self.callbackQueue, responseHandler, ^(Cancelable * success, Cancelable * failure) { diff --git a/zzz_generated/all-clusters-app/zap-generated/attribute-size.cpp b/zzz_generated/all-clusters-app/zap-generated/attribute-size.cpp index 6b2f90fd3ac906..df89aff5897748 100644 --- a/zzz_generated/all-clusters-app/zap-generated/attribute-size.cpp +++ b/zzz_generated/all-clusters-app/zap-generated/attribute-size.cpp @@ -781,6 +781,73 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo entryOffset = static_cast(entryOffset + 34); break; } + case 0x0023: // list_nullables_and_optionals_struct + { + entryLength = 39; + if (((index - 1) * entryLength) > (am->size - entryLength)) + { + ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); + return 0; + } + entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); + // Struct _NullablesAndOptionalsStruct + _NullablesAndOptionalsStruct * entry = reinterpret_cast<_NullablesAndOptionalsStruct *>(write ? src : dest); + copyListMember(write ? dest : (uint8_t *) &entry->NullableInt, write ? (uint8_t *) &entry->NullableInt : src, write, + &entryOffset, sizeof(entry->NullableInt)); // INT16U + copyListMember(write ? dest : (uint8_t *) &entry->OptionalInt, write ? (uint8_t *) &entry->OptionalInt : src, write, + &entryOffset, sizeof(entry->OptionalInt)); // INT16U + copyListMember(write ? dest : (uint8_t *) &entry->NullableOptionalInt, + write ? (uint8_t *) &entry->NullableOptionalInt : src, write, &entryOffset, + sizeof(entry->NullableOptionalInt)); // INT16U + ByteSpan NullableStringSpanStorage(Uint8::from_const_char(entry->NullableString.data()), + entry->NullableString.size()); // CHAR_STRING + ByteSpan * NullableStringSpan = &NullableStringSpanStorage; + if (CHIP_NO_ERROR != + (write ? WriteByteSpan(dest + entryOffset, 2, NullableStringSpan) + : ReadByteSpan(src + entryOffset, 2, NullableStringSpan))) + { + ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); + return 0; + } + entryOffset = static_cast(entryOffset + 2); + ByteSpan OptionalStringSpanStorage(Uint8::from_const_char(entry->OptionalString.data()), + entry->OptionalString.size()); // CHAR_STRING + ByteSpan * OptionalStringSpan = &OptionalStringSpanStorage; + if (CHIP_NO_ERROR != + (write ? WriteByteSpan(dest + entryOffset, 2, OptionalStringSpan) + : ReadByteSpan(src + entryOffset, 2, OptionalStringSpan))) + { + ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); + return 0; + } + entryOffset = static_cast(entryOffset + 2); + ByteSpan NullableOptionalStringSpanStorage(Uint8::from_const_char(entry->NullableOptionalString.data()), + entry->NullableOptionalString.size()); // CHAR_STRING + ByteSpan * NullableOptionalStringSpan = &NullableOptionalStringSpanStorage; + if (CHIP_NO_ERROR != + (write ? WriteByteSpan(dest + entryOffset, 2, NullableOptionalStringSpan) + : ReadByteSpan(src + entryOffset, 2, NullableOptionalStringSpan))) + { + ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); + return 0; + } + entryOffset = static_cast(entryOffset + 2); + copyListMember(write ? dest : (uint8_t *) &entry->NullableStruct, write ? (uint8_t *) &entry->NullableStruct : src, + write, &entryOffset, sizeof(entry->NullableStruct)); // SimpleStruct + copyListMember(write ? dest : (uint8_t *) &entry->OptionalStruct, write ? (uint8_t *) &entry->OptionalStruct : src, + write, &entryOffset, sizeof(entry->OptionalStruct)); // SimpleStruct + copyListMember(write ? dest : (uint8_t *) &entry->NullableOptionalStruct, + write ? (uint8_t *) &entry->NullableOptionalStruct : src, write, &entryOffset, + sizeof(entry->NullableOptionalStruct)); // SimpleStruct + copyListMember(write ? dest : (uint8_t *) &entry->NullableList, write ? (uint8_t *) &entry->NullableList : src, write, + &entryOffset, sizeof(entry->NullableList)); // SimpleEnum + copyListMember(write ? dest : (uint8_t *) &entry->OptionalList, write ? (uint8_t *) &entry->OptionalList : src, write, + &entryOffset, sizeof(entry->OptionalList)); // SimpleEnum + copyListMember(write ? dest : (uint8_t *) &entry->NullableOptionalList, + write ? (uint8_t *) &entry->NullableOptionalList : src, write, &entryOffset, + sizeof(entry->NullableOptionalList)); // SimpleEnum + break; + } } break; } @@ -1127,6 +1194,10 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut // Struct _TestListStructOctet entryLength = 42; break; + case 0x0023: // list_nullables_and_optionals_struct + // Struct _NullablesAndOptionalsStruct + entryLength = 39; + break; } break; case 0x0035: // Thread Network Diagnostics Cluster 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 034e03542686d8..68462dbddf1918 100644 --- a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h +++ b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h @@ -2049,7 +2049,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 491 +#define GENERATED_ATTRIBUTE_COUNT 492 #define GENERATED_ATTRIBUTES \ { \ \ @@ -2657,7 +2657,9 @@ { 0x0020, ZAP_TYPE(EPOCH_US), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_LONG_DEFAULTS_INDEX(9998) }, /* epoch_us */ \ { 0x0021, ZAP_TYPE(EPOCH_S), 4, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_LONG_DEFAULTS_INDEX(10006) }, /* epoch_s */ \ { 0x0022, ZAP_TYPE(VENDOR_ID), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* vendor_id */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x0023, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* list_nullables_and_optionals_struct */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 1, Cluster: Electrical Measurement (server) */ \ { 0x0000, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(10010) }, /* measurement type */ \ @@ -2960,25 +2962,25 @@ 0x050E, ZAP_ATTRIBUTE_INDEX(435), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Account Login (server) */ \ { \ - 0x050F, ZAP_ATTRIBUTE_INDEX(436), 26, 2609, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050F, ZAP_ATTRIBUTE_INDEX(436), 27, 2609, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Test Cluster (server) */ \ { \ - 0x0B04, ZAP_ATTRIBUTE_INDEX(462), 12, 28, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0B04, ZAP_ATTRIBUTE_INDEX(463), 12, 28, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Electrical Measurement (server) */ \ { \ - 0xF000, ZAP_ATTRIBUTE_INDEX(474), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF000, ZAP_ATTRIBUTE_INDEX(475), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Binding (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(475), \ + ZAP_ATTRIBUTE_INDEX(476), \ 7, \ 13, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 2, Cluster: On/Off (server) */ \ { \ - 0x001D, ZAP_ATTRIBUTE_INDEX(482), 5, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x001D, ZAP_ATTRIBUTE_INDEX(483), 5, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 2, Cluster: Descriptor (server) */ \ { 0x0406, \ - ZAP_ATTRIBUTE_INDEX(487), \ + ZAP_ATTRIBUTE_INDEX(488), \ 4, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ diff --git a/zzz_generated/app-common/app-common/zap-generated/attribute-id.h b/zzz_generated/app-common/app-common/zap-generated/attribute-id.h index b756bcbaf2d6de..803724b07b468d 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attribute-id.h +++ b/zzz_generated/app-common/app-common/zap-generated/attribute-id.h @@ -1379,6 +1379,7 @@ #define ZCL_EPOCH_US_ATTRIBUTE_ID (0x0020) #define ZCL_EPOCH_S_ATTRIBUTE_ID (0x0021) #define ZCL_TEST_VENDOR_ID_ATTRIBUTE_ID (0x0022) +#define ZCL_LIST_OF_STRUCTS_WITH_OPTIONALS_ATTRIBUTE_ID (0x0023) #define ZCL_UNSUPPORTED_ATTRIBUTE_ID (0x00FF) // Attribute ids for cluster: 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 2a30a3c391327d..14e1b306b12988 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 @@ -24325,6 +24325,16 @@ struct TypeInfo static constexpr AttributeId GetAttributeId() { return Attributes::VendorId::Id; } }; } // namespace VendorId +namespace ListNullablesAndOptionalsStruct { +struct TypeInfo +{ + using Type = DataModel::List; + using DecodableType = DataModel::DecodableList; + + static constexpr ClusterId GetClusterId() { return Clusters::TestCluster::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::ListNullablesAndOptionalsStruct::Id; } +}; +} // namespace ListNullablesAndOptionalsStruct namespace Unsupported { struct TypeInfo { diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index 53e5c5cf75b79c..fcde86803732b0 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -4474,6 +4474,10 @@ namespace VendorId { static constexpr AttributeId Id = 0x00000022; } // namespace VendorId +namespace ListNullablesAndOptionalsStruct { +static constexpr AttributeId Id = 0x00000023; +} // namespace ListNullablesAndOptionalsStruct + namespace Unsupported { static constexpr AttributeId Id = 0x000000FF; } // namespace Unsupported diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 4b4f4bd5e63644..d46f4967ddcf78 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -172,11 +172,11 @@ OnApplicationLauncherApplicationLauncherListListAttributeResponse(void * context uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "INT16U[%" PRIu16 "]: %" PRIu16 "", i, entry); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -201,14 +201,14 @@ static void OnAudioOutputAudioOutputListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "AudioOutputInfo[%" PRIu16 "]:", i); ChipLogProgress(chipTool, " index: %" PRIu8 "", entry.index); ChipLogProgress(chipTool, " outputType: %" PRIu8 "", entry.outputType); ChipLogProgress(Zcl, " name: %.*s", static_cast(entry.name.size()), entry.name.data()); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -233,17 +233,17 @@ static void OnBridgedActionsActionListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "ActionStruct[%" PRIu16 "]:", i); - ChipLogProgress(chipTool, " actionID: %" PRIu16 "", entry.actionID); + ChipLogProgress(chipTool, " ActionID: %" PRIu16 "", entry.actionID); ChipLogProgress(Zcl, " Name: %.*s", static_cast(entry.name.size()), entry.name.data()); - ChipLogProgress(chipTool, " type: %" PRIu8 "", entry.type); - ChipLogProgress(chipTool, " endpointListID: %" PRIu16 "", entry.endpointListID); - ChipLogProgress(chipTool, " supportedCommands: %" PRIu16 "", entry.supportedCommands); - ChipLogProgress(chipTool, " status: %" PRIu8 "", entry.status); + ChipLogProgress(chipTool, " Type: %" PRIu8 "", entry.type); + ChipLogProgress(chipTool, " EndpointListID: %" PRIu16 "", entry.endpointListID); + ChipLogProgress(chipTool, " SupportedCommands: %" PRIu16 "", entry.supportedCommands); + ChipLogProgress(chipTool, " Status: %" PRIu8 "", entry.status); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -269,15 +269,15 @@ static void OnBridgedActionsEndpointListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "EndpointListStruct[%" PRIu16 "]:", i); - ChipLogProgress(chipTool, " endpointListID: %" PRIu16 "", entry.endpointListID); + ChipLogProgress(chipTool, " EndpointListID: %" PRIu16 "", entry.endpointListID); ChipLogProgress(Zcl, " Name: %.*s", static_cast(entry.name.size()), entry.name.data()); - ChipLogProgress(chipTool, " type: %" PRIu8 "", entry.type); + ChipLogProgress(chipTool, " Type: %" PRIu8 "", entry.type); ChipLogProgress(Zcl, " Endpoints: %zu", entry.endpoints.size()); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -302,11 +302,11 @@ OnContentLauncherAcceptsHeaderListListAttributeResponse(void * context, uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(Zcl, " : %zu", entry.size()); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -331,11 +331,11 @@ static void OnContentLauncherSupportedStreamingTypesListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "ContentLaunchStreamingType[%" PRIu16 "]: %" PRIu8 "", i, entry); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -360,13 +360,13 @@ static void OnDescriptorDeviceListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "DeviceType[%" PRIu16 "]:", i); ChipLogProgress(chipTool, " type: %" PRIu32 "", entry.type); ChipLogProgress(chipTool, " revision: %" PRIu16 "", entry.revision); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -390,11 +390,11 @@ static void OnDescriptorServerListListAttributeResponse(void * context, uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "CLUSTER_ID[%" PRIu16 "]: %" PRIu32 "", i, entry); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -418,11 +418,11 @@ static void OnDescriptorClientListListAttributeResponse(void * context, uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "CLUSTER_ID[%" PRIu16 "]: %" PRIu32 "", i, entry); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -446,11 +446,11 @@ static void OnDescriptorPartsListListAttributeResponse(void * context, uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "ENDPOINT_NO[%" PRIu16 "]: %" PRIu16 "", i, entry); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -475,13 +475,13 @@ static void OnFixedLabelLabelListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "LabelStruct[%" PRIu16 "]:", i); ChipLogProgress(Zcl, " label: %.*s", static_cast(entry.label.size()), entry.label.data()); ChipLogProgress(Zcl, " value: %.*s", static_cast(entry.value.size()), entry.value.data()); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -507,12 +507,12 @@ static void OnGeneralCommissioningBasicCommissioningInfoListListAttributeRespons uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "BasicCommissioningInfoType[%" PRIu16 "]:", i); - ChipLogProgress(chipTool, " failSafeExpiryLengthMs: %" PRIu32 "", entry.failSafeExpiryLengthMs); + ChipLogProgress(chipTool, " FailSafeExpiryLengthMs: %" PRIu32 "", entry.failSafeExpiryLengthMs); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -538,17 +538,17 @@ static void OnGeneralDiagnosticsNetworkInterfacesListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "NetworkInterfaceType[%" PRIu16 "]:", i); ChipLogProgress(Zcl, " Name: %.*s", static_cast(entry.name.size()), entry.name.data()); - ChipLogProgress(chipTool, " fabricConnected: %d", entry.fabricConnected); - ChipLogProgress(chipTool, " offPremiseServicesReachableIPv4: %d", entry.offPremiseServicesReachableIPv4); - ChipLogProgress(chipTool, " offPremiseServicesReachableIPv6: %d", entry.offPremiseServicesReachableIPv6); + ChipLogProgress(chipTool, " FabricConnected: %d", entry.fabricConnected); + ChipLogProgress(chipTool, " OffPremiseServicesReachableIPv4: %d", entry.offPremiseServicesReachableIPv4); + ChipLogProgress(chipTool, " OffPremiseServicesReachableIPv6: %d", entry.offPremiseServicesReachableIPv6); ChipLogProgress(Zcl, " HardwareAddress: %zu", entry.hardwareAddress.size()); - ChipLogProgress(chipTool, " type: %" PRIu8 "", entry.type); + ChipLogProgress(chipTool, " Type: %" PRIu8 "", entry.type); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -573,14 +573,14 @@ static void OnGroupKeyManagementGroupsListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "GroupState[%" PRIu16 "]:", i); - ChipLogProgress(chipTool, " vendorId: %" PRIu16 "", entry.vendorId); - ChipLogProgress(chipTool, " vendorGroupId: %" PRIu16 "", entry.vendorGroupId); - ChipLogProgress(chipTool, " groupKeySetIndex: %" PRIu16 "", entry.groupKeySetIndex); + ChipLogProgress(chipTool, " VendorId: %" PRIu16 "", entry.vendorId); + ChipLogProgress(chipTool, " VendorGroupId: %" PRIu16 "", entry.vendorGroupId); + ChipLogProgress(chipTool, " GroupKeySetIndex: %" PRIu16 "", entry.groupKeySetIndex); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -605,16 +605,16 @@ static void OnGroupKeyManagementGroupKeysListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "GroupKey[%" PRIu16 "]:", i); - ChipLogProgress(chipTool, " vendorId: %" PRIu16 "", entry.vendorId); - ChipLogProgress(chipTool, " groupKeyIndex: %" PRIu16 "", entry.groupKeyIndex); + ChipLogProgress(chipTool, " VendorId: %" PRIu16 "", entry.vendorId); + ChipLogProgress(chipTool, " GroupKeyIndex: %" PRIu16 "", entry.groupKeyIndex); ChipLogProgress(Zcl, " GroupKeyRoot: %zu", entry.groupKeyRoot.size()); - ChipLogProgress(chipTool, " groupKeyEpochStartTime: %" PRIu64 "", entry.groupKeyEpochStartTime); - ChipLogProgress(chipTool, " groupKeySecurityPolicy: %" PRIu8 "", entry.groupKeySecurityPolicy); + ChipLogProgress(chipTool, " GroupKeyEpochStartTime: %" PRIu64 "", entry.groupKeyEpochStartTime); + ChipLogProgress(chipTool, " GroupKeySecurityPolicy: %" PRIu8 "", entry.groupKeySecurityPolicy); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -639,15 +639,15 @@ static void OnMediaInputMediaInputListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "MediaInputInfo[%" PRIu16 "]:", i); ChipLogProgress(chipTool, " index: %" PRIu8 "", entry.index); ChipLogProgress(chipTool, " inputType: %" PRIu8 "", entry.inputType); ChipLogProgress(Zcl, " name: %.*s", static_cast(entry.name.size()), entry.name.data()); ChipLogProgress(Zcl, " description: %.*s", static_cast(entry.description.size()), entry.description.data()); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -673,17 +673,17 @@ static void OnOperationalCredentialsFabricsListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "FabricDescriptor[%" PRIu16 "]:", i); - ChipLogProgress(chipTool, " fabricIndex: %" PRIu8 "", entry.fabricIndex); + ChipLogProgress(chipTool, " FabricIndex: %" PRIu8 "", entry.fabricIndex); ChipLogProgress(Zcl, " RootPublicKey: %zu", entry.rootPublicKey.size()); - ChipLogProgress(chipTool, " vendorId: %" PRIu16 "", entry.vendorId); - ChipLogProgress(chipTool, " fabricId: %" PRIu64 "", entry.fabricId); - ChipLogProgress(chipTool, " nodeId: %" PRIu64 "", entry.nodeId); + ChipLogProgress(chipTool, " VendorId: %" PRIu16 "", entry.vendorId); + ChipLogProgress(chipTool, " FabricId: %" PRIu64 "", entry.fabricId); + ChipLogProgress(chipTool, " NodeId: %" PRIu64 "", entry.nodeId); ChipLogProgress(Zcl, " Label: %.*s", static_cast(entry.label.size()), entry.label.data()); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -707,11 +707,11 @@ static void OnOperationalCredentialsTrustedRootCertificatesListAttributeResponse uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(Zcl, " : %zu", entry.size()); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -735,11 +735,11 @@ static void OnPowerSourceActiveBatteryFaultsListAttributeResponse(void * context uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "ENUM8[%" PRIu16 "]: %" PRIu8 "", i, entry); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -764,10 +764,9 @@ static void OnTvChannelTvChannelListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "TvChannelInfo[%" PRIu16 "]:", i); ChipLogProgress(chipTool, " majorNumber: %" PRIu16 "", entry.majorNumber); ChipLogProgress(chipTool, " minorNumber: %" PRIu16 "", entry.minorNumber); @@ -775,6 +774,7 @@ static void OnTvChannelTvChannelListListAttributeResponse( ChipLogProgress(Zcl, " callSign: %.*s", static_cast(entry.callSign.size()), entry.callSign.data()); ChipLogProgress(Zcl, " affiliateCallSign: %.*s", static_cast(entry.affiliateCallSign.size()), entry.affiliateCallSign.data()); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -800,13 +800,13 @@ static void OnTargetNavigatorTargetNavigatorListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "NavigateTargetTargetInfo[%" PRIu16 "]:", i); ChipLogProgress(chipTool, " identifier: %" PRIu8 "", entry.identifier); ChipLogProgress(Zcl, " name: %.*s", static_cast(entry.name.size()), entry.name.data()); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -829,11 +829,11 @@ static void OnTestClusterListInt8uListAttributeResponse(void * context, const ch uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "INT8U[%" PRIu16 "]: %" PRIu8 "", i, entry); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -857,11 +857,11 @@ static void OnTestClusterListOctetStringListAttributeResponse(void * context, uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(Zcl, " : %zu", entry.size()); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -886,13 +886,144 @@ static void OnTestClusterListStructOctetStringListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "TestListStructOctet[%" PRIu16 "]:", i); ChipLogProgress(chipTool, " fabricIndex: %" PRIu64 "", entry.fabricIndex); ChipLogProgress(Zcl, " operationalCert: %zu", entry.operationalCert.size()); +#endif // CHIP_PROGRESS_LOGGING + } + command->SetCommandExitStatus(iter.GetStatus()); +} + +static void OnTestClusterListNullablesAndOptionalsStructListAttributeResponse( + void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::TestCluster::Structs::NullablesAndOptionalsStruct::DecodableType> & list) +{ + ModelCommand * command = static_cast(context); + + size_t count = 0; + CHIP_ERROR err = list.ComputeSize(&count); + if (err != CHIP_NO_ERROR) + { + command->SetCommandExitStatus(err); + return; + } + + ChipLogProgress(chipTool, "OnTestClusterListNullablesAndOptionalsStructListAttributeResponse: %zu entries", count); + + auto iter = list.begin(); + uint16_t i = 0; + while (iter.Next()) + { + ++i; +#if CHIP_PROGRESS_LOGGING + auto & entry = iter.GetValue(); + ChipLogProgress(chipTool, "NullablesAndOptionalsStruct[%" PRIu16 "]:", i); + if (entry.nullableInt.IsNull()) + { + ChipLogProgress(chipTool, " NullableInt: null"); + } + else + { + ChipLogProgress(chipTool, " NullableInt: %" PRIu16 "", entry.nullableInt.Value()); + } + if (entry.optionalInt.HasValue()) + { + ChipLogProgress(chipTool, " OptionalInt: %" PRIu16 "", entry.optionalInt.Value()); + } + if (entry.nullableOptionalInt.HasValue()) + { + if (entry.nullableOptionalInt.Value().IsNull()) + { + ChipLogProgress(chipTool, " NullableOptionalInt: null"); + } + else + { + ChipLogProgress(chipTool, " NullableOptionalInt: %" PRIu16 "", entry.nullableOptionalInt.Value().Value()); + } + } + if (entry.nullableString.IsNull()) + { + ChipLogProgress(chipTool, " NullableString: null"); + } + else + { + ChipLogProgress(Zcl, " NullableString: %.*s", static_cast(entry.nullableString.Value().size()), + entry.nullableString.Value().data()); + } + if (entry.optionalString.HasValue()) + { + ChipLogProgress(Zcl, " OptionalString: %.*s", static_cast(entry.optionalString.Value().size()), + entry.optionalString.Value().data()); + } + if (entry.nullableOptionalString.HasValue()) + { + if (entry.nullableOptionalString.Value().IsNull()) + { + ChipLogProgress(chipTool, " NullableOptionalString: null"); + } + else + { + ChipLogProgress(Zcl, " NullableOptionalString: %.*s", + static_cast(entry.nullableOptionalString.Value().Value().size()), + entry.nullableOptionalString.Value().Value().data()); + } + } + if (entry.nullableStruct.IsNull()) + { + ChipLogProgress(chipTool, " NullableStruct: null"); + } + else + { + ChipLogProgress(chipTool, + " NullableStruct: struct member of struct element of list attribute printing not supported yet"); + } + if (entry.optionalStruct.HasValue()) + { + ChipLogProgress(chipTool, + " OptionalStruct: struct member of struct element of list attribute printing not supported yet"); + } + if (entry.nullableOptionalStruct.HasValue()) + { + if (entry.nullableOptionalStruct.Value().IsNull()) + { + ChipLogProgress(chipTool, " NullableOptionalStruct: null"); + } + else + { + ChipLogProgress( + chipTool, + " NullableOptionalStruct: struct member of struct element of list attribute printing not supported yet"); + } + } + if (entry.nullableList.IsNull()) + { + ChipLogProgress(chipTool, " NullableList: null"); + } + else + { + ChipLogProgress(chipTool, " NullableList: list member of struct element of list attribute printing not supported yet"); + } + if (entry.optionalList.HasValue()) + { + ChipLogProgress(chipTool, " OptionalList: list member of struct element of list attribute printing not supported yet"); + } + if (entry.nullableOptionalList.HasValue()) + { + if (entry.nullableOptionalList.Value().IsNull()) + { + ChipLogProgress(chipTool, " NullableOptionalList: null"); + } + else + { + ChipLogProgress( + chipTool, " NullableOptionalList: list member of struct element of list attribute printing not supported yet"); + } + } +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -918,25 +1049,25 @@ static void OnThreadNetworkDiagnosticsNeighborTableListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "NeighborTable[%" PRIu16 "]:", i); - ChipLogProgress(chipTool, " extAddress: %" PRIu64 "", entry.extAddress); - ChipLogProgress(chipTool, " age: %" PRIu32 "", entry.age); - ChipLogProgress(chipTool, " rloc16: %" PRIu16 "", entry.rloc16); - ChipLogProgress(chipTool, " linkFrameCounter: %" PRIu32 "", entry.linkFrameCounter); - ChipLogProgress(chipTool, " mleFrameCounter: %" PRIu32 "", entry.mleFrameCounter); - ChipLogProgress(chipTool, " lqi: %" PRIu8 "", entry.lqi); - ChipLogProgress(chipTool, " averageRssi: %" PRId8 "", entry.averageRssi); - ChipLogProgress(chipTool, " lastRssi: %" PRId8 "", entry.lastRssi); - ChipLogProgress(chipTool, " frameErrorRate: %" PRIu8 "", entry.frameErrorRate); - ChipLogProgress(chipTool, " messageErrorRate: %" PRIu8 "", entry.messageErrorRate); - ChipLogProgress(chipTool, " rxOnWhenIdle: %d", entry.rxOnWhenIdle); - ChipLogProgress(chipTool, " fullThreadDevice: %d", entry.fullThreadDevice); - ChipLogProgress(chipTool, " fullNetworkData: %d", entry.fullNetworkData); - ChipLogProgress(chipTool, " isChild: %d", entry.isChild); + ChipLogProgress(chipTool, " ExtAddress: %" PRIu64 "", entry.extAddress); + ChipLogProgress(chipTool, " Age: %" PRIu32 "", entry.age); + ChipLogProgress(chipTool, " Rloc16: %" PRIu16 "", entry.rloc16); + ChipLogProgress(chipTool, " LinkFrameCounter: %" PRIu32 "", entry.linkFrameCounter); + ChipLogProgress(chipTool, " MleFrameCounter: %" PRIu32 "", entry.mleFrameCounter); + ChipLogProgress(chipTool, " LQI: %" PRIu8 "", entry.lqi); + ChipLogProgress(chipTool, " AverageRssi: %" PRId8 "", entry.averageRssi); + ChipLogProgress(chipTool, " LastRssi: %" PRId8 "", entry.lastRssi); + ChipLogProgress(chipTool, " FrameErrorRate: %" PRIu8 "", entry.frameErrorRate); + ChipLogProgress(chipTool, " MessageErrorRate: %" PRIu8 "", entry.messageErrorRate); + ChipLogProgress(chipTool, " RxOnWhenIdle: %d", entry.rxOnWhenIdle); + ChipLogProgress(chipTool, " FullThreadDevice: %d", entry.fullThreadDevice); + ChipLogProgress(chipTool, " FullNetworkData: %d", entry.fullNetworkData); + ChipLogProgress(chipTool, " IsChild: %d", entry.isChild); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -962,21 +1093,21 @@ static void OnThreadNetworkDiagnosticsRouteTableListListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "RouteTable[%" PRIu16 "]:", i); - ChipLogProgress(chipTool, " extAddress: %" PRIu64 "", entry.extAddress); - ChipLogProgress(chipTool, " rloc16: %" PRIu16 "", entry.rloc16); - ChipLogProgress(chipTool, " routerId: %" PRIu8 "", entry.routerId); - ChipLogProgress(chipTool, " nextHop: %" PRIu8 "", entry.nextHop); - ChipLogProgress(chipTool, " pathCost: %" PRIu8 "", entry.pathCost); + ChipLogProgress(chipTool, " ExtAddress: %" PRIu64 "", entry.extAddress); + ChipLogProgress(chipTool, " Rloc16: %" PRIu16 "", entry.rloc16); + ChipLogProgress(chipTool, " RouterId: %" PRIu8 "", entry.routerId); + ChipLogProgress(chipTool, " NextHop: %" PRIu8 "", entry.nextHop); + ChipLogProgress(chipTool, " PathCost: %" PRIu8 "", entry.pathCost); ChipLogProgress(chipTool, " LQIIn: %" PRIu8 "", entry.LQIIn); ChipLogProgress(chipTool, " LQIOut: %" PRIu8 "", entry.LQIOut); - ChipLogProgress(chipTool, " age: %" PRIu8 "", entry.age); - ChipLogProgress(chipTool, " allocated: %d", entry.allocated); - ChipLogProgress(chipTool, " linkEstablished: %d", entry.linkEstablished); + ChipLogProgress(chipTool, " Age: %" PRIu8 "", entry.age); + ChipLogProgress(chipTool, " Allocated: %d", entry.allocated); + ChipLogProgress(chipTool, " LinkEstablished: %d", entry.linkEstablished); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -1002,13 +1133,13 @@ static void OnThreadNetworkDiagnosticsSecurityPolicyListAttributeResponse( uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "SecurityPolicy[%" PRIu16 "]:", i); - ChipLogProgress(chipTool, " rotationTime: %" PRIu16 "", entry.rotationTime); - ChipLogProgress(chipTool, " flags: %" PRIu16 "", entry.flags); + ChipLogProgress(chipTool, " RotationTime: %" PRIu16 "", entry.rotationTime); + ChipLogProgress(chipTool, " Flags: %" PRIu16 "", entry.flags); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -1034,23 +1165,23 @@ static void OnThreadNetworkDiagnosticsOperationalDatasetComponentsListAttributeR uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "OperationalDatasetComponents[%" PRIu16 "]:", i); - ChipLogProgress(chipTool, " activeTimestampPresent: %d", entry.activeTimestampPresent); - ChipLogProgress(chipTool, " pendingTimestampPresent: %d", entry.pendingTimestampPresent); - ChipLogProgress(chipTool, " masterKeyPresent: %d", entry.masterKeyPresent); - ChipLogProgress(chipTool, " networkNamePresent: %d", entry.networkNamePresent); - ChipLogProgress(chipTool, " extendedPanIdPresent: %d", entry.extendedPanIdPresent); - ChipLogProgress(chipTool, " meshLocalPrefixPresent: %d", entry.meshLocalPrefixPresent); - ChipLogProgress(chipTool, " delayPresent: %d", entry.delayPresent); - ChipLogProgress(chipTool, " panIdPresent: %d", entry.panIdPresent); - ChipLogProgress(chipTool, " channelPresent: %d", entry.channelPresent); - ChipLogProgress(chipTool, " pskcPresent: %d", entry.pskcPresent); - ChipLogProgress(chipTool, " securityPolicyPresent: %d", entry.securityPolicyPresent); - ChipLogProgress(chipTool, " channelMaskPresent: %d", entry.channelMaskPresent); + ChipLogProgress(chipTool, " ActiveTimestampPresent: %d", entry.activeTimestampPresent); + ChipLogProgress(chipTool, " PendingTimestampPresent: %d", entry.pendingTimestampPresent); + ChipLogProgress(chipTool, " MasterKeyPresent: %d", entry.masterKeyPresent); + ChipLogProgress(chipTool, " NetworkNamePresent: %d", entry.networkNamePresent); + ChipLogProgress(chipTool, " ExtendedPanIdPresent: %d", entry.extendedPanIdPresent); + ChipLogProgress(chipTool, " MeshLocalPrefixPresent: %d", entry.meshLocalPrefixPresent); + ChipLogProgress(chipTool, " DelayPresent: %d", entry.delayPresent); + ChipLogProgress(chipTool, " PanIdPresent: %d", entry.panIdPresent); + ChipLogProgress(chipTool, " ChannelPresent: %d", entry.channelPresent); + ChipLogProgress(chipTool, " PskcPresent: %d", entry.pskcPresent); + ChipLogProgress(chipTool, " SecurityPolicyPresent: %d", entry.securityPolicyPresent); + ChipLogProgress(chipTool, " ChannelMaskPresent: %d", entry.channelMaskPresent); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -1074,11 +1205,11 @@ static void OnThreadNetworkDiagnosticsActiveNetworkFaultsListListAttributeRespon uint16_t i = 0; while (iter.Next()) { + ++i; #if CHIP_PROGRESS_LOGGING auto & entry = iter.GetValue(); -#endif // CHIP_PROGRESS_LOGGING - ++i; ChipLogProgress(chipTool, "NetworkFault[%" PRIu16 "]: %" PRIu8 "", i, entry); +#endif // CHIP_PROGRESS_LOGGING } command->SetCommandExitStatus(iter.GetStatus()); } @@ -19334,6 +19465,7 @@ class ReadTemperatureMeasurementClusterRevision : public ModelCommand | * EpochUs | 0x0020 | | * EpochS | 0x0021 | | * VendorId | 0x0022 | +| * ListNullablesAndOptionalsStruct | 0x0023 | | * Unsupported | 0x00FF | | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ @@ -21177,6 +21309,41 @@ class WriteTestClusterVendorId : public ModelCommand chip::VendorId mValue; }; +/* + * Attribute ListNullablesAndOptionalsStruct + */ +class ReadTestClusterListNullablesAndOptionalsStruct : public ModelCommand +{ +public: + ReadTestClusterListNullablesAndOptionalsStruct() : ModelCommand("read") + { + AddArgument("attr-name", "list-nullables-and-optionals-struct"); + ModelCommand::AddArguments(); + } + + ~ReadTestClusterListNullablesAndOptionalsStruct() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x050F) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::TestClusterCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeListNullablesAndOptionalsStruct(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback( + OnTestClusterListNullablesAndOptionalsStructListAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + /* * Attribute Unsupported */ @@ -27791,67 +27958,68 @@ void registerClusterTestCluster(Commands & commands) const char * clusterName = "TestCluster"; commands_list clusterCommands = { - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // }; commands.Register(clusterName, clusterCommands); diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp index b6b2f791011367..6f755ce1e239f9 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp @@ -719,6 +719,31 @@ void TestClusterClusterListStructOctetStringListAttributeFilter(TLV::TLVReader * #pragma GCC diagnostic pop #endif // __clang__ +void TestClusterClusterListNullablesAndOptionalsStructListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::DataModel::DecodableList list; + CHIP_ERROR err = Decode(*tlvData, list); + if (err != CHIP_NO_ERROR) + { + if (onFailureCallback != nullptr) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } + return; + } + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, list); +} +#if !defined(__clang__) +#pragma GCC diagnostic pop +#endif // __clang__ + void ThreadNetworkDiagnosticsClusterNeighborTableListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h index 90a15f2c138e19..c37790556a4f3f 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h @@ -282,6 +282,13 @@ typedef void (*TestClusterListStructOctetStringListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); +void TestClusterClusterListNullablesAndOptionalsStructListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); +typedef void (*TestClusterListNullablesAndOptionalsStructListAttributeCallback)( + void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::TestCluster::Structs::NullablesAndOptionalsStruct::DecodableType> & data); void ThreadNetworkDiagnosticsClusterNeighborTableListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, chip::Callback::Cancelable * onFailureCallback); diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp index 8391e0b35cf27c..df45a62177973c 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp @@ -12130,6 +12130,18 @@ CHIP_ERROR TestClusterCluster::WriteAttributeVendorId(Callback::Cancelable * onS return mDevice->SendWriteAttributeRequest(std::move(handle), onSuccessCallback, onFailureCallback); } +CHIP_ERROR TestClusterCluster::ReadAttributeListNullablesAndOptionalsStruct(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x00000023; + attributePath.mFlags.Set(app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + TestClusterClusterListNullablesAndOptionalsStructListAttributeFilter); +} + CHIP_ERROR TestClusterCluster::ReadAttributeUnsupported(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h index 4127b939d4988f..de96421e1ed90a 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h @@ -1384,6 +1384,8 @@ class DLL_EXPORT TestClusterCluster : public ClusterBase CHIP_ERROR ReadAttributeEpochUs(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeEpochS(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeVendorId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeListNullablesAndOptionalsStruct(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeUnsupported(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR WriteAttributeBoolean(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,