Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the concept of client attributes from EmberAfAttributeSearchRecord. #17825

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/app/util/af-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,6 @@ typedef struct
*/
chip::ClusterId clusterId;

/**
* Cluster mask for the cluster, used to determine if it is
* the server or client version of the cluster. See CLUSTER_MASK_
* macros defined in att-storage.h
*/
EmberAfClusterMask clusterMask;

/**
* The identifier for the attribute.
*/
Expand Down
10 changes: 1 addition & 9 deletions src/app/util/af.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ static constexpr uint16_t kEmberInvalidEndpointIndex = 0xFFFF;
* @param endpoint Zigbee endpoint number.
* @param clusterId Cluster ID of the sought cluster.
* @param attributeId Attribute ID of the sought attribute.
* @param mask CLUSTER_MASK_SERVER or CLUSTER_MASK_CLIENT
*
* @return Returns pointer to the attribute metadata location.
*/
const EmberAfAttributeMetadata * emberAfLocateAttributeMetadata(chip::EndpointId endpoint, chip::ClusterId clusterId,
chip::AttributeId attributeId, uint8_t mask);
chip::AttributeId attributeId);

/**
* @brief Returns true if endpoint contains the ZCL cluster with specified id.
Expand Down Expand Up @@ -249,13 +248,6 @@ uint8_t emberAfGetDataSize(uint8_t dataType);
*/
#define emberAfClusterIsManufacturerSpecific(cluster) ((cluster)->clusterId >= 0xFC00)

/**
* @brief macro that returns true if client attribute, and false if server.
*
* @param metadata EmberAfAttributeMetadata* to consider.
*/
#define emberAfAttributeIsClient(metadata) (((metadata)->mask & ATTRIBUTE_MASK_CLIENT) != 0)

/**
* @brief macro that returns true if attribute is saved in external storage.
*
Expand Down
4 changes: 1 addition & 3 deletions src/app/util/attribute-metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ union EmberAfDefaultOrMinMaxAttributeValue
#define ATTRIBUTE_MASK_EXTERNAL_STORAGE (0x10)
// Attribute is singleton
#define ATTRIBUTE_MASK_SINGLETON (0x20)
// Attribute is a client attribute
#define ATTRIBUTE_MASK_CLIENT (0x40)
// Attribute is nullable
#define ATTRIBUTE_MASK_NULLABLE (0x80)
#define ATTRIBUTE_MASK_NULLABLE (0x40)

/**
* @brief Each attribute has it's metadata stored in such struct.
Expand Down
10 changes: 3 additions & 7 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,12 @@ void emAfCallInits(void)
}

// Returns the pointer to metadata, or null if it is not found
const EmberAfAttributeMetadata * emberAfLocateAttributeMetadata(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId,
uint8_t mask)
const EmberAfAttributeMetadata * emberAfLocateAttributeMetadata(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId)
{
const EmberAfAttributeMetadata * metadata = nullptr;
EmberAfAttributeSearchRecord record;
record.endpoint = endpoint;
record.clusterId = clusterId;
record.clusterMask = mask;
record.attributeId = attributeId;
emAfReadOrWriteAttribute(&record, &metadata,
nullptr, // buffer
Expand Down Expand Up @@ -512,12 +510,11 @@ static EmberAfStatus typeSensitiveMemCopy(ClusterId clusterId, uint8_t * dest, u
*
* Clusters match if:
* 1. Cluster ids match AND
* 2. Cluster directions match as defined by cluster->mask
* and attRecord->clusterMask
* 2. Cluster is a server cluster (because there are no client attributes).
*/
bool emAfMatchCluster(const EmberAfCluster * cluster, EmberAfAttributeSearchRecord * attRecord)
{
return (cluster->clusterId == attRecord->clusterId && cluster->mask & attRecord->clusterMask);
return (cluster->clusterId == attRecord->clusterId && (cluster->mask & CLUSTER_MASK_SERVER));
}

/**
Expand Down Expand Up @@ -1244,7 +1241,6 @@ void emAfLoadAttributeDefaults(EndpointId endpoint, bool ignoreStorage, Optional
EmberAfAttributeSearchRecord record;
record.endpoint = de->endpoint;
record.clusterId = cluster->clusterId;
record.clusterMask = (emberAfAttributeIsClient(am) ? CLUSTER_MASK_CLIENT : CLUSTER_MASK_SERVER);
record.attributeId = am->attributeId;

if (ptr == nullptr)
Expand Down
20 changes: 13 additions & 7 deletions src/app/util/attribute-table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void emberAfPrintAttributeTable(void)
{
EmberAfDefinedEndpoint * ep = &(emAfEndpoints[endpointIndex]);
emberAfAttributesPrintln("ENDPOINT %x", ep->endpoint);
emberAfAttributesPrintln("clus / side / attr / mfg /type(len)/ rw / storage / data (raw)");
emberAfAttributesPrintln("clus / attr / mfg /type(len)/ rw / storage / data (raw)");
emberAfAttributesFlush();
for (clusterIndex = 0; clusterIndex < ep->endpointType->clusterCount; clusterIndex++)
{
Expand All @@ -174,17 +174,15 @@ void emberAfPrintAttributeTable(void)
// manually reset the watchdog.
// halResetWatchdog();

emberAfAttributesPrint(ChipLogFormatMEI " / %p / " ChipLogFormatMEI " / ", ChipLogValueMEI(cluster->clusterId),
(emberAfAttributeIsClient(metaData) ? "clnt" : "srvr"),
emberAfAttributesPrint(ChipLogFormatMEI " / " ChipLogFormatMEI " / ", ChipLogValueMEI(cluster->clusterId),
ChipLogValueMEI(metaData->attributeId));
emberAfAttributesPrint("----");
emberAfAttributesPrint(
" / %x (%x) / %p / %p / ", metaData->attributeType, emberAfAttributeSize(metaData),
(metaData->IsReadOnly() ? "RO" : "RW"),
(metaData->IsNonVolatile() ? " nonvolatile " : (metaData->IsExternal() ? " extern " : " RAM ")));
emberAfAttributesFlush();
status = emAfReadAttribute(ep->endpoint, cluster->clusterId, metaData->attributeId,
(emberAfAttributeIsClient(metaData) ? CLUSTER_MASK_CLIENT : CLUSTER_MASK_SERVER), data,
status = emAfReadAttribute(ep->endpoint, cluster->clusterId, metaData->attributeId, CLUSTER_MASK_SERVER, data,
ATTRIBUTE_LARGEST, nullptr);
if (status == EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)
{
Expand Down Expand Up @@ -299,11 +297,15 @@ static bool IsNullValue(const uint8_t * data, uint16_t dataLen, bool isAttribute
EmberAfStatus emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t mask, uint8_t * data,
EmberAfAttributeType dataType, bool overrideReadOnlyAndDataType, bool justTest)
{
if (mask != CLUSTER_MASK_SERVER)
{
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
}

const EmberAfAttributeMetadata * metadata = nullptr;
EmberAfAttributeSearchRecord record;
record.endpoint = endpoint;
record.clusterId = cluster;
record.clusterMask = mask;
record.attributeId = attributeID;
emAfReadOrWriteAttribute(&record, &metadata,
nullptr, // buffer
Expand Down Expand Up @@ -444,12 +446,16 @@ EmberAfStatus emAfWriteAttribute(EndpointId endpoint, ClusterId cluster, Attribu
EmberAfStatus emAfReadAttribute(EndpointId endpoint, ClusterId cluster, AttributeId attributeID, uint8_t mask, uint8_t * dataPtr,
uint16_t readLength, EmberAfAttributeType * dataType)
{
if (mask != CLUSTER_MASK_SERVER)
{
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
}

const EmberAfAttributeMetadata * metadata = nullptr;
EmberAfAttributeSearchRecord record;
EmberAfStatus status;
record.endpoint = endpoint;
record.clusterId = cluster;
record.clusterMask = mask;
record.attributeId = attributeID;
status = emAfReadOrWriteAttribute(&record, &metadata, dataPtr, readLength,
false); // write?
Expand Down
6 changes: 2 additions & 4 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,7 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b
attributeCluster = emberAfFindCluster(aPath.mEndpointId, aPath.mClusterId, CLUSTER_MASK_SERVER);
break;
default:
attributeMetadata =
emberAfLocateAttributeMetadata(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId, CLUSTER_MASK_SERVER);
attributeMetadata = emberAfLocateAttributeMetadata(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId);
}

if (attributeCluster == nullptr && attributeMetadata == nullptr)
Expand Down Expand Up @@ -611,7 +610,6 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b
EmberAfAttributeSearchRecord record;
record.endpoint = aPath.mEndpointId;
record.clusterId = aPath.mClusterId;
record.clusterMask = CLUSTER_MASK_SERVER;
record.attributeId = aPath.mAttributeId;
EmberAfStatus emberStatus = emAfReadOrWriteAttribute(&record, &attributeMetadata, attributeData, sizeof(attributeData),
/* write = */ false);
Expand Down Expand Up @@ -965,7 +963,7 @@ CHIP_ERROR prepareWriteData(const EmberAfAttributeMetadata * attributeMetadata,
const EmberAfAttributeMetadata * GetAttributeMetadata(const ConcreteAttributePath & aConcreteClusterPath)
{
return emberAfLocateAttributeMetadata(aConcreteClusterPath.mEndpointId, aConcreteClusterPath.mClusterId,
aConcreteClusterPath.mAttributeId, CLUSTER_MASK_SERVER);
aConcreteClusterPath.mAttributeId);
}

CHIP_ERROR WriteSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, const ConcreteDataAttributePath & aPath,
Expand Down
14 changes: 10 additions & 4 deletions src/app/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,15 +771,21 @@ uint8_t emberAfMake8bitEncodedChanPg(uint8_t page, uint8_t channel)

bool emberAfContainsAttribute(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, bool asServer)
{
uint8_t mask = asServer ? CLUSTER_MASK_SERVER : CLUSTER_MASK_CLIENT;
return (emberAfLocateAttributeMetadata(endpoint, clusterId, attributeId, mask) != nullptr);
if (!asServer)
{
return false;
}
return (emberAfLocateAttributeMetadata(endpoint, clusterId, attributeId) != nullptr);
}

bool emberAfIsNonVolatileAttribute(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
bool asServer)
{
uint8_t mask = asServer ? CLUSTER_MASK_SERVER : CLUSTER_MASK_CLIENT;
const EmberAfAttributeMetadata * metadata = emberAfLocateAttributeMetadata(endpoint, clusterId, attributeId, mask);
if (!asServer)
{
return false;
}
const EmberAfAttributeMetadata * metadata = emberAfLocateAttributeMetadata(endpoint, clusterId, attributeId);

if (metadata == nullptr)
{
Expand Down