Skip to content

Commit

Permalink
Remove manufacturer code from attribute-storage APIs. (#13546)
Browse files Browse the repository at this point in the history
Matter does not use a separate manufacturer code.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jul 19, 2023
1 parent bf7c60b commit 1106860
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 225 deletions.
13 changes: 5 additions & 8 deletions src/app/clusters/ias-zone-server/ias-zone-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,29 +594,26 @@ static bool areZoneServerAttributesNonVolatile(EndpointId endpoint)
{
EmberAfAttributeMetadata * metadata;

metadata = emberAfLocateAttributeMetadata(endpoint, ZCL_IAS_ZONE_CLUSTER_ID, ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER, EMBER_AF_NULL_MANUFACTURER_CODE);
metadata =
emberAfLocateAttributeMetadata(endpoint, ZCL_IAS_ZONE_CLUSTER_ID, ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID, CLUSTER_MASK_SERVER);
if (!metadata->IsNonVolatile())
{
return false;
}

metadata = emberAfLocateAttributeMetadata(endpoint, ZCL_IAS_ZONE_CLUSTER_ID, ZCL_ZONE_STATE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER,
EMBER_AF_NULL_MANUFACTURER_CODE);
metadata = emberAfLocateAttributeMetadata(endpoint, ZCL_IAS_ZONE_CLUSTER_ID, ZCL_ZONE_STATE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER);
if (!metadata->IsNonVolatile())
{
return false;
}

metadata = emberAfLocateAttributeMetadata(endpoint, ZCL_IAS_ZONE_CLUSTER_ID, ZCL_ZONE_TYPE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER,
EMBER_AF_NULL_MANUFACTURER_CODE);
metadata = emberAfLocateAttributeMetadata(endpoint, ZCL_IAS_ZONE_CLUSTER_ID, ZCL_ZONE_TYPE_ATTRIBUTE_ID, CLUSTER_MASK_SERVER);
if (!metadata->IsNonVolatile())
{
return false;
}

metadata = emberAfLocateAttributeMetadata(endpoint, ZCL_IAS_ZONE_CLUSTER_ID, ZCL_ZONE_ID_ATTRIBUTE_ID, CLUSTER_MASK_SERVER,
EMBER_AF_NULL_MANUFACTURER_CODE);
metadata = emberAfLocateAttributeMetadata(endpoint, ZCL_IAS_ZONE_CLUSTER_ID, ZCL_ZONE_ID_ATTRIBUTE_ID, CLUSTER_MASK_SERVER);
if (!metadata->IsNonVolatile())
{
return false;
Expand Down
7 changes: 3 additions & 4 deletions src/app/clusters/level-control/level-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,15 +1034,14 @@ static bool areStartUpLevelControlServerAttributesNonVolatile(EndpointId endpoin
{
EmberAfAttributeMetadata * metadata;

metadata = emberAfLocateAttributeMetadata(endpoint, LevelControl::Id, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, CLUSTER_MASK_SERVER,
EMBER_AF_NULL_MANUFACTURER_CODE);
metadata = emberAfLocateAttributeMetadata(endpoint, LevelControl::Id, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, CLUSTER_MASK_SERVER);
if (!metadata->IsNonVolatile())
{
return false;
}

metadata = emberAfLocateAttributeMetadata(endpoint, LevelControl::Id, ZCL_START_UP_CURRENT_LEVEL_ATTRIBUTE_ID,
CLUSTER_MASK_SERVER, EMBER_AF_NULL_MANUFACTURER_CODE);
metadata =
emberAfLocateAttributeMetadata(endpoint, LevelControl::Id, ZCL_START_UP_CURRENT_LEVEL_ATTRIBUTE_ID, CLUSTER_MASK_SERVER);
if (!metadata->IsNonVolatile())
{
return false;
Expand Down
6 changes: 2 additions & 4 deletions src/app/clusters/on-off-server/on-off-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,13 @@ bool OnOffServer::areStartUpOnOffServerAttributesNonVolatile(EndpointId endpoint
{
EmberAfAttributeMetadata * metadata;

metadata = emberAfLocateAttributeMetadata(endpoint, OnOff::Id, Attributes::OnOff::Id, CLUSTER_MASK_SERVER,
EMBER_AF_NULL_MANUFACTURER_CODE);
metadata = emberAfLocateAttributeMetadata(endpoint, OnOff::Id, Attributes::OnOff::Id, CLUSTER_MASK_SERVER);
if (!metadata->IsNonVolatile())
{
return false;
}

metadata = emberAfLocateAttributeMetadata(endpoint, OnOff::Id, Attributes::StartUpOnOff::Id, CLUSTER_MASK_SERVER,
EMBER_AF_NULL_MANUFACTURER_CODE);
metadata = emberAfLocateAttributeMetadata(endpoint, OnOff::Id, Attributes::StartUpOnOff::Id, CLUSTER_MASK_SERVER);
if (!metadata->IsNonVolatile())
{
return false;
Expand Down
9 changes: 1 addition & 8 deletions src/app/util/af-main-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,14 +576,7 @@ void emAfMessageSentHandler(const MessageSendDestination & destination, EmberAps

if (messageContents != NULL && messageContents[0] & ZCL_CLUSTER_SPECIFIC_COMMAND)
{
emberAfClusterMessageSentWithMfgCodeCallback(
destination, apsFrame, messageLength, messageContents, status,
// If the manufacturer specific flag is set
// get read it as next part of message
// else use null code.
(((messageContents[0] & ZCL_MANUFACTURER_SPECIFIC_MASK) == ZCL_MANUFACTURER_SPECIFIC_MASK)
? emberAfGetInt16u(messageContents, 1, messageLength)
: EMBER_AF_NULL_MANUFACTURER_CODE));
emberAfClusterMessageSentCallback(destination, apsFrame, messageLength, messageContents, status);
}

if (callback != NULL)
Expand Down
53 changes: 4 additions & 49 deletions src/app/util/af.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,59 +92,29 @@
* @return Returns pointer to the attribute metadata location.
*/
EmberAfAttributeMetadata * emberAfLocateAttributeMetadata(chip::EndpointId endpoint, chip::ClusterId clusterId,
chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode);
chip::AttributeId attributeId, uint8_t mask);

#ifdef DOXYGEN_SHOULD_SKIP_THIS
/** @brief Returns true if the attribute exists. */
bool emberAfContainsAttribute(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask,
uint16_t manufacturerCode);
bool emberAfContainsAttribute(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask);
#else
#define emberAfContainsAttribute(endpoint, clusterId, attributeId, mask, manufacturerCode) \
(emberAfLocateAttributeMetadata(endpoint, clusterId, attributeId, mask, manufacturerCode) != NULL)
#define emberAfContainsAttribute(endpoint, clusterId, attributeId, mask) \
(emberAfLocateAttributeMetadata(endpoint, clusterId, attributeId, mask) != NULL)
#endif

/**
* @brief Returns true if endpoint contains a cluster, checking for mfg code.
*
* This function returns true regardless of whether
* the endpoint contains server, client or both.
* For standard libraries (when ClusterId < FC00),
* the manufacturerCode is ignored.
*/
bool emberAfContainsClusterWithMfgCode(chip::EndpointId endpoint, chip::ClusterId clusterId, uint16_t manufacturerCode);

/**
* @brief Returns true if endpoint contains the ZCL cluster with specified id.
*
* This function returns true regardless of whether
* the endpoint contains server, client or both in the Zigbee cluster Library.
* This wraps emberAfContainsClusterWithMfgCode with
* manufacturerCode = EMBER_AF_NULL_MANUFACTURER_CODE
* If this function is used with a manufacturer specific clusterId
* then this will return the first cluster that it finds in the Cluster table.
* and will not return any other clusters that share that id.
*/
bool emberAfContainsCluster(chip::EndpointId endpoint, chip::ClusterId clusterId);

/**
* @brief Returns true if endpoint has cluster server, checking for mfg code.
*
* This function returns true if
* the endpoint contains server of a given cluster.
* For standard librarys (when ClusterId < FC00), the manufacturerCode is ignored.
*/
bool emberAfContainsServerWithMfgCode(chip::EndpointId endpoint, chip::ClusterId clusterId, uint16_t manufacturerCode);

/**
* @brief Returns true if endpoint contains the ZCL server with specified id.
*
* This function returns true if
* the endpoint contains server of a given cluster.
* This wraps emberAfContainsServer with
* manufacturerCode = EMBER_AF_NULL_MANUFACTURER_CODE
* If this function is used with a manufacturer specific clusterId
* then this will return the first cluster that it finds in the Cluster table.
* and will not return any other clusters that share that id.
*/
bool emberAfContainsServer(chip::EndpointId endpoint, chip::ClusterId clusterId);

Expand All @@ -159,26 +129,11 @@ bool emberAfContainsServer(chip::EndpointId endpoint, chip::ClusterId clusterId)
*/
bool emberAfContainsServerFromIndex(uint16_t index, chip::ClusterId clusterId);

/**
* @brief Returns true if endpoint contains cluster client.
*
* This function returns true if
* the endpoint contains client of a given cluster.
* For standard library clusters (when ClusterId < FC00),
* the manufacturerCode is ignored.
*/
bool emberAfContainsClientWithMfgCode(chip::EndpointId endpoint, chip::ClusterId clusterId, uint16_t manufacturerCode);

/**
* @brief Returns true if endpoint contains the ZCL client with specified id.
*
* This function returns true if
* the endpoint contains client of a given cluster.
* This wraps emberAfContainsClient with
* manufacturerCode = EMBER_AF_NULL_MANUFACTURER_CODE
* If this function is used with a manufacturer specific clusterId
* then this will return the first cluster that it finds in the Cluster table.
* and will not return any other clusters that share that id.
*/
bool emberAfContainsClient(chip::EndpointId endpoint, chip::ClusterId clusterId);

Expand Down
Loading

0 comments on commit 1106860

Please sign in to comment.