Skip to content

Commit

Permalink
Remove the CHIP_CLUSTER_CONFIG_ENABLE_COMPLEX_ATTRIBUTE_READ define. (#…
Browse files Browse the repository at this point in the history
…11617)

It's always enabled.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Aug 21, 2023
1 parent 4dc915b commit 2361248
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 132 deletions.
2 changes: 0 additions & 2 deletions src/app/clusters/descriptor/descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
118 changes: 0 additions & 118 deletions src/app/clusters/test-cluster-server/test-cluster-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
10 changes: 0 additions & 10 deletions src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
* @}
*/

0 comments on commit 2361248

Please sign in to comment.