From 4546833d28a892ca3f1ce67417d5a92c76a46151 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 23 Mar 2023 15:59:09 -0400 Subject: [PATCH] Remove unused things from af.h. (#25807) Fixes https://github.com/project-chip/connectedhomeip/issues/1939 --- src/app/util/af.h | 121 ----------------------------- src/app/util/attribute-storage.cpp | 8 -- src/app/util/util.cpp | 15 ---- 3 files changed, 144 deletions(-) diff --git a/src/app/util/af.h b/src/app/util/af.h index 8b052d6e025524..f59d36c1fcb126 100644 --- a/src/app/util/af.h +++ b/src/app/util/af.h @@ -118,35 +118,6 @@ EmberAfStatus emberAfWriteAttribute(chip::EndpointId endpoint, chip::ClusterId c EmberAfStatus emberAfReadAttribute(chip::EndpointId endpoint, chip::ClusterId cluster, chip::AttributeId attributeID, uint8_t * dataPtr, uint16_t readLength); -/** - * @brief this function returns the size of the ZCL data in bytes. - * - * @param dataType Zcl data type - * @return size in bytes or 0 if invalid data type - */ -uint8_t emberAfGetDataSize(uint8_t dataType); - -/** - * @brief macro that returns true if the cluster is in the manufacturer specific range - * - * @param cluster EmberAfCluster* to consider - */ -#define emberAfClusterIsManufacturerSpecific(cluster) ((cluster)->clusterId >= 0xFC00) - -/** - * @brief macro that returns true if attribute is saved in external storage. - * - * @param metadata EmberAfAttributeMetadata* to consider. - */ -#define emberAfAttributeIsExternal(metadata) (((metadata)->mask & ATTRIBUTE_MASK_EXTERNAL_STORAGE) != 0) - -/** - * @brief macro that returns true if attribute is a singleton - * - * @param metadata EmberAfAttributeMetadata* to consider. - */ -#define emberAfAttributeIsSingleton(metadata) (((metadata)->mask & ATTRIBUTE_MASK_SINGLETON) != 0) - /** * @brief macro that returns size of attribute in bytes. * @@ -187,11 +158,6 @@ uint16_t emberAfIndexFromEndpointIncludingDisabledEndpoints(chip::EndpointId end */ uint16_t emberAfFindClusterServerEndpointIndex(chip::EndpointId endpoint, chip::ClusterId clusterId); -/** - * @brief Macro that returns the primary endpoint. - */ -#define emberAfPrimaryEndpoint() (emAfEndpoints[0].endpoint) - /** * @brief Returns the total number of endpoints (dynamic and pre-compiled). */ @@ -202,17 +168,6 @@ uint16_t emberAfEndpointCount(void); */ uint16_t emberAfFixedEndpointCount(void); -/** - * Data types are either analog or discrete. This makes a difference for - * some of the ZCL global commands - */ -enum -{ - EMBER_AF_DATA_TYPE_ANALOG = 0, - EMBER_AF_DATA_TYPE_DISCRETE = 1, - EMBER_AF_DATA_TYPE_NONE = 2 -}; - /** *@brief Returns true if type is signed, false otherwise. */ @@ -227,7 +182,6 @@ uint16_t emberAfGetInt16u(const uint8_t * message, uint16_t currentIndex, uint16 * @brief Macro for consistency, that extracts single byte out of the message */ #define emberAfGetInt8u(message, currentIndex, msgLen) message[currentIndex] -#define emberAfGetInt8s(message, currentIndex, msgLen) chip::CastToSigned(emberAfGetInt8u(message, currentIndex, msgLen)) /** * @brief Macro for consistency that copies a uint8_t from variable into buffer. @@ -237,14 +191,6 @@ uint16_t emberAfGetInt16u(const uint8_t * message, uint16_t currentIndex, uint16 * @brief function that copies a uint16_t value into a buffer */ void emberAfCopyInt16u(uint8_t * data, uint16_t index, uint16_t x); -/** - * @brief function that copies a uint24_t value into a buffer - */ -void emberAfCopyInt24u(uint8_t * data, uint16_t index, uint32_t x); -/** - * @brief function that copies a uint32_t value into a buffer - */ -void emberAfCopyInt32u(uint8_t * data, uint16_t index, uint32_t x); /* * @brief Function that copies a ZCL string type into a buffer. The size * parameter should indicate the maximum number of characters to copy to the @@ -288,18 +234,6 @@ bool emberAfEndpointEnableDisable(chip::EndpointId endpoint, bool enable); */ bool emberAfEndpointIndexIsEnabled(uint16_t index); -/** - * @brief Returns true if a given ZCL data type is a string type. - * - * You should use this function if you need to perform a different - * memory operation on a certain attribute because it is a string type. - * Since ZCL strings carry length as the first byte(s), it is often required - * to treat them differently than regular data types. - * - * @return true if data type is a string. - */ -bool emberAfIsThisDataTypeAStringType(EmberAfAttributeType dataType); - /** @brief Returns true if a given ZCL data type is a list type. */ bool emberAfIsThisDataTypeAListType(EmberAfAttributeType dataType); @@ -317,63 +251,8 @@ bool emberAfIsThisDataTypeAListType(EmberAfAttributeType dataType); */ int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t len, bool signedNumber); -/** - * @brief populates the passed EUI64 with the local EUI64 MAC address. - */ -void emberAfGetEui64(EmberEUI64 returnEui64); - -/** - * @brief Returns the node ID of the local node. - */ -EmberNodeId emberAfGetNodeId(void); - /** @} END Miscellaneous */ -/** @name Messaging */ -// @{ - -/** - * @brief Set the source and destination endpoints in the client API APS frame. - */ -void emberAfSetCommandEndpoints(chip::EndpointId sourceEndpoint, chip::EndpointId destinationEndpoint); - -/** @} END Messaging */ - -/** @name ZCL macros */ -// @{ -// Frame control fields (8 bits total) -// Bits 0 and 1 are Frame Type Sub-field -#define ZCL_FRAME_CONTROL_FRAME_TYPE_MASK (EMBER_BIT(0) | EMBER_BIT(1)) -#define ZCL_CLUSTER_SPECIFIC_COMMAND EMBER_BIT(0) -#define ZCL_PROFILE_WIDE_COMMAND 0 -#define ZCL_GLOBAL_COMMAND (ZCL_PROFILE_WIDE_COMMAND) -// Bit 2 is Manufacturer Specific Sub-field -#define ZCL_MANUFACTURER_SPECIFIC_MASK EMBER_BIT(2) -// Bit 3 is Direction Sub-field -#define ZCL_FRAME_CONTROL_DIRECTION_MASK EMBER_BIT(3) -#define ZCL_FRAME_CONTROL_SERVER_TO_CLIENT EMBER_BIT(3) -#define ZCL_FRAME_CONTROL_CLIENT_TO_SERVER 0 -// Bit 4 is Disable Default Response Sub-field -#define ZCL_DISABLE_DEFAULT_RESPONSE_MASK EMBER_BIT(4) -// Bits 5 to 7 are reserved - -#define ZCL_DIRECTION_CLIENT_TO_SERVER 0 -#define ZCL_DIRECTION_SERVER_TO_CLIENT 1 - -// Packet must be at least 3 bytes for ZCL overhead. -// Frame Control (1-byte) -// Sequence Number (1-byte) -// Command Id (1-byte) -#define EMBER_AF_ZCL_OVERHEAD 3 -#define EMBER_AF_ZCL_MANUFACTURER_SPECIFIC_OVERHEAD 5 - -// Permitted values for emberAfSetFormAndJoinMode -#define FIND_AND_JOIN_MODE_ALLOW_2_4_GHZ EMBER_BIT(0) -#define FIND_AND_JOIN_MODE_ALLOW_SUB_GHZ EMBER_BIT(1) -#define FIND_AND_JOIN_MODE_ALLOW_BOTH (FIND_AND_JOIN_MODE_ALLOW_2_4_GHZ | FIND_AND_JOIN_MODE_ALLOW_SUB_GHZ) - -/** @} END ZCL macros */ - /** @} END addtogroup */ #if !defined(DOXYGEN_SHOULD_SKIP_THIS) diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 5254d2138b9f31..322c22cd549e67 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -298,14 +298,6 @@ bool emberAfEndpointIndexIsEnabled(uint16_t index) return (emAfEndpoints[index].bitmask & EMBER_AF_ENDPOINT_ENABLED); } -// some data types (like strings) are sent OTA in human readable order -// (how they are read) instead of little endian as the data types are. -bool emberAfIsThisDataTypeAStringType(EmberAfAttributeType dataType) -{ - return (dataType == ZCL_OCTET_STRING_ATTRIBUTE_TYPE || dataType == ZCL_CHAR_STRING_ATTRIBUTE_TYPE || - dataType == ZCL_LONG_OCTET_STRING_ATTRIBUTE_TYPE || dataType == ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE); -} - bool emberAfIsStringAttributeType(EmberAfAttributeType attributeType) { return (attributeType == ZCL_OCTET_STRING_ATTRIBUTE_TYPE || attributeType == ZCL_CHAR_STRING_ATTRIBUTE_TYPE); diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index f5855d5757801c..f11e4c635a5509 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -163,21 +163,6 @@ void emberAfCopyInt16u(uint8_t * data, uint16_t index, uint16_t x) data[index + 1] = (uint8_t)(((x) >> 8) & 0xFF); } -void emberAfCopyInt24u(uint8_t * data, uint16_t index, uint32_t x) -{ - data[index] = (uint8_t)(((x)) & 0xFF); - data[index + 1] = (uint8_t)(((x) >> 8) & 0xFF); - data[index + 2] = (uint8_t)(((x) >> 16) & 0xFF); -} - -void emberAfCopyInt32u(uint8_t * data, uint16_t index, uint32_t x) -{ - data[index] = (uint8_t)(((x)) & 0xFF); - data[index + 1] = (uint8_t)(((x) >> 8) & 0xFF); - data[index + 2] = (uint8_t)(((x) >> 16) & 0xFF); - data[index + 3] = (uint8_t)(((x) >> 24) & 0xFF); -} - void emberAfCopyString(uint8_t * dest, const uint8_t * src, size_t size) { if (src == nullptr)