From 42df33166eed7dd96626df9aae7dad2db6659a6e Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Tue, 27 Jun 2023 13:10:35 -0400 Subject: [PATCH 1/2] Removed the optionnal quality from the AttributeId in scene xml and refactored tests and clusters to work with the changes --- .../all-clusters-app.matter | 2 +- .../all-clusters-minimal-app.matter | 2 +- .../light-switch-app.matter | 2 +- .../lighting-common/lighting-app.matter | 2 +- .../data_model/lighting-thread-app.matter | 2 +- .../data_model/lighting-wifi-app.matter | 2 +- .../placeholder/linux/apps/app1/config.matter | 2 +- .../placeholder/linux/apps/app2/config.matter | 2 +- .../thermostat-common/thermostat.matter | 2 +- examples/window-app/common/window-app.matter | 2 +- .../clusters/on-off-server/on-off-server.cpp | 10 +- src/app/tests/TestSceneTable.cpp | 26 ++--- .../zcl/data-model/chip/scene.xml | 2 +- .../data_model/controller-clusters.matter | 2 +- .../zap-generated/CHIPInvokeCallbacks.cpp | 46 +++------ .../chip/devicecontroller/ChipStructs.java | 4 +- .../python/chip/clusters/Objects.py | 4 +- .../CHIP/zap-generated/MTRBaseClusters.mm | 10 +- .../CHIP/zap-generated/MTRClusters.mm | 10 +- .../zap-generated/MTRCommandPayloadsObjc.mm | 12 +-- .../CHIP/zap-generated/MTRStructsObjc.h | 4 +- .../CHIP/zap-generated/MTRStructsObjc.mm | 6 +- .../zap-generated/cluster-objects.h | 4 +- .../cluster/ComplexArgumentParser.cpp | 9 +- .../chip-tool/zap-generated/test/Commands.h | 99 +++++++------------ .../zap-generated/cluster/Commands.h | 12 +-- 26 files changed, 99 insertions(+), 181 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 1501b06a842527..270a46241873ea 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -159,7 +159,7 @@ server cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 38e86b0cb5f2cc..8e5945a4770b58 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -153,7 +153,7 @@ server cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index 394f1f21915591..0ac49caffa6548 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -207,7 +207,7 @@ client cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index 533dba220fb674..febaa910b704eb 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -159,7 +159,7 @@ server cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter index c872fe09b891f8..c26354fbbe12f9 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter @@ -159,7 +159,7 @@ server cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter b/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter index 0855b1e51f8bc2..59752a7ff81c70 100644 --- a/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-wifi-app.matter @@ -159,7 +159,7 @@ server cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 914da728d08372..44beb2431e4c24 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -207,7 +207,7 @@ server cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index 628f03280ad070..2ec302c964e7e4 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -207,7 +207,7 @@ server cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index 11cd0f27954c68..4a98c601fb8abe 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -207,7 +207,7 @@ server cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index 1b555884166d66..cf591462e82826 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -159,7 +159,7 @@ server cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/src/app/clusters/on-off-server/on-off-server.cpp b/src/app/clusters/on-off-server/on-off-server.cpp index bfda035f23bde1..8bfbbed18d02a2 100644 --- a/src/app/clusters/on-off-server/on-off-server.cpp +++ b/src/app/clusters/on-off-server/on-off-server.cpp @@ -199,7 +199,7 @@ class DefaultOnOffSceneHandler : public scenes::DefaultSceneHandlerImpl AttributeValuePair pairs[scenableAttributeCount]; - pairs[0].attributeID.SetValue(Attributes::OnOff::Id); + pairs[0].attributeID = Attributes::OnOff::Id; pairs[0].attributeValue = currentValue; app::DataModel::List attributeValueList(pairs); @@ -230,11 +230,7 @@ class DefaultOnOffSceneHandler : public scenes::DefaultSceneHandlerImpl while (pair_iterator.Next()) { auto & decodePair = pair_iterator.GetValue(); - if (decodePair.attributeID.HasValue()) - { - // If attribute ID was encoded, verify it is the proper ID for the OnOff attribute - VerifyOrReturnError(decodePair.attributeID.Value() == Attributes::OnOff::Id, CHIP_ERROR_INVALID_ARGUMENT); - } + VerifyOrReturnError(decodePair.attributeID == Attributes::OnOff::Id, CHIP_ERROR_INVALID_ARGUMENT); ReturnErrorOnFailure( mSceneEndpointStatePairs.InsertPair(EndpointStatePair(endpoint, static_cast(decodePair.attributeValue)))); } @@ -545,7 +541,7 @@ void OnOffServer::initOnOffServer(chip::EndpointId endpoint) #ifdef EMBER_AF_PLUGIN_SCENES // Registers Scene handlers for the On/Off cluster on the server - // app::Clusters::Scenes::ScenesServer::Instance().RegisterSceneHandler(OnOffServer::Instance().GetSceneHandler()); + app::Clusters::Scenes::ScenesServer::Instance().RegisterSceneHandler(OnOffServer::Instance().GetSceneHandler()); #endif #ifdef EMBER_AF_PLUGIN_MODE_SELECT diff --git a/src/app/tests/TestSceneTable.cpp b/src/app/tests/TestSceneTable.cpp index f9c65adf57f284..9817228cad289e 100644 --- a/src/app/tests/TestSceneTable.cpp +++ b/src/app/tests/TestSceneTable.cpp @@ -494,29 +494,29 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext) static const uint16_t LC_av_payload[2] = { 0x64, 0x01F0 }; static const uint16_t CC_av_payload[8] = { 0 }; - OOPairs[0].attributeID.SetValue(kOnOffAttId); + OOPairs[0].attributeID = kOnOffAttId; OOPairs[0].attributeValue = OO_av_payload; - LCPairs[0].attributeID.SetValue(kCurrentLevelId); + LCPairs[0].attributeID = kCurrentLevelId; LCPairs[0].attributeValue = LC_av_payload[0]; - LCPairs[1].attributeID.SetValue(kCurrentFrequencyId); + LCPairs[1].attributeID = kCurrentFrequencyId; LCPairs[1].attributeValue = LC_av_payload[1]; - CCPairs[0].attributeID.SetValue(kCurrentSaturationId); + CCPairs[0].attributeID = kCurrentSaturationId; CCPairs[0].attributeValue = CC_av_payload[0]; - CCPairs[1].attributeID.SetValue(kCurrentXId); + CCPairs[1].attributeID = kCurrentXId; CCPairs[1].attributeValue = CC_av_payload[1]; - CCPairs[2].attributeID.SetValue(kCurrentYId); + CCPairs[2].attributeID = kCurrentYId; CCPairs[2].attributeValue = CC_av_payload[2]; - CCPairs[3].attributeID.SetValue(kColorTemperatureMiredsId); + CCPairs[3].attributeID = kColorTemperatureMiredsId; CCPairs[3].attributeValue = CC_av_payload[3]; - CCPairs[4].attributeID.SetValue(kEnhancedCurrentHueId); + CCPairs[4].attributeID = kEnhancedCurrentHueId; CCPairs[4].attributeValue = CC_av_payload[4]; - CCPairs[5].attributeID.SetValue(kColorLoopActiveId); + CCPairs[5].attributeID = kColorLoopActiveId; CCPairs[5].attributeValue = CC_av_payload[5]; - CCPairs[6].attributeID.SetValue(kColorLoopDirectionId); + CCPairs[6].attributeID = kColorLoopDirectionId; CCPairs[6].attributeValue = CC_av_payload[6]; - CCPairs[7].attributeID.SetValue(kColorLoopTimeId); + CCPairs[7].attributeID = kColorLoopTimeId; CCPairs[7].attributeValue = CC_av_payload[7]; // Initialize Extension Field sets as if they were received by add commands @@ -637,7 +637,6 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext) app::Clusters::Scenes::Structs::AttributeValuePair::Type TooManyPairs[16]; uint8_t payloadOk = 0; - for (uint8_t i = 0; i < 16; i++) { TooManyPairs[i].attributeValue = payloadOk; @@ -646,7 +645,8 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext) extensionFieldFailTestOut.clusterID = kColorControlClusterId; extensionFieldFailTestOut.attributeValueList = TooManyPairs; - uint8_t failBuffer[scenes::kMaxFieldBytesPerCluster] = { 0 }; + // Give a bigger buffer given we are using to many pairs on purpose + uint8_t failBuffer[2 * scenes::kMaxFieldBytesPerCluster] = { 0 }; ByteSpan fail_list(failBuffer); // Serialize Extension Field sets as if they were recovered from memory diff --git a/src/app/zap-templates/zcl/data-model/chip/scene.xml b/src/app/zap-templates/zcl/data-model/chip/scene.xml index 02a9c65d68ec0f..313d921a93e41b 100644 --- a/src/app/zap-templates/zcl/data-model/chip/scene.xml +++ b/src/app/zap-templates/zcl/data-model/chip/scene.xml @@ -22,7 +22,7 @@ limitations under the License. - + diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 6e95ea7a83dcfc..5ba44004542ad3 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -167,7 +167,7 @@ client cluster Scenes = 5 { } struct AttributeValuePair { - optional attrib_id attributeID = 0; + attrib_id attributeID = 0; int32u attributeValue = 1; } diff --git a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp index 0abae72ad343c9..0a3e7d467a7c3c 100644 --- a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp @@ -504,22 +504,11 @@ void CHIPScenesClusterViewSceneResponseCallback::CallbackFn( auto & entry_3 = iter_newElement_1_attributeValueList_3.GetValue(); jobject newElement_3; jobject newElement_3_attributeID; - if (!entry_3.attributeID.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_3_attributeID); - } - else - { - jobject newElement_3_attributeIDInsideOptional; - std::string newElement_3_attributeIDInsideOptionalClassName = "java/lang/Long"; - std::string newElement_3_attributeIDInsideOptionalCtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_3_attributeIDInsideOptionalClassName.c_str(), - newElement_3_attributeIDInsideOptionalCtorSignature.c_str(), entry_3.attributeID.Value(), - newElement_3_attributeIDInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_3_attributeIDInsideOptional, - newElement_3_attributeID); - } + std::string newElement_3_attributeIDClassName = "java/lang/Long"; + std::string newElement_3_attributeIDCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_3_attributeIDClassName.c_str(), + newElement_3_attributeIDCtorSignature.c_str(), + entry_3.attributeID, newElement_3_attributeID); jobject newElement_3_attributeValue; std::string newElement_3_attributeValueClassName = "java/lang/Long"; std::string newElement_3_attributeValueCtorSignature = "(J)V"; @@ -536,7 +525,7 @@ void CHIPScenesClusterViewSceneResponseCallback::CallbackFn( return; } jmethodID attributeValuePairStructCtor_4 = - env->GetMethodID(attributeValuePairStructClass_4, "", "(Ljava/util/Optional;Ljava/lang/Long;)V"); + env->GetMethodID(attributeValuePairStructClass_4, "", "(Ljava/lang/Long;Ljava/lang/Long;)V"); if (attributeValuePairStructCtor_4 == nullptr) { ChipLogError(Zcl, "Could not find ChipStructs$ScenesClusterAttributeValuePair constructor"); @@ -1078,22 +1067,11 @@ void CHIPScenesClusterEnhancedViewSceneResponseCallback::CallbackFn( auto & entry_3 = iter_newElement_1_attributeValueList_3.GetValue(); jobject newElement_3; jobject newElement_3_attributeID; - if (!entry_3.attributeID.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_3_attributeID); - } - else - { - jobject newElement_3_attributeIDInsideOptional; - std::string newElement_3_attributeIDInsideOptionalClassName = "java/lang/Long"; - std::string newElement_3_attributeIDInsideOptionalCtorSignature = "(J)V"; - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_3_attributeIDInsideOptionalClassName.c_str(), - newElement_3_attributeIDInsideOptionalCtorSignature.c_str(), entry_3.attributeID.Value(), - newElement_3_attributeIDInsideOptional); - chip::JniReferences::GetInstance().CreateOptional(newElement_3_attributeIDInsideOptional, - newElement_3_attributeID); - } + std::string newElement_3_attributeIDClassName = "java/lang/Long"; + std::string newElement_3_attributeIDCtorSignature = "(J)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(newElement_3_attributeIDClassName.c_str(), + newElement_3_attributeIDCtorSignature.c_str(), + entry_3.attributeID, newElement_3_attributeID); jobject newElement_3_attributeValue; std::string newElement_3_attributeValueClassName = "java/lang/Long"; std::string newElement_3_attributeValueCtorSignature = "(J)V"; @@ -1110,7 +1088,7 @@ void CHIPScenesClusterEnhancedViewSceneResponseCallback::CallbackFn( return; } jmethodID attributeValuePairStructCtor_4 = - env->GetMethodID(attributeValuePairStructClass_4, "", "(Ljava/util/Optional;Ljava/lang/Long;)V"); + env->GetMethodID(attributeValuePairStructClass_4, "", "(Ljava/lang/Long;Ljava/lang/Long;)V"); if (attributeValuePairStructCtor_4 == nullptr) { ChipLogError(Zcl, "Could not find ChipStructs$ScenesClusterAttributeValuePair constructor"); diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java index b024e13325d2b8..e8d9aab805a04f 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java @@ -25,11 +25,11 @@ public class ChipStructs { public static class ScenesClusterAttributeValuePair { -public Optional attributeID; +public Long attributeID; public Long attributeValue; public ScenesClusterAttributeValuePair( - Optional attributeID + Long attributeID , Long attributeValue ) { this.attributeID = attributeID; diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index e9ee0c02b107a2..361c55ce428e38 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -635,11 +635,11 @@ class AttributeValuePair(ClusterObject): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="attributeID", Tag=0, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="attributeID", Tag=0, Type=uint), ClusterObjectFieldDescriptor(Label="attributeValue", Tag=1, Type=uint), ]) - attributeID: 'typing.Optional[uint]' = None + attributeID: 'uint' = 0 attributeValue: 'uint' = 0 @dataclass diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index 41d6c11041776d..0588c01dd4cdbd 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -1817,10 +1817,7 @@ - (void)addSceneWithParams:(MTRScenesClusterAddSceneParams *)params return CHIP_ERROR_INVALID_ARGUMENT; } auto element_2 = (MTRScenesClusterAttributeValuePair *) element_0.attributeValueList[i_2]; - if (element_2.attributeID != nil) { - auto & definedValue_4 = listHolder_2->mList[i_2].attributeID.Emplace(); - definedValue_4 = element_2.attributeID.unsignedIntValue; - } + listHolder_2->mList[i_2].attributeID = element_2.attributeID.unsignedIntValue; listHolder_2->mList[i_2].attributeValue = element_2.attributeValue.unsignedIntValue; } listHolder_0->mList[i_0].attributeValueList @@ -2126,10 +2123,7 @@ - (void)enhancedAddSceneWithParams:(MTRScenesClusterEnhancedAddSceneParams *)par return CHIP_ERROR_INVALID_ARGUMENT; } auto element_2 = (MTRScenesClusterAttributeValuePair *) element_0.attributeValueList[i_2]; - if (element_2.attributeID != nil) { - auto & definedValue_4 = listHolder_2->mList[i_2].attributeID.Emplace(); - definedValue_4 = element_2.attributeID.unsignedIntValue; - } + listHolder_2->mList[i_2].attributeID = element_2.attributeID.unsignedIntValue; listHolder_2->mList[i_2].attributeValue = element_2.attributeValue.unsignedIntValue; } listHolder_0->mList[i_0].attributeValueList diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index 3b7d52bd39b26f..f6518c22ad5844 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -1039,10 +1039,7 @@ - (void)addSceneWithParams:(MTRScenesClusterAddSceneParams *)params return CHIP_ERROR_INVALID_ARGUMENT; } auto element_2 = (MTRScenesClusterAttributeValuePair *) element_0.attributeValueList[i_2]; - if (element_2.attributeID != nil) { - auto & definedValue_4 = listHolder_2->mList[i_2].attributeID.Emplace(); - definedValue_4 = element_2.attributeID.unsignedIntValue; - } + listHolder_2->mList[i_2].attributeID = element_2.attributeID.unsignedIntValue; listHolder_2->mList[i_2].attributeValue = element_2.attributeValue.unsignedIntValue; } listHolder_0->mList[i_0].attributeValueList @@ -1591,10 +1588,7 @@ - (void)enhancedAddSceneWithParams:(MTRScenesClusterEnhancedAddSceneParams *)par return CHIP_ERROR_INVALID_ARGUMENT; } auto element_2 = (MTRScenesClusterAttributeValuePair *) element_0.attributeValueList[i_2]; - if (element_2.attributeID != nil) { - auto & definedValue_4 = listHolder_2->mList[i_2].attributeID.Emplace(); - definedValue_4 = element_2.attributeID.unsignedIntValue; - } + listHolder_2->mList[i_2].attributeID = element_2.attributeID.unsignedIntValue; listHolder_2->mList[i_2].attributeValue = element_2.attributeValue.unsignedIntValue; } listHolder_0->mList[i_0].attributeValueList diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index a99ccebd27db17..20d5e7fc2142a1 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -1121,11 +1121,7 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct: auto & entry_3 = iter_3.GetValue(); MTRScenesClusterAttributeValuePair * newElement_3; newElement_3 = [MTRScenesClusterAttributeValuePair new]; - if (entry_3.attributeID.HasValue()) { - newElement_3.attributeID = [NSNumber numberWithUnsignedInt:entry_3.attributeID.Value()]; - } else { - newElement_3.attributeID = nil; - } + newElement_3.attributeID = [NSNumber numberWithUnsignedInt:entry_3.attributeID]; newElement_3.attributeValue = [NSNumber numberWithUnsignedInt:entry_3.attributeValue]; [array_3 addObject:newElement_3]; } @@ -2274,11 +2270,7 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct: auto & entry_3 = iter_3.GetValue(); MTRScenesClusterAttributeValuePair * newElement_3; newElement_3 = [MTRScenesClusterAttributeValuePair new]; - if (entry_3.attributeID.HasValue()) { - newElement_3.attributeID = [NSNumber numberWithUnsignedInt:entry_3.attributeID.Value()]; - } else { - newElement_3.attributeID = nil; - } + newElement_3.attributeID = [NSNumber numberWithUnsignedInt:entry_3.attributeID]; newElement_3.attributeValue = [NSNumber numberWithUnsignedInt:entry_3.attributeValue]; [array_3 addObject:newElement_3]; } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index 076ed268a092cb..c169c3c37aba91 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -21,8 +21,8 @@ NS_ASSUME_NONNULL_BEGIN API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @interface MTRScenesClusterAttributeValuePair : NSObject -@property (nonatomic, copy) NSNumber * _Nullable attributeID API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); -@property (nonatomic, copy) NSNumber * _Nullable attributeId MTR_DEPRECATED( +@property (nonatomic, copy) NSNumber * _Nonnull attributeID API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +@property (nonatomic, copy) NSNumber * _Nonnull attributeId MTR_DEPRECATED( "Please use attributeID", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); @property (nonatomic, copy) NSNumber * _Nonnull attributeValue API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); @end diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index f81221f07a8bed..9aed49bb01c3e6 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -24,7 +24,7 @@ - (instancetype)init { if (self = [super init]) { - _attributeID = nil; + _attributeID = @(0); _attributeValue = @(0); } @@ -48,12 +48,12 @@ - (NSString *)description return descriptionString; } -- (void)setAttributeId:(NSNumber * _Nullable)attributeId +- (void)setAttributeId:(NSNumber * _Nonnull)attributeId { self.attributeID = attributeId; } -- (NSNumber * _Nullable)attributeId +- (NSNumber * _Nonnull)attributeId { return self.attributeID; } 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 3b906f74c4e5ca..6555c0e7abfb48 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 @@ -924,8 +924,8 @@ enum class Fields : uint8_t struct Type { public: - Optional attributeID; - uint32_t attributeValue = static_cast(0); + chip::AttributeId attributeID = static_cast(0); + uint32_t attributeValue = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index b7ba3d66776751..f55c84a4580483 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -229,15 +229,14 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("AttributeValuePair.attributeID", "attributeID", value.isMember("attributeID"))); ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AttributeValuePair.attributeValue", "attributeValue", value.isMember("attributeValue"))); char labelWithMember[kMaxLabelLength]; - if (value.isMember("attributeID")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeID, value["attributeID"])); - } + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeID, value["attributeID"])); valueCopy.removeMember("attributeID"); snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeValue"); diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 2d73030806360f..8d1e0247edc576 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -132014,10 +132014,8 @@ class Test_TC_S_2_2Suite : public TestCommand auto iter_3 = iter_1.GetValue().attributeValueList.begin(); VerifyOrReturn(CheckNextListItemDecodes( "extensionFieldSets.Value()[0].attributeValueList", iter_3, 0)); - VerifyOrReturn(CheckValuePresent("extensionFieldSets.Value()[0].attributeValueList[0].attributeID", - iter_3.GetValue().attributeID)); - VerifyOrReturn(CheckValue("extensionFieldSets.Value()[0].attributeValueList[0].attributeID.Value()", - iter_3.GetValue().attributeID.Value(), 0UL)); + VerifyOrReturn(CheckValue("extensionFieldSets.Value()[0].attributeValueList[0].attributeID", + iter_3.GetValue().attributeID, 0UL)); VerifyOrReturn(CheckValue("extensionFieldSets.Value()[0].attributeValueList[0].attributeValue", iter_3.GetValue().attributeValue, 1UL)); VerifyOrReturn(CheckNoMoreListItems( @@ -132030,18 +132028,14 @@ class Test_TC_S_2_2Suite : public TestCommand auto iter_3 = iter_1.GetValue().attributeValueList.begin(); VerifyOrReturn(CheckNextListItemDecodes( "extensionFieldSets.Value()[1].attributeValueList", iter_3, 0)); - VerifyOrReturn(CheckValuePresent("extensionFieldSets.Value()[1].attributeValueList[0].attributeID", - iter_3.GetValue().attributeID)); - VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[0].attributeID.Value()", - iter_3.GetValue().attributeID.Value(), 0UL)); + VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[0].attributeID", + iter_3.GetValue().attributeID, 0UL)); VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[0].attributeValue", iter_3.GetValue().attributeValue, 100UL)); VerifyOrReturn(CheckNextListItemDecodes( "extensionFieldSets.Value()[1].attributeValueList", iter_3, 1)); - VerifyOrReturn(CheckValuePresent("extensionFieldSets.Value()[1].attributeValueList[1].attributeID", - iter_3.GetValue().attributeID)); - VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[1].attributeID.Value()", - iter_3.GetValue().attributeID.Value(), 1UL)); + VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[1].attributeID", + iter_3.GetValue().attributeID, 1UL)); VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[1].attributeValue", iter_3.GetValue().attributeValue, 0UL)); VerifyOrReturn(CheckNoMoreListItems( @@ -132661,9 +132655,8 @@ class Test_TC_S_2_2Suite : public TestCommand auto * listHolder_2 = new ListHolder(1); listFreer.add(listHolder_2); - listHolder_2->mList[0].attributeID.Emplace(); - listHolder_2->mList[0].attributeID.Value() = 0UL; - listHolder_2->mList[0].attributeValue = 1UL; + listHolder_2->mList[0].attributeID = 0UL; + listHolder_2->mList[0].attributeValue = 1UL; listHolder_0->mList[0].attributeValueList = chip::app::DataModel::List( @@ -132676,13 +132669,11 @@ class Test_TC_S_2_2Suite : public TestCommand auto * listHolder_2 = new ListHolder(2); listFreer.add(listHolder_2); - listHolder_2->mList[0].attributeID.Emplace(); - listHolder_2->mList[0].attributeID.Value() = 0UL; - listHolder_2->mList[0].attributeValue = 100UL; + listHolder_2->mList[0].attributeID = 0UL; + listHolder_2->mList[0].attributeValue = 100UL; - listHolder_2->mList[1].attributeID.Emplace(); - listHolder_2->mList[1].attributeID.Value() = 1UL; - listHolder_2->mList[1].attributeValue = 0UL; + listHolder_2->mList[1].attributeID = 1UL; + listHolder_2->mList[1].attributeValue = 0UL; listHolder_0->mList[1].attributeValueList = chip::app::DataModel::List( @@ -133109,10 +133100,8 @@ class Test_TC_S_2_3Suite : public TestCommand auto iter_3 = iter_1.GetValue().attributeValueList.begin(); VerifyOrReturn(CheckNextListItemDecodes( "extensionFieldSets.Value()[0].attributeValueList", iter_3, 0)); - VerifyOrReturn(CheckValuePresent("extensionFieldSets.Value()[0].attributeValueList[0].attributeID", - iter_3.GetValue().attributeID)); - VerifyOrReturn(CheckValue("extensionFieldSets.Value()[0].attributeValueList[0].attributeID.Value()", - iter_3.GetValue().attributeID.Value(), 0UL)); + VerifyOrReturn(CheckValue("extensionFieldSets.Value()[0].attributeValueList[0].attributeID", + iter_3.GetValue().attributeID, 0UL)); VerifyOrReturn(CheckValue("extensionFieldSets.Value()[0].attributeValueList[0].attributeValue", iter_3.GetValue().attributeValue, 1UL)); VerifyOrReturn(CheckNoMoreListItems( @@ -133125,18 +133114,14 @@ class Test_TC_S_2_3Suite : public TestCommand auto iter_3 = iter_1.GetValue().attributeValueList.begin(); VerifyOrReturn(CheckNextListItemDecodes( "extensionFieldSets.Value()[1].attributeValueList", iter_3, 0)); - VerifyOrReturn(CheckValuePresent("extensionFieldSets.Value()[1].attributeValueList[0].attributeID", - iter_3.GetValue().attributeID)); - VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[0].attributeID.Value()", - iter_3.GetValue().attributeID.Value(), 0UL)); + VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[0].attributeID", + iter_3.GetValue().attributeID, 0UL)); VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[0].attributeValue", iter_3.GetValue().attributeValue, 100UL)); VerifyOrReturn(CheckNextListItemDecodes( "extensionFieldSets.Value()[1].attributeValueList", iter_3, 1)); - VerifyOrReturn(CheckValuePresent("extensionFieldSets.Value()[1].attributeValueList[1].attributeID", - iter_3.GetValue().attributeID)); - VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[1].attributeID.Value()", - iter_3.GetValue().attributeID.Value(), 1UL)); + VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[1].attributeID", + iter_3.GetValue().attributeID, 1UL)); VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[1].attributeValue", iter_3.GetValue().attributeValue, 0UL)); VerifyOrReturn(CheckNoMoreListItems( @@ -133167,10 +133152,8 @@ class Test_TC_S_2_3Suite : public TestCommand auto iter_3 = iter_1.GetValue().attributeValueList.begin(); VerifyOrReturn(CheckNextListItemDecodes( "extensionFieldSets.Value()[0].attributeValueList", iter_3, 0)); - VerifyOrReturn(CheckValuePresent("extensionFieldSets.Value()[0].attributeValueList[0].attributeID", - iter_3.GetValue().attributeID)); - VerifyOrReturn(CheckValue("extensionFieldSets.Value()[0].attributeValueList[0].attributeID.Value()", - iter_3.GetValue().attributeID.Value(), 0UL)); + VerifyOrReturn(CheckValue("extensionFieldSets.Value()[0].attributeValueList[0].attributeID", + iter_3.GetValue().attributeID, 0UL)); VerifyOrReturn(CheckValue("extensionFieldSets.Value()[0].attributeValueList[0].attributeValue", iter_3.GetValue().attributeValue, 1UL)); VerifyOrReturn(CheckNoMoreListItems( @@ -133183,18 +133166,14 @@ class Test_TC_S_2_3Suite : public TestCommand auto iter_3 = iter_1.GetValue().attributeValueList.begin(); VerifyOrReturn(CheckNextListItemDecodes( "extensionFieldSets.Value()[1].attributeValueList", iter_3, 0)); - VerifyOrReturn(CheckValuePresent("extensionFieldSets.Value()[1].attributeValueList[0].attributeID", - iter_3.GetValue().attributeID)); - VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[0].attributeID.Value()", - iter_3.GetValue().attributeID.Value(), 0UL)); + VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[0].attributeID", + iter_3.GetValue().attributeID, 0UL)); VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[0].attributeValue", iter_3.GetValue().attributeValue, 100UL)); VerifyOrReturn(CheckNextListItemDecodes( "extensionFieldSets.Value()[1].attributeValueList", iter_3, 1)); - VerifyOrReturn(CheckValuePresent("extensionFieldSets.Value()[1].attributeValueList[1].attributeID", - iter_3.GetValue().attributeID)); - VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[1].attributeID.Value()", - iter_3.GetValue().attributeID.Value(), 1UL)); + VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[1].attributeID", + iter_3.GetValue().attributeID, 1UL)); VerifyOrReturn(CheckValue("extensionFieldSets.Value()[1].attributeValueList[1].attributeValue", iter_3.GetValue().attributeValue, 0UL)); VerifyOrReturn(CheckNoMoreListItems( @@ -133425,9 +133404,8 @@ class Test_TC_S_2_3Suite : public TestCommand auto * listHolder_2 = new ListHolder(1); listFreer.add(listHolder_2); - listHolder_2->mList[0].attributeID.Emplace(); - listHolder_2->mList[0].attributeID.Value() = 0UL; - listHolder_2->mList[0].attributeValue = 1UL; + listHolder_2->mList[0].attributeID = 0UL; + listHolder_2->mList[0].attributeValue = 1UL; listHolder_0->mList[0].attributeValueList = chip::app::DataModel::List( @@ -133440,13 +133418,11 @@ class Test_TC_S_2_3Suite : public TestCommand auto * listHolder_2 = new ListHolder(2); listFreer.add(listHolder_2); - listHolder_2->mList[0].attributeID.Emplace(); - listHolder_2->mList[0].attributeID.Value() = 0UL; - listHolder_2->mList[0].attributeValue = 100UL; + listHolder_2->mList[0].attributeID = 0UL; + listHolder_2->mList[0].attributeValue = 100UL; - listHolder_2->mList[1].attributeID.Emplace(); - listHolder_2->mList[1].attributeID.Value() = 1UL; - listHolder_2->mList[1].attributeValue = 0UL; + listHolder_2->mList[1].attributeID = 1UL; + listHolder_2->mList[1].attributeValue = 0UL; listHolder_0->mList[1].attributeValueList = chip::app::DataModel::List( @@ -133484,9 +133460,8 @@ class Test_TC_S_2_3Suite : public TestCommand auto * listHolder_2 = new ListHolder(1); listFreer.add(listHolder_2); - listHolder_2->mList[0].attributeID.Emplace(); - listHolder_2->mList[0].attributeID.Value() = 0UL; - listHolder_2->mList[0].attributeValue = 1UL; + listHolder_2->mList[0].attributeID = 0UL; + listHolder_2->mList[0].attributeValue = 1UL; listHolder_0->mList[0].attributeValueList = chip::app::DataModel::List( @@ -133499,13 +133474,11 @@ class Test_TC_S_2_3Suite : public TestCommand auto * listHolder_2 = new ListHolder(2); listFreer.add(listHolder_2); - listHolder_2->mList[0].attributeID.Emplace(); - listHolder_2->mList[0].attributeID.Value() = 0UL; - listHolder_2->mList[0].attributeValue = 100UL; + listHolder_2->mList[0].attributeID = 0UL; + listHolder_2->mList[0].attributeValue = 100UL; - listHolder_2->mList[1].attributeID.Emplace(); - listHolder_2->mList[1].attributeID.Value() = 1UL; - listHolder_2->mList[1].attributeValue = 0UL; + listHolder_2->mList[1].attributeID = 1UL; + listHolder_2->mList[1].attributeValue = 0UL; listHolder_0->mList[1].attributeValueList = chip::app::DataModel::List( diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 61f12b52a9de60..b2b58d04258c89 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -1693,11 +1693,7 @@ class ScenesAddScene : public ClusterCommand { for (auto & entry_2 : entry_0.attributeValueList) { MTRScenesClusterAttributeValuePair * newElement_2; newElement_2 = [MTRScenesClusterAttributeValuePair new]; - if (entry_2.attributeID.HasValue()) { - newElement_2.attributeID = [NSNumber numberWithUnsignedInt:entry_2.attributeID.Value()]; - } else { - newElement_2.attributeID = nil; - } + newElement_2.attributeID = [NSNumber numberWithUnsignedInt:entry_2.attributeID]; newElement_2.attributeValue = [NSNumber numberWithUnsignedInt:entry_2.attributeValue]; [array_2 addObject:newElement_2]; } @@ -2066,11 +2062,7 @@ class ScenesEnhancedAddScene : public ClusterCommand { for (auto & entry_2 : entry_0.attributeValueList) { MTRScenesClusterAttributeValuePair * newElement_2; newElement_2 = [MTRScenesClusterAttributeValuePair new]; - if (entry_2.attributeID.HasValue()) { - newElement_2.attributeID = [NSNumber numberWithUnsignedInt:entry_2.attributeID.Value()]; - } else { - newElement_2.attributeID = nil; - } + newElement_2.attributeID = [NSNumber numberWithUnsignedInt:entry_2.attributeID]; newElement_2.attributeValue = [NSNumber numberWithUnsignedInt:entry_2.attributeValue]; [array_2 addObject:newElement_2]; } From d8ef748ecaa1da56b9028a9cb53228504eb9ffb2 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 28 Jun 2023 09:19:12 -0400 Subject: [PATCH 2/2] Update src/app/tests/TestSceneTable.cpp Co-authored-by: Boris Zbarsky --- src/app/tests/TestSceneTable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tests/TestSceneTable.cpp b/src/app/tests/TestSceneTable.cpp index 9817228cad289e..cba0ebe4e8d5f5 100644 --- a/src/app/tests/TestSceneTable.cpp +++ b/src/app/tests/TestSceneTable.cpp @@ -645,7 +645,7 @@ void TestHandlerFunctions(nlTestSuite * aSuite, void * aContext) extensionFieldFailTestOut.clusterID = kColorControlClusterId; extensionFieldFailTestOut.attributeValueList = TooManyPairs; - // Give a bigger buffer given we are using to many pairs on purpose + // Give a bigger buffer given we are using too many pairs on purpose uint8_t failBuffer[2 * scenes::kMaxFieldBytesPerCluster] = { 0 }; ByteSpan fail_list(failBuffer);