Skip to content

Commit

Permalink
Simplify implementation of emberAfContainsAttribute. (#17956)
Browse files Browse the repository at this point in the history
The current implementation looks up the attribute metadata, which
involves figuring out where in the global attribute storage the
attribute might live, which depends on the state of other endpoints.

Instead, use emberAfGetServerAttributeIndexByAttributeId, which only
depends on the state of the one endpoint in question.

This allows removing a workaround for the "calling these functions
when endpoints are not initialized yet" bits that was added in #17719.
  • Loading branch information
bzbarsky-apple authored May 5, 2022
1 parent fe4798b commit 00ccf44
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 0 additions & 4 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,6 @@ EmberAfStatus emAfReadOrWriteAttribute(EmberAfAttributeSearchRecord * attRecord,
// Dynamic endpoints are external and don't factor into storage size
if (!isDynamicEndpoint)
{
if (emAfEndpoints[ep].endpointType == nullptr)
{
return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE;
}
attributeOffsetIndex = static_cast<uint16_t>(attributeOffsetIndex + emAfEndpoints[ep].endpointType->endpointSize);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ uint8_t emberAfMake8bitEncodedChanPg(uint8_t page, uint8_t channel)

bool emberAfContainsAttribute(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId)
{
return (emberAfLocateAttributeMetadata(endpoint, clusterId, attributeId) != nullptr);
return (emberAfGetServerAttributeIndexByAttributeId(endpoint, clusterId, attributeId) != UINT16_MAX);
}

bool emberAfIsNonVolatileAttribute(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId)
Expand Down

0 comments on commit 00ccf44

Please sign in to comment.