Skip to content

Commit

Permalink
Remove attribute-size.cpp.
Browse files Browse the repository at this point in the history
This was being used only for the old list encoding, which we are not using anymore
  • Loading branch information
bzbarsky-apple committed Dec 7, 2021
1 parent f647393 commit e38c989
Show file tree
Hide file tree
Showing 58 changed files with 61 additions and 10,311 deletions.
1 change: 0 additions & 1 deletion examples/all-clusters-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ include(${prj_root}/GCC-RELEASE/project_hp/asdk/includepath.cmake)
list(
APPEND ${list_chip_main_sources}

${chip_dir}/zzz_generated/all-clusters-app/zap-generated/attribute-size.cpp
${chip_dir}/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp
${chip_dir}/zzz_generated/all-clusters-app/zap-generated/callback-stub.cpp
${chip_dir}/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ target_sources(${APP_TARGET} PRIVATE

${MBED_COMMON}/util/LEDWidget.cpp

${GEN_DIR}/all-clusters-app/zap-generated/attribute-size.cpp
${GEN_DIR}/all-clusters-app/zap-generated/callback-stub.cpp
${GEN_DIR}/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp
${GEN_DIR}/all-clusters-app/zap-generated/CHIPClusters.cpp
Expand Down
8 changes: 3 additions & 5 deletions examples/bridge-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,12 @@ uint8_t * ToZclCharString(uint8_t * zclString, const char * cString, uint8_t max
// Converted into bytes and mapped the (label, value)
void EncodeFixedLabel(const char * label, const char * value, uint8_t * buffer, uint16_t length, EmberAfAttributeMetadata * am)
{
uint16_t listCount = 1;
_LabelStruct labelStruct;

labelStruct.label = chip::CharSpan(label, strlen(label));
labelStruct.value = chip::CharSpan(value, strlen(value));

emberAfCopyList(ZCL_FIXED_LABEL_CLUSTER_ID, am, true, buffer, reinterpret_cast<uint8_t *>(&labelStruct), 1);
emberAfCopyList(ZCL_FIXED_LABEL_CLUSTER_ID, am, true, buffer, reinterpret_cast<uint8_t *>(&listCount), 0);
// TODO: Need to set up an AttributeAccessInterface to handle the lists here.
}

EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer,
Expand Down Expand Up @@ -260,7 +258,7 @@ EmberAfStatus HandleWriteOnOffAttribute(Device * dev, chip::AttributeId attribut

EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
uint8_t * buffer, uint16_t maxReadLength, int32_t index)
uint8_t * buffer, uint16_t maxReadLength)
{
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);

Expand All @@ -287,7 +285,7 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI

EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
uint8_t * buffer, int32_t index)
uint8_t * buffer)
{
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);

Expand Down
8 changes: 3 additions & 5 deletions examples/bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ int RemoveDeviceEndpoint(Device * dev)
void EncodeFixedLabel(const char * label, const char * value, uint8_t * buffer, uint16_t length, EmberAfAttributeMetadata * am)
{
char zclOctetStrBuf[kFixedLabelElementsOctetStringSize];
uint16_t listCount = 1;
_LabelStruct labelStruct;

// TODO: This size is obviously wrong. See
Expand All @@ -251,8 +250,7 @@ void EncodeFixedLabel(const char * label, const char * value, uint8_t * buffer,
// https://github.com/project-chip/connectedhomeip/issues/10743
labelStruct.value = CharSpan(&zclOctetStrBuf[0], sizeof(zclOctetStrBuf));

emberAfCopyList(ZCL_FIXED_LABEL_CLUSTER_ID, am, true, buffer, reinterpret_cast<uint8_t *>(&labelStruct), 1);
emberAfCopyList(ZCL_FIXED_LABEL_CLUSTER_ID, am, true, buffer, reinterpret_cast<uint8_t *>(&listCount), 0);
// TODO: Need to set up an AttributeAccessInterface to handle the lists here.
}

void HandleDeviceStatusChanged(Device * dev, Device::Changed_t itemChangedMask)
Expand Down Expand Up @@ -454,7 +452,7 @@ EmberAfStatus HandleReadSwitchAttribute(DeviceSwitch * dev, chip::AttributeId at

EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
uint8_t * buffer, uint16_t maxReadLength, int32_t index)
uint8_t * buffer, uint16_t maxReadLength)
{
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);

Expand Down Expand Up @@ -488,7 +486,7 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI

EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
uint8_t * buffer, int32_t index)
uint8_t * buffer)
{
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);

Expand Down
11 changes: 3 additions & 8 deletions examples/common/pigweed/rpc_services/Attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,9 @@ class Attributes : public generated::Attributes<Attributes>
response.which_data = chip_rpc_AttributeData_data_uint32_tag;
break;
case chip_rpc_AttributeType_ZCL_ARRAY_ATTRIBUTE_TYPE:
data = response.data.data_bytes.bytes;
size = sizeof(response.data.data_bytes.bytes);
RETURN_STATUS_IF_NOT_OK(emberAfReadServerAttribute(request.endpoint, request.cluster, request.attribute_id,
static_cast<uint8_t *>(data), size));
size = emberAfAttributeValueListSize(request.cluster, request.attribute_id, (const uint8_t *) data);
response.data.data_bytes.size = size;
response.which_data = chip_rpc_AttributeData_data_bytes_tag;
return pw::OkStatus();
// We don't know how to read these; need to get the right
// AttributeAccessInterface.
return pw::Status::InvalidArgument();
case chip_rpc_AttributeType_ZCL_BITMAP64_ATTRIBUTE_TYPE:
case chip_rpc_AttributeType_ZCL_INT24U_ATTRIBUTE_TYPE:
case chip_rpc_AttributeType_ZCL_INT40U_ATTRIBUTE_TYPE:
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ include(${prj_root}/GCC-RELEASE/project_hp/asdk/includepath.cmake)
list(
APPEND ${list_chip_main_sources}

${chip_dir}/zzz_generated/lighting-app/zap-generated/attribute-size.cpp
${chip_dir}/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp
${chip_dir}/zzz_generated/lighting-app/zap-generated/callback-stub.cpp
${chip_dir}/zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ target_sources(${APP_TARGET} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/main/LightingManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/main/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/main/ZclCallbacks.cpp
${GEN_DIR}/lighting-app/zap-generated/attribute-size.cpp
${GEN_DIR}/lighting-app/zap-generated/callback-stub.cpp
${GEN_DIR}/lighting-app/zap-generated/IMClusterCommandHandler.cpp
${MBED_COMMON}/util/LEDWidget.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ target_sources(app PRIVATE
main/LightingManager.cpp
main/main.cpp
main/ZclCallbacks.cpp
${GEN_DIR}/lighting-app/zap-generated/attribute-size.cpp
${GEN_DIR}/lighting-app/zap-generated/callback-stub.cpp
${GEN_DIR}/lighting-app/zap-generated/CHIPClusters.cpp
${GEN_DIR}/lighting-app/zap-generated/IMClusterCommandHandler.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ target_sources(app PRIVATE
src/LightingManager.cpp
src/main.cpp
src/ZclCallbacks.cpp
${GEN_DIR}/lighting-app/zap-generated/attribute-size.cpp
${GEN_DIR}/lighting-app/zap-generated/callback-stub.cpp
${GEN_DIR}/lighting-app/zap-generated/IMClusterCommandHandler.cpp
${TELINK_COMMON}/util/src/LEDWidget.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/mbed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ target_sources(${APP_TARGET} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/main/BoltLockManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/main/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/main/ZclCallbacks.cpp
${GEN_DIR}/lock-app/zap-generated/attribute-size.cpp
${GEN_DIR}/lock-app/zap-generated/callback-stub.cpp
${GEN_DIR}/lock-app/zap-generated/IMClusterCommandHandler.cpp
${MBED_COMMON}/util/LEDWidget.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ target_sources(app PRIVATE
main/BoltLockManager.cpp
main/main.cpp
main/ZclCallbacks.cpp
${GEN_DIR}/lock-app/zap-generated/attribute-size.cpp
${GEN_DIR}/lock-app/zap-generated/callback-stub.cpp
${GEN_DIR}/lock-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/pump-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ target_sources(app PRIVATE
main/PumpManager.cpp
main/main.cpp
main/ZclCallbacks.cpp
${GEN_DIR}/pump-app/zap-generated/attribute-size.cpp
${GEN_DIR}/pump-app/zap-generated/callback-stub.cpp
${GEN_DIR}/pump-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp
Expand Down
1 change: 0 additions & 1 deletion examples/pump-controller-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ target_sources(app PRIVATE
main/PumpManager.cpp
main/main.cpp
main/ZclCallbacks.cpp
${GEN_DIR}/pump-controller-app/zap-generated/attribute-size.cpp
${GEN_DIR}/pump-controller-app/zap-generated/callback-stub.cpp
${GEN_DIR}/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/LEDWidget.cpp
Expand Down
1 change: 0 additions & 1 deletion src/app/chip_data_model.gni
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ template("chip_data_model") {

if (defined(invoker.zap_pregenerated_dir)) {
sources += [
"${invoker.zap_pregenerated_dir}/attribute-size.cpp",
"${invoker.zap_pregenerated_dir}/callback-stub.cpp",
]

Expand Down
4 changes: 2 additions & 2 deletions src/app/util/ContentAppPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using namespace chip::AppPlatform;

EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
uint8_t * buffer, uint16_t maxReadLength, int32_t index)
uint8_t * buffer, uint16_t maxReadLength)
{
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);

Expand All @@ -64,7 +64,7 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI

EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId,
EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
uint8_t * buffer, int32_t index)
uint8_t * buffer)
{
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);

Expand Down
33 changes: 0 additions & 33 deletions src/app/util/af.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,30 +588,6 @@ uint8_t emberAfStringLength(const uint8_t * buffer);
*/
uint16_t emberAfLongStringLength(const uint8_t * buffer);

/*
* @brief Function that copies (part of) a ZCL typed list into a buffer. The index parameter
* may indicate a specific member of the list, or the list length, or the whole list if it
* is equal to -1.
*
* Individual elements may be accessed by an index of type 16-bit unsigned integer.
* Elements are numbered from 1 upwards. The element with index 0 is always of type
* uint16, and holds the number of elements contained in the list, which may be zero.
* If the zeroth element contains 0xffff, the list is a non value and is considered
* undefined.
*
* When writing, dest points to the list to write to, src points to the value to write, and index is the index to write at.
*
* When reading (i.e write is false), dest is the location to read into, src points to the list, and index is the index to read
* from.
*
* When reading or writing if the index leads to read or write outside of the
* allocated size for the list, this function will return 0.
*
* @return The number of bytes copied
*/
uint16_t emberAfCopyList(chip::ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src,
int32_t index);

/*
* @brief Function that determines the size of a zigbee Cluster Library
* attribute value (where the attribute could be non-string, string, or long
Expand All @@ -621,15 +597,6 @@ uint16_t emberAfCopyList(chip::ClusterId clusterId, EmberAfAttributeMetadata * a
uint16_t emberAfAttributeValueSize(chip::ClusterId clusterId, chip::AttributeId attributeId, EmberAfAttributeType dataType,
const uint8_t * buffer);

/*
* @brief Function that determines the size of a zigbee Cluster Library
* attribute List[T] where T could be of any type.
* The size is expressed in bytes, and includes the used length consumed
* by list entries plus the 2 bytes used to represent the number of actual
* entries in the list.
*/
uint16_t emberAfAttributeValueListSize(chip::ClusterId clusterId, chip::AttributeId attributeId, const uint8_t * buffer);

/** @} END Attribute Storage */

/** @name Device Control */
Expand Down
6 changes: 2 additions & 4 deletions src/app/util/attribute-size-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ uint16_t emberAfAttributeValueSize(ClusterId clusterId, AttributeId attrId, Embe
}
else if (emberAfIsThisDataTypeAListType(dataType))
{
if (buffer != 0)
{
dataSize = emberAfAttributeValueListSize(clusterId, attrId, buffer);
}
// Just claim to have a length and nothing else.
dataSize = 2;
}
else
{
Expand Down
18 changes: 7 additions & 11 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,8 @@ static uint8_t * singletonAttributeLocation(EmberAfAttributeMetadata * am)
// If src == NULL, then this method will set memory to zeroes
// See documentation for emAfReadOrWriteAttribute for the semantics of
// readLength when reading and writing.
//
// The index argument is used exclusively for List. When reading or writing a List attribute, it could take 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
static EmberAfStatus typeSensitiveMemCopy(ClusterId clusterId, uint8_t * dest, uint8_t * src, EmberAfAttributeMetadata * am,
bool write, uint16_t readLength, int32_t index)
bool write, uint16_t readLength)
{
EmberAfAttributeType attributeType = am->attributeType;
// readLength == 0 for a read indicates that we should just trust that the
Expand Down Expand Up @@ -468,7 +463,8 @@ static EmberAfStatus typeSensitiveMemCopy(ClusterId clusterId, uint8_t * dest, u
return EMBER_ZCL_STATUS_INSUFFICIENT_SPACE;
}

emberAfCopyList(clusterId, am, write, dest, src, index);
// Just copy the length.
memmove(dest, src, 2);
}
else
{
Expand Down Expand Up @@ -530,7 +526,7 @@ bool emAfMatchAttribute(EmberAfCluster * cluster, EmberAfAttributeMetadata * am,
// attribute. This means the resulting string may be truncated. The length
// byte(s) in the resulting string will reflect any truncated.
EmberAfStatus emAfReadOrWriteAttribute(EmberAfAttributeSearchRecord * attRecord, EmberAfAttributeMetadata ** metadata,
uint8_t * buffer, uint16_t readLength, bool write, int32_t index)
uint8_t * buffer, uint16_t readLength, bool write)
{
uint16_t attributeOffsetIndex = 0;

Expand Down Expand Up @@ -600,17 +596,17 @@ EmberAfStatus emAfReadOrWriteAttribute(EmberAfAttributeSearchRecord * attRecord,
{
return (write ? emberAfExternalAttributeWriteCallback(attRecord->endpoint, attRecord->clusterId,
am, EMBER_AF_NULL_MANUFACTURER_CODE,
buffer, index)
buffer)
: emberAfExternalAttributeReadCallback(attRecord->endpoint, attRecord->clusterId,
am, EMBER_AF_NULL_MANUFACTURER_CODE,
buffer, emberAfAttributeSize(am), index));
buffer, emberAfAttributeSize(am)));
}
else
{
// Internal storage is only supported for fixed endpoints
if (!isDynamicEndpoint)
{
return typeSensitiveMemCopy(attRecord->clusterId, dst, src, am, write, readLength, index);
return typeSensitiveMemCopy(attRecord->clusterId, dst, src, am, write, readLength);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/util/attribute-storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void emAfCallInits(void);
void emberAfEndpointConfigure(void);

EmberAfStatus emAfReadOrWriteAttribute(EmberAfAttributeSearchRecord * attRecord, EmberAfAttributeMetadata ** metadata,
uint8_t * buffer, uint16_t readLength, bool write, int32_t index = -1);
uint8_t * buffer, uint16_t readLength, bool write);

bool emAfMatchCluster(EmberAfCluster * cluster, EmberAfAttributeSearchRecord * attRecord);
bool emAfMatchAttribute(EmberAfCluster * cluster, EmberAfAttributeMetadata * am, EmberAfAttributeSearchRecord * attRecord);
Expand Down
9 changes: 2 additions & 7 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,14 +533,9 @@ CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const Concre
case ZCL_ARRAY_ATTRIBUTE_TYPE: {
// We only get here for attributes of list type that have no override
// registered. There should not be any nonempty lists like that.
uint16_t size = emberAfAttributeValueSize(aPath.mClusterId, aPath.mAttributeId, attributeType, attributeData);
if (size != 2)
uint16_t length = emberAfGetInt16u(attributeData, 0, 2);
if (length != 0)
{
// The value returned by emberAfAttributeValueSize for a list
// includes the space needed to store the list length (2 bytes) plus
// the space needed to store the actual list items. We expect it to
// return 2 here, indicating a zero-length list. If it doesn't,
// something has gone wrong.
return CHIP_ERROR_INCORRECT_STATE;
}

Expand Down
5 changes: 0 additions & 5 deletions src/app/zap-templates/app-templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
"name": "Matter Application Callbacks header",
"output": "PluginApplicationCallbacks.h"
},
{
"path": "templates/app/attribute-size-src.zapt",
"name": "ZCL attribute-size",
"output": "attribute-size.cpp"
},
{
"path": "templates/app/callback-stub-src.zapt",
"name": "ZCL callback-stub source",
Expand Down
Loading

0 comments on commit e38c989

Please sign in to comment.