From bbd8f11beeb1ff1635ea7f2a4584b79ba5a70fc4 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 10 Nov 2021 09:15:51 -0500 Subject: [PATCH] Remove the CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ define. (#11617) It's always enabled. --- src/app/clusters/descriptor/descriptor.cpp | 2 - .../operational-credentials-server.cpp | 2 - .../test-cluster-server.cpp | 118 ------------------ src/lib/core/CHIPConfig.h | 10 -- 4 files changed, 132 deletions(-) diff --git a/src/app/clusters/descriptor/descriptor.cpp b/src/app/clusters/descriptor/descriptor.cpp index ad0eb53c7e4581..9a24fdf34624b8 100644 --- a/src/app/clusters/descriptor/descriptor.cpp +++ b/src/app/clusters/descriptor/descriptor.cpp @@ -152,7 +152,5 @@ CHIP_ERROR DescriptorAttrAccess::Read(const ConcreteAttributePath & aPath, Attri void MatterDescriptorPluginServerInitCallback(void) { -#if CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ registerAttributeAccessOverride(&gAttrAccess); -#endif } diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp index 5826a0ad877804..3af39b6c45e95d 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -232,9 +232,7 @@ void MatterOperationalCredentialsPluginServerInitCallback(void) { emberAfPrintln(EMBER_AF_PRINT_DEBUG, "OpCreds: Initiating OpCreds cluster by writing fabrics list from fabric table."); -#if CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ registerAttributeAccessOverride(&gAttrAccess); -#endif Server::GetInstance().GetFabricTable().SetFabricDelegate(&gFabricDelegate); } 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 19c60d03ac2e65..b5c1682977711f 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -40,10 +40,6 @@ using namespace chip::app::Clusters::TestCluster; using namespace chip::app::Clusters::TestCluster::Commands; using namespace chip::app::Clusters::TestCluster::Attributes; -#if !CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ -constexpr const char * kErrorStr = "Test Cluster: List Octet cluster (0x%02x) Error setting '%s' attribute: 0x%02x"; -#endif // CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ - namespace { class TestAttrAccess : public AttributeAccessInterface @@ -87,45 +83,6 @@ CHIP_ERROR TestAttrAccess::Read(const ConcreteAttributePath & aPath, AttributeVa return CHIP_NO_ERROR; } -#if !CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ -EmberAfStatus writeAttribute(EndpointId endpoint, AttributeId attributeId, uint8_t * buffer, int32_t index = -1) -{ - EmberAfAttributeSearchRecord record; - record.endpoint = endpoint; - record.clusterId = TestCluster::Id; - record.clusterMask = CLUSTER_MASK_SERVER; - record.manufacturerCode = EMBER_AF_NULL_MANUFACTURER_CODE; - record.attributeId = attributeId; - - // When reading or writing a List attribute the 'index' value could have 3 types of values: - // -1: Read/Write the whole list content, including the number of elements in the list - // 0: Read/Write the number of elements in the list, represented as a uint16_t - // n: Read/Write the nth element of the list - // - // Since the first 2 bytes of the attribute are used to store the number of elements, elements indexing starts - // at 1. In order to hide this to the rest of the code of this file, the element index is incremented by 1 here. - // This also allows calling writeAttribute() with no index arg to mean "write the length". - return emAfReadOrWriteAttribute(&record, NULL, buffer, 0, true, index + 1); -} - -EmberAfStatus writeTestListInt8uAttribute(EndpointId endpoint) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - AttributeId attributeId = ZCL_LIST_ATTRIBUTE_ID; - - uint16_t attributeCount = 4; - for (uint8_t index = 0; index < attributeCount; index++) - { - status = writeAttribute(endpoint, attributeId, (uint8_t *) &index, index); - VerifyOrReturnError(status == EMBER_ZCL_STATUS_SUCCESS, status); - } - - status = writeAttribute(endpoint, attributeId, (uint8_t *) &attributeCount); - VerifyOrReturnError(status == EMBER_ZCL_STATUS_SUCCESS, status); - return status; -} -#endif // !CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ - CHIP_ERROR TestAttrAccess::ReadListInt8uAttribute(AttributeValueEncoder & aEncoder) { return aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR { @@ -138,30 +95,6 @@ CHIP_ERROR TestAttrAccess::ReadListInt8uAttribute(AttributeValueEncoder & aEncod }); } -#if !CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ -EmberAfStatus writeTestListOctetAttribute(EndpointId endpoint) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - AttributeId attributeId = ZCL_LIST_OCTET_STRING_ATTRIBUTE_ID; - - uint16_t attributeCount = 4; - char data[6] = { 'T', 'e', 's', 't', 'N', '\0' }; - ByteSpan span = ByteSpan(Uint8::from_char(data), strlen(data)); - - for (uint8_t index = 0; index < attributeCount; index++) - { - sprintf(data + strlen(data) - 1, "%d", index); - - status = writeAttribute(endpoint, attributeId, (uint8_t *) &span, index); - VerifyOrReturnError(status == EMBER_ZCL_STATUS_SUCCESS, status); - } - - status = writeAttribute(endpoint, attributeId, (uint8_t *) &attributeCount); - VerifyOrReturnError(status == EMBER_ZCL_STATUS_SUCCESS, status); - return status; -} -#endif // !CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ - CHIP_ERROR TestAttrAccess::ReadListOctetStringAttribute(AttributeValueEncoder & aEncoder) { return aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR { @@ -178,34 +111,6 @@ CHIP_ERROR TestAttrAccess::ReadListOctetStringAttribute(AttributeValueEncoder & }); } -#if !CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ -EmberAfStatus writeTestListStructOctetAttribute(EndpointId endpoint) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - AttributeId attributeId = ZCL_LIST_STRUCT_OCTET_STRING_ATTRIBUTE_ID; - - uint16_t attributeCount = 4; - char data[6] = { 'T', 'e', 's', 't', 'N', '\0' }; - ByteSpan span = ByteSpan(Uint8::from_char(data), strlen(data)); - - for (uint8_t index = 0; index < attributeCount; index++) - { - sprintf(data + strlen(data) - 1, "%d", index); - - _TestListStructOctet structOctet; - structOctet.fabricIndex = index; - structOctet.operationalCert = span; - - status = writeAttribute(endpoint, attributeId, (uint8_t *) &structOctet, index); - VerifyOrReturnError(status == EMBER_ZCL_STATUS_SUCCESS, status); - } - - status = writeAttribute(endpoint, attributeId, (uint8_t *) &attributeCount); - VerifyOrReturnError(status == EMBER_ZCL_STATUS_SUCCESS, status); - return status; -} -#endif // !CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ - CHIP_ERROR TestAttrAccess::ReadListStructOctetStringAttribute(AttributeValueEncoder & aEncoder) { return aEncoder.EncodeList([](const TagBoundEncoder & encoder) -> CHIP_ERROR { @@ -487,28 +392,5 @@ bool emberAfTestClusterClusterTestNullableOptionalRequestCallback( void MatterTestClusterPluginServerInitCallback(void) { -#if CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ registerAttributeAccessOverride(&gAttrAccess); -#else // CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - - for (uint8_t index = 0; index < emberAfEndpointCount(); index++) - { - EndpointId endpoint = emberAfEndpointFromIndex(index); - if (!emberAfContainsCluster(endpoint, TestCluster::Id)) - { - continue; - } - - status = writeTestListInt8uAttribute(endpoint); - VerifyOrReturn(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, kErrorStr, endpoint, "test list int8u", status)); - - status = writeTestListOctetAttribute(endpoint); - VerifyOrReturn(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, kErrorStr, endpoint, "test list octet", status)); - - status = writeTestListStructOctetAttribute(endpoint); - VerifyOrReturn(status == EMBER_ZCL_STATUS_SUCCESS, - ChipLogError(Zcl, kErrorStr, endpoint, "test list struct octet", status)); - } -#endif // CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ } diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index d8137496b30e2b..25a8407e6a18eb 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -2583,16 +2583,6 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #define CHIP_CONFIG_MAX_GROUP_CONCURRENT_ITERATORS 2 #endif -/** - * @def CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ - * - * @brief Enable or disable attribute read with complex type. - * - */ -#ifndef CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ -#define CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ 1 -#endif - /** * @} */