diff --git a/examples/all-clusters-app/ameba/chip_main.cmake b/examples/all-clusters-app/ameba/chip_main.cmake index 3c0aa18f15d08f..db77f4bce9cd26 100755 --- a/examples/all-clusters-app/ameba/chip_main.cmake +++ b/examples/all-clusters-app/ameba/chip_main.cmake @@ -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 diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index a71393a6880cfa..c255084468381a 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -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 @@ -77,7 +76,6 @@ target_sources(${APP_TARGET} PRIVATE ${APP_UTIL}/attribute-storage.cpp ${APP_UTIL}/attribute-table.cpp ${APP_UTIL}/attribute-size-util.cpp - ${APP_UTIL}/attribute-list-byte-span.cpp ${APP_UTIL}/binding-table.cpp ${APP_UTIL}/chip-message-send.cpp ${APP_UTIL}/client-api.cpp diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index 411ff15c5bec8d..33aee02b2d2900 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -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(&labelStruct), 1); - emberAfCopyList(ZCL_FIXED_LABEL_CLUSTER_ID, am, true, buffer, reinterpret_cast(&listCount), 0); + // TODO: Need to set up an AttributeAccessInterface to handle the lists here. } EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer, @@ -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); @@ -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); diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index 3d7deecc5649d1..63c575acbcdf30 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -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 @@ -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(&labelStruct), 1); - emberAfCopyList(ZCL_FIXED_LABEL_CLUSTER_ID, am, true, buffer, reinterpret_cast(&listCount), 0); + // TODO: Need to set up an AttributeAccessInterface to handle the lists here. } void HandleDeviceStatusChanged(Device * dev, Device::Changed_t itemChangedMask) @@ -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); @@ -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); diff --git a/examples/common/pigweed/rpc_services/Attributes.h b/examples/common/pigweed/rpc_services/Attributes.h index 93b26f809dd543..68a85e48d620da 100644 --- a/examples/common/pigweed/rpc_services/Attributes.h +++ b/examples/common/pigweed/rpc_services/Attributes.h @@ -102,14 +102,9 @@ class Attributes : public generated::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(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: diff --git a/examples/lighting-app/ameba/chip_main.cmake b/examples/lighting-app/ameba/chip_main.cmake index e5ad4778d9d367..f10e7a2ccf9de9 100755 --- a/examples/lighting-app/ameba/chip_main.cmake +++ b/examples/lighting-app/ameba/chip_main.cmake @@ -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 diff --git a/examples/lighting-app/mbed/CMakeLists.txt b/examples/lighting-app/mbed/CMakeLists.txt index 56c75658fc7f9e..de27bb94940a1c 100644 --- a/examples/lighting-app/mbed/CMakeLists.txt +++ b/examples/lighting-app/mbed/CMakeLists.txt @@ -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 @@ -56,7 +55,6 @@ target_sources(${APP_TARGET} PRIVATE ${CHIP_ROOT}/src/app/util/DataModelHandler.cpp ${CHIP_ROOT}/src/app/util/af-event.cpp ${CHIP_ROOT}/src/app/util/af-main-common.cpp - ${CHIP_ROOT}/src/app/util/attribute-list-byte-span.cpp ${CHIP_ROOT}/src/app/util/attribute-size-util.cpp ${CHIP_ROOT}/src/app/util/attribute-storage.cpp ${CHIP_ROOT}/src/app/util/attribute-table.cpp diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 6663936334d4a1..1452ce1d6ef7ee 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -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 diff --git a/examples/lighting-app/telink/CMakeLists.txt b/examples/lighting-app/telink/CMakeLists.txt index c0961f3083b99f..8a2762230c2e51 100644 --- a/examples/lighting-app/telink/CMakeLists.txt +++ b/examples/lighting-app/telink/CMakeLists.txt @@ -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 @@ -56,7 +55,6 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/util/DataModelHandler.cpp ${CHIP_ROOT}/src/app/util/af-event.cpp ${CHIP_ROOT}/src/app/util/af-main-common.cpp - ${CHIP_ROOT}/src/app/util/attribute-list-byte-span.cpp ${CHIP_ROOT}/src/app/util/attribute-size-util.cpp ${CHIP_ROOT}/src/app/util/attribute-storage.cpp ${CHIP_ROOT}/src/app/util/attribute-table.cpp diff --git a/examples/lock-app/mbed/CMakeLists.txt b/examples/lock-app/mbed/CMakeLists.txt index 1fc39a643cc919..f0a76116d447f5 100644 --- a/examples/lock-app/mbed/CMakeLists.txt +++ b/examples/lock-app/mbed/CMakeLists.txt @@ -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 @@ -55,7 +54,6 @@ target_sources(${APP_TARGET} PRIVATE ${CHIP_ROOT}/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp ${CHIP_ROOT}/src/app/util/af-event.cpp ${CHIP_ROOT}/src/app/util/af-main-common.cpp - ${CHIP_ROOT}/src/app/util/attribute-list-byte-span.cpp ${CHIP_ROOT}/src/app/util/attribute-size-util.cpp ${CHIP_ROOT}/src/app/util/attribute-storage.cpp ${CHIP_ROOT}/src/app/util/attribute-table.cpp diff --git a/examples/lock-app/nrfconnect/CMakeLists.txt b/examples/lock-app/nrfconnect/CMakeLists.txt index 5e52554417c144..f187c196370920 100644 --- a/examples/lock-app/nrfconnect/CMakeLists.txt +++ b/examples/lock-app/nrfconnect/CMakeLists.txt @@ -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 diff --git a/examples/pump-app/nrfconnect/CMakeLists.txt b/examples/pump-app/nrfconnect/CMakeLists.txt index d843265ad395e1..e9f8574e29a53d 100644 --- a/examples/pump-app/nrfconnect/CMakeLists.txt +++ b/examples/pump-app/nrfconnect/CMakeLists.txt @@ -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 diff --git a/examples/pump-controller-app/nrfconnect/CMakeLists.txt b/examples/pump-controller-app/nrfconnect/CMakeLists.txt index c98cbb7f5ffb45..bb5e2314f6adff 100644 --- a/examples/pump-controller-app/nrfconnect/CMakeLists.txt +++ b/examples/pump-controller-app/nrfconnect/CMakeLists.txt @@ -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 diff --git a/src/app/chip_data_model.cmake b/src/app/chip_data_model.cmake index ab31d7fa06829c..663c27c142e6e1 100644 --- a/src/app/chip_data_model.cmake +++ b/src/app/chip_data_model.cmake @@ -82,7 +82,6 @@ function(chip_configure_data_model APP_TARGET) ${CHIP_APP_BASE_DIR}/../../zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp ${CHIP_APP_BASE_DIR}/util/af-event.cpp ${CHIP_APP_BASE_DIR}/util/af-main-common.cpp - ${CHIP_APP_BASE_DIR}/util/attribute-list-byte-span.cpp ${CHIP_APP_BASE_DIR}/util/attribute-size-util.cpp ${CHIP_APP_BASE_DIR}/util/attribute-storage.cpp ${CHIP_APP_BASE_DIR}/util/attribute-table.cpp diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 6e7219a0fc5b50..67dfba799c43fc 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -100,7 +100,6 @@ template("chip_data_model") { "${_app_root}/util/DataModelHandler.cpp", "${_app_root}/util/af-event.cpp", "${_app_root}/util/af-main-common.cpp", - "${_app_root}/util/attribute-list-byte-span.cpp", "${_app_root}/util/attribute-size-util.cpp", "${_app_root}/util/attribute-storage.cpp", "${_app_root}/util/attribute-table.cpp", @@ -160,10 +159,7 @@ 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", - ] + sources += [ "${invoker.zap_pregenerated_dir}/callback-stub.cpp" ] if (chip_controller) { sources += [ diff --git a/src/app/util/ContentAppPlatform.cpp b/src/app/util/ContentAppPlatform.cpp index 7b3c16ac501bb1..e99e5b607ca3ac 100644 --- a/src/app/util/ContentAppPlatform.cpp +++ b/src/app/util/ContentAppPlatform.cpp @@ -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); @@ -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); diff --git a/src/app/util/af.h b/src/app/util/af.h index f4e981e94cd1b1..d9586f79f71560 100644 --- a/src/app/util/af.h +++ b/src/app/util/af.h @@ -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 @@ -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 */ diff --git a/src/app/util/attribute-list-byte-span.cpp b/src/app/util/attribute-list-byte-span.cpp deleted file mode 100644 index 773d53291ea754..00000000000000 --- a/src/app/util/attribute-list-byte-span.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "attribute-list-byte-span.h" - -#include -#include -#include - -namespace chip { -namespace app { -namespace List { - -// The first 2 bytes of a OCTET_STRING/CHAR_STRING field specifies the length in little-endian. -constexpr uint16_t kByteSpanSizeLengthInBytes = 2; - -static CHIP_ERROR ReadByteSpanSize(const uint8_t * buffer, uint16_t bufferLen, uint16_t * size) -{ - ReturnErrorCodeIf(bufferLen < kByteSpanSizeLengthInBytes, CHIP_ERROR_INVALID_ARGUMENT); - - chip::Encoding::LittleEndian::Reader reader(buffer, kByteSpanSizeLengthInBytes); - ReturnErrorOnFailure(reader.Read16(size).StatusCode()); - return CHIP_NO_ERROR; -} - -static CHIP_ERROR WriteByteSpanSize(uint8_t * buffer, uint16_t bufferLen, uint16_t size) -{ - ReturnErrorCodeIf(bufferLen < kByteSpanSizeLengthInBytes, CHIP_ERROR_BUFFER_TOO_SMALL); - - chip::Encoding::LittleEndian::BufferWriter writer(buffer, kByteSpanSizeLengthInBytes); - ReturnErrorCodeIf(!writer.Put16(size).Fit(), CHIP_ERROR_BUFFER_TOO_SMALL); - return CHIP_NO_ERROR; -} - -CHIP_ERROR ReadByteSpan(const uint8_t * buffer, uint16_t bufferLen, chip::ByteSpan * span) -{ - uint16_t size = 0; - ReturnErrorOnFailure(ReadByteSpanSize(buffer, bufferLen, &size)); - - ReturnErrorCodeIf(size > bufferLen - kByteSpanSizeLengthInBytes, CHIP_ERROR_BUFFER_TOO_SMALL); - *span = chip::ByteSpan(buffer + kByteSpanSizeLengthInBytes, size); - - return CHIP_NO_ERROR; -} - -CHIP_ERROR WriteByteSpan(uint8_t * buffer, uint16_t bufferLen, chip::ByteSpan * span) -{ - uint16_t size = static_cast(span->size()); - ReturnErrorOnFailure(WriteByteSpanSize(buffer, bufferLen, size)); - - ReturnErrorCodeIf(size > bufferLen - kByteSpanSizeLengthInBytes, CHIP_ERROR_BUFFER_TOO_SMALL); - memmove(buffer + kByteSpanSizeLengthInBytes, span->data(), size); - - return CHIP_NO_ERROR; -} - -uint16_t GetByteSpanOffsetFromIndex(const uint8_t * buffer, uint16_t bufferLen, uint16_t index) -{ - chip::Encoding::LittleEndian::Reader reader(buffer, bufferLen); - - uint16_t entryCount = 0; - ReturnErrorCodeIf(CHIP_NO_ERROR != reader.Read16(&entryCount).StatusCode(), 0); - - for (uint16_t i = 0; i < index; i++) - { - uint16_t entrySize = 0; - ReturnErrorCodeIf(CHIP_NO_ERROR != reader.Read16(&entrySize).StatusCode(), 0); - ReturnErrorCodeIf(!reader.HasAtLeast(entrySize), 0); - reader.Skip(entrySize); - } - - return static_cast(reader.OctetsRead()); -} - -} // namespace List -} // namespace app -} // namespace chip diff --git a/src/app/util/attribute-list-byte-span.h b/src/app/util/attribute-list-byte-span.h deleted file mode 100644 index e6ea90f4294fa5..00000000000000 --- a/src/app/util/attribute-list-byte-span.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include - -namespace chip { -namespace app { -namespace List { - -/** - * @brief Deserialize a bytespan from buffer - * - * @param [in] buffer A buffer containing serialized ByteSpan - * @param [in] bufferLen The buffer size - * @param [in] span The deserialized bytespan - * - */ -CHIP_ERROR ReadByteSpan(const uint8_t * buffer, uint16_t bufferLen, chip::ByteSpan * span); - -/** - * @brief Serialize a bytespan to buffer - * - * @param [in] buffer A buffer containing serialized ByteSpan - * @param [in] bufferLen The buffer size - * @param [in] span The bytespan to serialize - * - */ -CHIP_ERROR WriteByteSpan(uint8_t * buffer, uint16_t bufferLen, chip::ByteSpan * span); - -/** - * @brief Returns the byte offset of a serialized bytespan into a buffer of serialized bytespans. - * - * @param [in] buffer A buffer containing serialized ByteSpan - * @param [in] bufferLen The buffer size - * @param [in] index The index of the serialized ByteSpan to retrieve - * - * @return offset on success. This value can be added to buffer to obtain a useful first argument to ReadByteSpan/WriteByteSpan - * 0 on error or if the serialized bytespan is not found - */ -uint16_t GetByteSpanOffsetFromIndex(const uint8_t * buffer, uint16_t bufferLen, uint16_t index); - -} // namespace List -} // namespace app -} // namespace chip diff --git a/src/app/util/attribute-size-util.cpp b/src/app/util/attribute-size-util.cpp index f5757f4e25c3a5..c5b7f467598b11 100644 --- a/src/app/util/attribute-size-util.cpp +++ b/src/app/util/attribute-size-util.cpp @@ -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 { diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 3243333a58b214..235d4f52b92ebc 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -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 @@ -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 { @@ -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; @@ -598,19 +594,19 @@ EmberAfStatus emAfReadOrWriteAttribute(EmberAfAttributeSearchRecord * attRecord, // Is the attribute externally stored? if (am->mask & ATTRIBUTE_MASK_EXTERNAL_STORAGE) { - return (write ? emberAfExternalAttributeWriteCallback(attRecord->endpoint, attRecord->clusterId, - am, EMBER_AF_NULL_MANUFACTURER_CODE, - buffer, index) - : emberAfExternalAttributeReadCallback(attRecord->endpoint, attRecord->clusterId, - am, EMBER_AF_NULL_MANUFACTURER_CODE, - buffer, emberAfAttributeSize(am), index)); + return (write + ? emberAfExternalAttributeWriteCallback(attRecord->endpoint, attRecord->clusterId, + am, EMBER_AF_NULL_MANUFACTURER_CODE, buffer) + : emberAfExternalAttributeReadCallback(attRecord->endpoint, attRecord->clusterId, + am, EMBER_AF_NULL_MANUFACTURER_CODE, 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 { diff --git a/src/app/util/attribute-storage.h b/src/app/util/attribute-storage.h index eb0fe406c0a8a1..ca2c4fbf21fdd6 100644 --- a/src/app/util/attribute-storage.h +++ b/src/app/util/attribute-storage.h @@ -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); diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index cf196ddf61748c..333df9d0f79fca 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -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; } diff --git a/src/app/util/im-client-callbacks.cpp b/src/app/util/im-client-callbacks.cpp index 1a471d6784f2a0..7b523ea4354fb2 100644 --- a/src/app/util/im-client-callbacks.cpp +++ b/src/app/util/im-client-callbacks.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -32,7 +31,6 @@ #include using namespace ::chip; -using namespace ::chip::app::List; void LogStatus(uint8_t status) { diff --git a/src/app/zap-templates/app-templates.json b/src/app/zap-templates/app-templates.json index c2520049e329dd..eee83bf5ab9ef7 100644 --- a/src/app/zap-templates/app-templates.json +++ b/src/app/zap-templates/app-templates.json @@ -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", diff --git a/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt b/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt index 8469aa4b130c01..19f059ea290694 100644 --- a/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt +++ b/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -19,7 +18,6 @@ using namespace ::chip; using namespace ::chip::app::DataModel; -using namespace ::chip::app::List; namespace { [[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; diff --git a/src/app/zap-templates/templates/app/attribute-size-src.zapt b/src/app/zap-templates/templates/app/attribute-size-src.zapt deleted file mode 100644 index d72e66d18e022d..00000000000000 --- a/src/app/zap-templates/templates/app/attribute-size-src.zapt +++ /dev/null @@ -1,195 +0,0 @@ -{{> header}} - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - {{#chip_server_clusters}} - {{#if (chip_server_has_list_attributes)}} - case {{asHex code 4}}: // {{name}} Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - {{#chip_server_cluster_attributes}} - {{#if isList}} - case {{asHex code 4}}: // {{name}} - { - {{#unless (isString type)}} - entryLength = {{size}}; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - {{/unless}} - {{#if isStruct}} - // Struct {{chipType}} - {{chipType}} * entry = reinterpret_cast<{{chipType}} *>(write ? src : dest); - {{#chip_attribute_list_entryTypes}} - {{#if (isString type)}} - {{#if (isOctetString type)}} - ByteSpan * {{name}}Span = &entry->{{name}}; // {{type}} - {{else}} - ByteSpan {{name}}SpanStorage(Uint8::from_const_char(entry->{{name}}.data()), entry->{{name}}.size()); // {{type}} - ByteSpan * {{name}}Span = &{{name}}SpanStorage; - {{/if}} - if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, {{size}}, {{name}}Span) : ReadByteSpan(src + entryOffset, {{size}}, {{name}}Span))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + {{size}}); - {{else}} - copyListMember(write ? dest : (uint8_t *)&entry->{{name}}, write ? (uint8_t *)&entry->{{name}} : src, write, &entryOffset, sizeof(entry->{{name}})); // {{type}} - {{/if}} - {{/chip_attribute_list_entryTypes}} - {{else}} - {{#if (isString type)}} - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * {{asLowerCamelCase name}}Span = reinterpret_cast(write ? src : dest); // {{type}} - uint16_t {{asLowerCamelCase name}}RemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, {{asLowerCamelCase name}}RemainingSpace, {{asLowerCamelCase name}}Span) : ReadByteSpan(src + entryOffset, {{asLowerCamelCase name}}RemainingSpace, {{asLowerCamelCase name}}Span))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo({{asLowerCamelCase name}}Span->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", {{asLowerCamelCase name}}Span->size()); - return 0; - } - entryLength = static_cast({{asLowerCamelCase name}}Span->size()); - {{else}} - copyListMember(dest, src, write, &entryOffset, entryLength); // {{type}} - {{/if}} - {{/if}} - break; - } - {{/if}} - {{/chip_server_cluster_attributes}} - } - break; - } -{{/if}} -{{/chip_server_clusters}} - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { -{{#chip_server_clusters}} -{{#if (chip_server_has_list_attributes)}} - case {{asHex code 4}}: // {{name}} Cluster - switch (attributeId) - { - {{#chip_server_cluster_attributes}} - {{#if isList}} - case {{asHex code 4}}: // {{name}} - {{#if isStruct}} - // Struct {{chipType}} - {{else}} - // {{chipType}} - {{/if}} - {{#if (isString type)}} - return GetByteSpanOffsetFromIndex(buffer, {{size}}, entryCount); - {{else}} - entryLength = {{size}}; - {{/if}} - break; - {{/if}} - {{/chip_server_cluster_attributes}} - } - break; -{{/if}} -{{/chip_server_clusters}} - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/src/app/zap-templates/templates/app/callback-stub-src.zapt b/src/app/zap-templates/templates/app/callback-stub-src.zapt index 44ecfd9e4a89a8..a3b874658246c6 100644 --- a/src/app/zap-templates/templates/app/callback-stub-src.zapt +++ b/src/app/zap-templates/templates/app/callback-stub-src.zapt @@ -84,7 +84,7 @@ bool __attribute__((weak)) emberAfMessageSentCallback( EmberAfStatus __attribute__((weak)) 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) { return EMBER_ZCL_STATUS_FAILURE; } @@ -92,7 +92,7 @@ EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback( EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback( EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode, - uint8_t * buffer, int32_t index) + uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/src/app/zap-templates/templates/app/callback.zapt b/src/app/zap-templates/templates/app/callback.zapt index 41b172b1576740..4f9e0a2ca71614 100644 --- a/src/app/zap-templates/templates/app/callback.zapt +++ b/src/app/zap-templates/templates/app/callback.zapt @@ -311,7 +311,7 @@ bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination */ EmberAfStatus emberAfExternalAttributeReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode, - uint8_t * buffer, uint16_t maxReadLength, int32_t index = -1); + uint8_t * buffer, uint16_t maxReadLength); /** @brief External Attribute Write * @@ -355,7 +355,7 @@ EmberAfStatus emberAfExternalAttributeReadCallback(chip::EndpointId endpoint, ch */ EmberAfStatus emberAfExternalAttributeWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode, - uint8_t * buffer, int32_t index = -1); + uint8_t * buffer); /** @brief Get Current Time * diff --git a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj index fbbb9bc489ab21..68f9694548bdd3 100644 --- a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj @@ -12,11 +12,9 @@ 1E857306265519720050A4D9 /* CHIPClientCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E857305265519720050A4D9 /* CHIPClientCallbacks.cpp */; }; 1E85730C265519AE0050A4D9 /* callback-stub.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E857307265519AE0050A4D9 /* callback-stub.cpp */; }; 1E85730E265519AE0050A4D9 /* CHIPClusters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E857309265519AE0050A4D9 /* CHIPClusters.cpp */; }; - 1E85730F265519AE0050A4D9 /* attribute-size.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85730A265519AE0050A4D9 /* attribute-size.cpp */; }; 1E857310265519AE0050A4D9 /* IMClusterCommandHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85730B265519AE0050A4D9 /* IMClusterCommandHandler.cpp */; }; 1E85732226551A490050A4D9 /* binding-table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731226551A490050A4D9 /* binding-table.cpp */; }; 1E85732326551A490050A4D9 /* process-global-message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731326551A490050A4D9 /* process-global-message.cpp */; }; - 1E85732426551A490050A4D9 /* attribute-list-byte-span.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731426551A490050A4D9 /* attribute-list-byte-span.cpp */; }; 1E85732526551A490050A4D9 /* message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731526551A490050A4D9 /* message.cpp */; }; 1E85732626551A490050A4D9 /* attribute-storage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731626551A490050A4D9 /* attribute-storage.cpp */; }; 1E85732726551A490050A4D9 /* client-api.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731726551A490050A4D9 /* client-api.cpp */; }; @@ -103,11 +101,9 @@ 1E857305265519720050A4D9 /* CHIPClientCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CHIPClientCallbacks.cpp; path = "../../../../zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp"; sourceTree = ""; }; 1E857307265519AE0050A4D9 /* callback-stub.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "callback-stub.cpp"; path = "../../../../zzz_generated/controller-clusters/zap-generated/callback-stub.cpp"; sourceTree = ""; }; 1E857309265519AE0050A4D9 /* CHIPClusters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CHIPClusters.cpp; path = "../../../../zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp"; sourceTree = ""; }; - 1E85730A265519AE0050A4D9 /* attribute-size.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "attribute-size.cpp"; path = "../../../../zzz_generated/controller-clusters/zap-generated/attribute-size.cpp"; sourceTree = ""; }; 1E85730B265519AE0050A4D9 /* IMClusterCommandHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IMClusterCommandHandler.cpp; path = "../../../../zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp"; sourceTree = ""; }; 1E85731226551A490050A4D9 /* binding-table.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "binding-table.cpp"; path = "../../../app/util/binding-table.cpp"; sourceTree = ""; }; 1E85731326551A490050A4D9 /* process-global-message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "process-global-message.cpp"; path = "../../../app/util/process-global-message.cpp"; sourceTree = ""; }; - 1E85731426551A490050A4D9 /* attribute-list-byte-span.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "attribute-list-byte-span.cpp"; path = "../../../app/util/attribute-list-byte-span.cpp"; sourceTree = ""; }; 1E85731526551A490050A4D9 /* message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = message.cpp; path = ../../../app/util/message.cpp; sourceTree = ""; }; 1E85731626551A490050A4D9 /* attribute-storage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "attribute-storage.cpp"; path = "../../../app/util/attribute-storage.cpp"; sourceTree = ""; }; 1E85731726551A490050A4D9 /* client-api.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "client-api.cpp"; path = "../../../app/util/client-api.cpp"; sourceTree = ""; }; @@ -210,7 +206,6 @@ 2FD775542695557E00FF4B12 /* error-mapping.cpp */, 1E85731926551A490050A4D9 /* af-event.cpp */, 1E85731B26551A490050A4D9 /* af-main-common.cpp */, - 1E85731426551A490050A4D9 /* attribute-list-byte-span.cpp */, 1E85731F26551A490050A4D9 /* attribute-size-util.cpp */, 1E85731626551A490050A4D9 /* attribute-storage.cpp */, 1E85731826551A490050A4D9 /* attribute-table.cpp */, @@ -239,7 +234,6 @@ 1E16A8F926B9835600683C53 /* CHIPTestClustersObjc.h */, 1E16A8FA26B9835700683C53 /* CHIPTestClustersObjc.mm */, 1ED276DF26C57CF000547A89 /* CHIPCallbackBridge.mm */, - 1E85730A265519AE0050A4D9 /* attribute-size.cpp */, 1E857307265519AE0050A4D9 /* callback-stub.cpp */, 1E857309265519AE0050A4D9 /* CHIPClusters.cpp */, 1E85730B265519AE0050A4D9 /* IMClusterCommandHandler.cpp */, @@ -499,7 +493,6 @@ 2C8C8FC2253E0C2100797F05 /* CHIPPersistentStorageDelegateBridge.mm in Sources */, 2CB7163C252E8A7C0026E2BB /* CHIPDevicePairingDelegateBridge.mm in Sources */, 997DED162695343400975E97 /* CHIPThreadOperationalDataset.mm in Sources */, - 1E85732426551A490050A4D9 /* attribute-list-byte-span.cpp in Sources */, 998F287126D56940001846C6 /* CHIPP256KeypairBridge.mm in Sources */, 1E85730E265519AE0050A4D9 /* CHIPClusters.cpp in Sources */, 1E16A90226B98AB700683C53 /* CHIPTestClustersObjc.mm in Sources */, @@ -538,7 +531,6 @@ 1E85732626551A490050A4D9 /* attribute-storage.cpp in Sources */, 1E85732C26551A490050A4D9 /* DataModelHandler.cpp in Sources */, 1E85733126551A490050A4D9 /* chip-message-send.cpp in Sources */, - 1E85730F265519AE0050A4D9 /* attribute-size.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp index daeade20704895..8aa5b5c517f332 100644 --- a/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/all-clusters-app/zap-generated/CHIPClientCallbacks.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ using namespace ::chip; using namespace ::chip::app::DataModel; -using namespace ::chip::app::List; namespace { [[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; diff --git a/zzz_generated/all-clusters-app/zap-generated/attribute-size.cpp b/zzz_generated/all-clusters-app/zap-generated/attribute-size.cpp deleted file mode 100644 index 8d16c148122f11..00000000000000 --- a/zzz_generated/all-clusters-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,1497 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001F: // Access Control Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ACL - { - entryLength = 21; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _AccessControlEntry - _AccessControlEntry * entry = reinterpret_cast<_AccessControlEntry *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // fabric_idx - copyListMember(write ? dest : (uint8_t *) &entry->Privilege, write ? (uint8_t *) &entry->Privilege : src, write, - &entryOffset, sizeof(entry->Privilege)); // Privilege - copyListMember(write ? dest : (uint8_t *) &entry->AuthMode, write ? (uint8_t *) &entry->AuthMode : src, write, - &entryOffset, sizeof(entry->AuthMode)); // AuthMode - copyListMember(write ? dest : (uint8_t *) &entry->Subjects, write ? (uint8_t *) &entry->Subjects : src, write, - &entryOffset, sizeof(entry->Subjects)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Targets, write ? (uint8_t *) &entry->Targets : src, write, - &entryOffset, sizeof(entry->Targets)); // Target - break; - } - case 0x0001: // Extension - { - entryLength = 257; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ExtensionEntry - _ExtensionEntry * entry = reinterpret_cast<_ExtensionEntry *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // fabric_idx - ByteSpan * DataSpan = &entry->Data; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 256, DataSpan) : ReadByteSpan(src + entryOffset, 256, DataSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 256); - break; - } - } - break; - } - case 0x050C: // Application Launcher Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // application launcher list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // INT16U - break; - } - } - break; - } - case 0x050B: // Audio Output Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // audio output list - { - entryLength = 36; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _AudioOutputInfo - _AudioOutputInfo * entry = reinterpret_cast<_AudioOutputInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->index, write ? (uint8_t *) &entry->index : src, write, &entryOffset, - sizeof(entry->index)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->outputType, write ? (uint8_t *) &entry->outputType : src, write, - &entryOffset, sizeof(entry->outputType)); // AudioOutputType - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x0025: // Bridged Actions Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // action list - { - entryLength = 42; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ActionStruct - _ActionStruct * entry = reinterpret_cast<_ActionStruct *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActionID, write ? (uint8_t *) &entry->ActionID : src, write, - &entryOffset, sizeof(entry->ActionID)); // INT16U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // ActionTypeEnum - copyListMember(write ? dest : (uint8_t *) &entry->EndpointListID, write ? (uint8_t *) &entry->EndpointListID : src, - write, &entryOffset, sizeof(entry->EndpointListID)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->SupportedCommands, - write ? (uint8_t *) &entry->SupportedCommands : src, write, &entryOffset, - sizeof(entry->SupportedCommands)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Status, write ? (uint8_t *) &entry->Status : src, write, &entryOffset, - sizeof(entry->Status)); // ActionStatusEnum - break; - } - case 0x0001: // endpoint list - { - entryLength = 39; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _EndpointListStruct - _EndpointListStruct * entry = reinterpret_cast<_EndpointListStruct *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->EndpointListID, write ? (uint8_t *) &entry->EndpointListID : src, - write, &entryOffset, sizeof(entry->EndpointListID)); // INT16U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // EndpointListTypeEnum - copyListMember(write ? dest : (uint8_t *) &entry->Endpoints, write ? (uint8_t *) &entry->Endpoints : src, write, - &entryOffset, sizeof(entry->Endpoints)); // ENDPOINT_NO - break; - } - } - break; - } - case 0x050A: // Content Launcher Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // accepts header list - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * acceptsHeaderListSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t acceptsHeaderListRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, acceptsHeaderListRemainingSpace, acceptsHeaderListSpan) - : ReadByteSpan(src + entryOffset, acceptsHeaderListRemainingSpace, acceptsHeaderListSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(acceptsHeaderListSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", acceptsHeaderListSpan->size()); - return 0; - } - entryLength = static_cast(acceptsHeaderListSpan->size()); - break; - } - case 0x0001: // supported streaming types - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ContentLaunchStreamingType - break; - } - } - break; - } - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0040: // Fixed Label Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // label list - { - entryLength = 36; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _LabelStruct - _LabelStruct * entry = reinterpret_cast<_LabelStruct *>(write ? src : dest); - ByteSpan labelSpanStorage(Uint8::from_const_char(entry->label.data()), entry->label.size()); // CHAR_STRING - ByteSpan * labelSpan = &labelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 18, labelSpan) : ReadByteSpan(src + entryOffset, 18, labelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 18); - ByteSpan valueSpanStorage(Uint8::from_const_char(entry->value.data()), entry->value.size()); // CHAR_STRING - ByteSpan * valueSpan = &valueSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 18, valueSpan) : ReadByteSpan(src + entryOffset, 18, valueSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 18); - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003F: // Group Key Management Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // groups - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _GroupState - _GroupState * entry = reinterpret_cast<_GroupState *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->VendorGroupId, write ? (uint8_t *) &entry->VendorGroupId : src, write, - &entryOffset, sizeof(entry->VendorGroupId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeySetIndex, write ? (uint8_t *) &entry->GroupKeySetIndex : src, - write, &entryOffset, sizeof(entry->GroupKeySetIndex)); // INT16U - break; - } - case 0x0001: // group keys - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _GroupKey - _GroupKey * entry = reinterpret_cast<_GroupKey *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyIndex, write ? (uint8_t *) &entry->GroupKeyIndex : src, write, - &entryOffset, sizeof(entry->GroupKeyIndex)); // INT16U - ByteSpan * GroupKeyRootSpan = &entry->GroupKeyRoot; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 18, GroupKeyRootSpan) - : ReadByteSpan(src + entryOffset, 18, GroupKeyRootSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 18); - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyEpochStartTime, - write ? (uint8_t *) &entry->GroupKeyEpochStartTime : src, write, &entryOffset, - sizeof(entry->GroupKeyEpochStartTime)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeySecurityPolicy, - write ? (uint8_t *) &entry->GroupKeySecurityPolicy : src, write, &entryOffset, - sizeof(entry->GroupKeySecurityPolicy)); // GroupKeySecurityPolicy - break; - } - } - break; - } - case 0x0507: // Media Input Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // media input list - { - entryLength = 70; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _MediaInputInfo - _MediaInputInfo * entry = reinterpret_cast<_MediaInputInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->index, write ? (uint8_t *) &entry->index : src, write, &entryOffset, - sizeof(entry->index)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->inputType, write ? (uint8_t *) &entry->inputType : src, write, - &entryOffset, sizeof(entry->inputType)); // MediaInputType - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - ByteSpan descriptionSpanStorage(Uint8::from_const_char(entry->description.data()), - entry->description.size()); // CHAR_STRING - ByteSpan * descriptionSpan = &descriptionSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, descriptionSpan) - : ReadByteSpan(src + entryOffset, 34, descriptionSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x0050: // Mode Select Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // SupportedModes - { - entryLength = 39; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ModeOptionStruct - _ModeOptionStruct * entry = reinterpret_cast<_ModeOptionStruct *>(write ? src : dest); - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->Mode, write ? (uint8_t *) &entry->Mode : src, write, &entryOffset, - sizeof(entry->Mode)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->SemanticTag, write ? (uint8_t *) &entry->SemanticTag : src, write, - &entryOffset, sizeof(entry->SemanticTag)); // INT32U - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - case 0x002F: // Power Source Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0012: // ActiveBatteryFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x002E: // Power Source Configuration Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // Sources - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // INT8U - break; - } - } - break; - } - case 0x0034: // Software Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ThreadMetrics - { - entryLength = 30; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ThreadMetrics - _ThreadMetrics * entry = reinterpret_cast<_ThreadMetrics *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->Id, write ? (uint8_t *) &entry->Id : src, write, &entryOffset, - sizeof(entry->Id)); // INT64U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, NameSpan) : ReadByteSpan(src + entryOffset, 10, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeCurrent, write ? (uint8_t *) &entry->StackFreeCurrent : src, - write, &entryOffset, sizeof(entry->StackFreeCurrent)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeMinimum, write ? (uint8_t *) &entry->StackFreeMinimum : src, - write, &entryOffset, sizeof(entry->StackFreeMinimum)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackSize, write ? (uint8_t *) &entry->StackSize : src, write, - &entryOffset, sizeof(entry->StackSize)); // INT32U - break; - } - } - break; - } - case 0x0504: // TV Channel Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // tv channel list - { - entryLength = 106; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _TvChannelInfo - _TvChannelInfo * entry = reinterpret_cast<_TvChannelInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->majorNumber, write ? (uint8_t *) &entry->majorNumber : src, write, - &entryOffset, sizeof(entry->majorNumber)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->minorNumber, write ? (uint8_t *) &entry->minorNumber : src, write, - &entryOffset, sizeof(entry->minorNumber)); // INT16U - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - ByteSpan callSignSpanStorage(Uint8::from_const_char(entry->callSign.data()), entry->callSign.size()); // CHAR_STRING - ByteSpan * callSignSpan = &callSignSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, callSignSpan) : ReadByteSpan(src + entryOffset, 34, callSignSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - ByteSpan affiliateCallSignSpanStorage(Uint8::from_const_char(entry->affiliateCallSign.data()), - entry->affiliateCallSign.size()); // CHAR_STRING - ByteSpan * affiliateCallSignSpan = &affiliateCallSignSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, affiliateCallSignSpan) - : ReadByteSpan(src + entryOffset, 34, affiliateCallSignSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x0505: // Target Navigator Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // target navigator list - { - entryLength = 35; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NavigateTargetTargetInfo - _NavigateTargetTargetInfo * entry = reinterpret_cast<_NavigateTargetTargetInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->identifier, write ? (uint8_t *) &entry->identifier : src, write, - &entryOffset, sizeof(entry->identifier)); // INT8U - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x050F: // Test Cluster Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x001A: // list_int8u - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // INT8U - break; - } - case 0x001B: // list_octet_string - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * listOctetStringSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t listOctetStringRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, listOctetStringRemainingSpace, listOctetStringSpan) - : ReadByteSpan(src + entryOffset, listOctetStringRemainingSpace, listOctetStringSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(listOctetStringSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", listOctetStringSpan->size()); - return 0; - } - entryLength = static_cast(listOctetStringSpan->size()); - break; - } - case 0x001C: // list_struct_octet_string - { - entryLength = 42; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _TestListStructOctet - _TestListStructOctet * entry = reinterpret_cast<_TestListStructOctet *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->fabricIndex, write ? (uint8_t *) &entry->fabricIndex : src, write, - &entryOffset, sizeof(entry->fabricIndex)); // INT64U - ByteSpan * operationalCertSpan = &entry->operationalCert; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, operationalCertSpan) - : ReadByteSpan(src + entryOffset, 34, operationalCertSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0023: // list_nullables_and_optionals_struct - { - entryLength = 75; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NullablesAndOptionalsStruct - _NullablesAndOptionalsStruct * entry = reinterpret_cast<_NullablesAndOptionalsStruct *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->NullableInt, write ? (uint8_t *) &entry->NullableInt : src, write, - &entryOffset, sizeof(entry->NullableInt)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->OptionalInt, write ? (uint8_t *) &entry->OptionalInt : src, write, - &entryOffset, sizeof(entry->OptionalInt)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->NullableOptionalInt, - write ? (uint8_t *) &entry->NullableOptionalInt : src, write, &entryOffset, - sizeof(entry->NullableOptionalInt)); // INT16U - ByteSpan NullableStringSpanStorage(Uint8::from_const_char(entry->NullableString.data()), - entry->NullableString.size()); // CHAR_STRING - ByteSpan * NullableStringSpan = &NullableStringSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 2, NullableStringSpan) - : ReadByteSpan(src + entryOffset, 2, NullableStringSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 2); - ByteSpan OptionalStringSpanStorage(Uint8::from_const_char(entry->OptionalString.data()), - entry->OptionalString.size()); // CHAR_STRING - ByteSpan * OptionalStringSpan = &OptionalStringSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 2, OptionalStringSpan) - : ReadByteSpan(src + entryOffset, 2, OptionalStringSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 2); - ByteSpan NullableOptionalStringSpanStorage(Uint8::from_const_char(entry->NullableOptionalString.data()), - entry->NullableOptionalString.size()); // CHAR_STRING - ByteSpan * NullableOptionalStringSpan = &NullableOptionalStringSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 2, NullableOptionalStringSpan) - : ReadByteSpan(src + entryOffset, 2, NullableOptionalStringSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 2); - copyListMember(write ? dest : (uint8_t *) &entry->NullableStruct, write ? (uint8_t *) &entry->NullableStruct : src, - write, &entryOffset, sizeof(entry->NullableStruct)); // SimpleStruct - copyListMember(write ? dest : (uint8_t *) &entry->OptionalStruct, write ? (uint8_t *) &entry->OptionalStruct : src, - write, &entryOffset, sizeof(entry->OptionalStruct)); // SimpleStruct - copyListMember(write ? dest : (uint8_t *) &entry->NullableOptionalStruct, - write ? (uint8_t *) &entry->NullableOptionalStruct : src, write, &entryOffset, - sizeof(entry->NullableOptionalStruct)); // SimpleStruct - copyListMember(write ? dest : (uint8_t *) &entry->NullableList, write ? (uint8_t *) &entry->NullableList : src, write, - &entryOffset, sizeof(entry->NullableList)); // SimpleEnum - copyListMember(write ? dest : (uint8_t *) &entry->OptionalList, write ? (uint8_t *) &entry->OptionalList : src, write, - &entryOffset, sizeof(entry->OptionalList)); // SimpleEnum - copyListMember(write ? dest : (uint8_t *) &entry->NullableOptionalList, - write ? (uint8_t *) &entry->NullableOptionalList : src, write, &entryOffset, - sizeof(entry->NullableOptionalList)); // SimpleEnum - break; - } - case 0x002A: // list_long_octet_string - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * listLongOctetStringSpan = reinterpret_cast(write ? src : dest); // LONG_OCTET_STRING - uint16_t listLongOctetStringRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, listLongOctetStringRemainingSpace, listLongOctetStringSpan) - : ReadByteSpan(src + entryOffset, listLongOctetStringRemainingSpace, listLongOctetStringSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(listLongOctetStringSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", listLongOctetStringSpan->size()); - return 0; - } - entryLength = static_cast(listLongOctetStringSpan->size()); - break; - } - } - break; - } - case 0x0035: // Thread Network Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0007: // NeighborTableList - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NeighborTable - _NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src, - write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src, - write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset, - sizeof(entry->LQI)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write, - &entryOffset, sizeof(entry->AverageRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write, - &entryOffset, sizeof(entry->LastRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src, - write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src, - write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write, - &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src, - write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src, - write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write, - &entryOffset, sizeof(entry->IsChild)); // BOOLEAN - break; - } - case 0x0008: // RouteTableList - { - entryLength = 18; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _RouteTable - _RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write, - &entryOffset, sizeof(entry->RouterId)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write, - &entryOffset, sizeof(entry->NextHop)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write, - &entryOffset, sizeof(entry->PathCost)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset, - sizeof(entry->LQIIn)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset, - sizeof(entry->LQIOut)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write, - &entryOffset, sizeof(entry->Allocated)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src, - write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN - break; - } - case 0x003B: // SecurityPolicy - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _SecurityPolicy - _SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write, - &entryOffset, sizeof(entry->RotationTime)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset, - sizeof(entry->Flags)); // BITMAP16 - break; - } - case 0x003D: // OperationalDatasetComponents - { - entryLength = 12; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _OperationalDatasetComponents - _OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent, - write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset, - sizeof(entry->ActiveTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent, - write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset, - sizeof(entry->PendingTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src, - write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent, - write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset, - sizeof(entry->NetworkNamePresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent, - write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset, - sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent, - write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset, - sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write, - &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write, - &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src, - write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write, - &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent, - write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset, - sizeof(entry->SecurityPolicyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent, - write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset, - sizeof(entry->ChannelMaskPresent)); // BOOLEAN - break; - } - case 0x003E: // ActiveNetworkFaultsList - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001F: // Access Control Cluster - switch (attributeId) - { - case 0x0000: // ACL - // Struct _AccessControlEntry - entryLength = 21; - break; - case 0x0001: // Extension - // Struct _ExtensionEntry - entryLength = 257; - break; - } - break; - case 0x050C: // Application Launcher Cluster - switch (attributeId) - { - case 0x0000: // application launcher list - // uint16_t - entryLength = 2; - break; - } - break; - case 0x050B: // Audio Output Cluster - switch (attributeId) - { - case 0x0000: // audio output list - // Struct _AudioOutputInfo - entryLength = 36; - break; - } - break; - case 0x0025: // Bridged Actions Cluster - switch (attributeId) - { - case 0x0000: // action list - // Struct _ActionStruct - entryLength = 42; - break; - case 0x0001: // endpoint list - // Struct _EndpointListStruct - entryLength = 39; - break; - } - break; - case 0x050A: // Content Launcher Cluster - switch (attributeId) - { - case 0x0000: // accepts header list - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 256, entryCount); - break; - case 0x0001: // supported streaming types - // uint8_t - entryLength = 1; - break; - } - break; - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0040: // Fixed Label Cluster - switch (attributeId) - { - case 0x0000: // label list - // Struct _LabelStruct - entryLength = 36; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003F: // Group Key Management Cluster - switch (attributeId) - { - case 0x0000: // groups - // Struct _GroupState - entryLength = 6; - break; - case 0x0001: // group keys - // Struct _GroupKey - entryLength = 31; - break; - } - break; - case 0x0507: // Media Input Cluster - switch (attributeId) - { - case 0x0000: // media input list - // Struct _MediaInputInfo - entryLength = 70; - break; - } - break; - case 0x0050: // Mode Select Cluster - switch (attributeId) - { - case 0x0001: // SupportedModes - // Struct _ModeOptionStruct - entryLength = 39; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - case 0x002F: // Power Source Cluster - switch (attributeId) - { - case 0x0012: // ActiveBatteryFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x002E: // Power Source Configuration Cluster - switch (attributeId) - { - case 0x0000: // Sources - // uint8_t - entryLength = 1; - break; - } - break; - case 0x0034: // Software Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // ThreadMetrics - // Struct _ThreadMetrics - entryLength = 30; - break; - } - break; - case 0x0504: // TV Channel Cluster - switch (attributeId) - { - case 0x0000: // tv channel list - // Struct _TvChannelInfo - entryLength = 106; - break; - } - break; - case 0x0505: // Target Navigator Cluster - switch (attributeId) - { - case 0x0000: // target navigator list - // Struct _NavigateTargetTargetInfo - entryLength = 35; - break; - } - break; - case 0x050F: // Test Cluster Cluster - switch (attributeId) - { - case 0x001A: // list_int8u - // uint8_t - entryLength = 1; - break; - case 0x001B: // list_octet_string - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 256, entryCount); - break; - case 0x001C: // list_struct_octet_string - // Struct _TestListStructOctet - entryLength = 42; - break; - case 0x0023: // list_nullables_and_optionals_struct - // Struct _NullablesAndOptionalsStruct - entryLength = 75; - break; - case 0x002A: // list_long_octet_string - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 1002, entryCount); - break; - } - break; - case 0x0035: // Thread Network Diagnostics Cluster - switch (attributeId) - { - case 0x0007: // NeighborTableList - // Struct _NeighborTable - entryLength = 31; - break; - case 0x0008: // RouteTableList - // Struct _RouteTable - entryLength = 18; - break; - case 0x003B: // SecurityPolicy - // Struct _SecurityPolicy - entryLength = 4; - break; - case 0x003D: // OperationalDatasetComponents - // Struct _OperationalDatasetComponents - entryLength = 12; - break; - case 0x003E: // ActiveNetworkFaultsList - // uint8_t - entryLength = 1; - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/all-clusters-app/zap-generated/callback-stub.cpp b/zzz_generated/all-clusters-app/zap-generated/callback-stub.cpp index 4876296c80e626..f55af8bd0a555d 100644 --- a/zzz_generated/all-clusters-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/all-clusters-app/zap-generated/callback-stub.cpp @@ -561,14 +561,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/app-common/app-common/zap-generated/callback.h b/zzz_generated/app-common/app-common/zap-generated/callback.h index b31e893698cac2..c401c082c30786 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -15545,7 +15545,7 @@ bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination */ EmberAfStatus emberAfExternalAttributeReadCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode, - uint8_t * buffer, uint16_t maxReadLength, int32_t index = -1); + uint8_t * buffer, uint16_t maxReadLength); /** @brief External Attribute Write * @@ -15589,7 +15589,7 @@ EmberAfStatus emberAfExternalAttributeReadCallback(chip::EndpointId endpoint, ch */ EmberAfStatus emberAfExternalAttributeWriteCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode, - uint8_t * buffer, int32_t index = -1); + uint8_t * buffer); /** @brief Get Current Time * diff --git a/zzz_generated/bridge-app/zap-generated/attribute-size.cpp b/zzz_generated/bridge-app/zap-generated/attribute-size.cpp deleted file mode 100644 index 4f7f43e75f07bc..00000000000000 --- a/zzz_generated/bridge-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,695 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0040: // Fixed Label Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // label list - { - entryLength = 36; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _LabelStruct - _LabelStruct * entry = reinterpret_cast<_LabelStruct *>(write ? src : dest); - ByteSpan labelSpanStorage(Uint8::from_const_char(entry->label.data()), entry->label.size()); // CHAR_STRING - ByteSpan * labelSpan = &labelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 18, labelSpan) : ReadByteSpan(src + entryOffset, 18, labelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 18); - ByteSpan valueSpanStorage(Uint8::from_const_char(entry->value.data()), entry->value.size()); // CHAR_STRING - ByteSpan * valueSpan = &valueSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 18, valueSpan) : ReadByteSpan(src + entryOffset, 18, valueSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 18); - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - case 0x0034: // Software Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ThreadMetrics - { - entryLength = 30; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ThreadMetrics - _ThreadMetrics * entry = reinterpret_cast<_ThreadMetrics *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->Id, write ? (uint8_t *) &entry->Id : src, write, &entryOffset, - sizeof(entry->Id)); // INT64U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, NameSpan) : ReadByteSpan(src + entryOffset, 10, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeCurrent, write ? (uint8_t *) &entry->StackFreeCurrent : src, - write, &entryOffset, sizeof(entry->StackFreeCurrent)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeMinimum, write ? (uint8_t *) &entry->StackFreeMinimum : src, - write, &entryOffset, sizeof(entry->StackFreeMinimum)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackSize, write ? (uint8_t *) &entry->StackSize : src, write, - &entryOffset, sizeof(entry->StackSize)); // INT32U - break; - } - } - break; - } - case 0x0035: // Thread Network Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0007: // NeighborTableList - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NeighborTable - _NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src, - write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src, - write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset, - sizeof(entry->LQI)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write, - &entryOffset, sizeof(entry->AverageRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write, - &entryOffset, sizeof(entry->LastRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src, - write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src, - write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write, - &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src, - write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src, - write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write, - &entryOffset, sizeof(entry->IsChild)); // BOOLEAN - break; - } - case 0x0008: // RouteTableList - { - entryLength = 18; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _RouteTable - _RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write, - &entryOffset, sizeof(entry->RouterId)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write, - &entryOffset, sizeof(entry->NextHop)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write, - &entryOffset, sizeof(entry->PathCost)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset, - sizeof(entry->LQIIn)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset, - sizeof(entry->LQIOut)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write, - &entryOffset, sizeof(entry->Allocated)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src, - write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN - break; - } - case 0x003B: // SecurityPolicy - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _SecurityPolicy - _SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write, - &entryOffset, sizeof(entry->RotationTime)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset, - sizeof(entry->Flags)); // BITMAP16 - break; - } - case 0x003D: // OperationalDatasetComponents - { - entryLength = 12; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _OperationalDatasetComponents - _OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent, - write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset, - sizeof(entry->ActiveTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent, - write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset, - sizeof(entry->PendingTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src, - write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent, - write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset, - sizeof(entry->NetworkNamePresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent, - write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset, - sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent, - write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset, - sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write, - &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write, - &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src, - write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write, - &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent, - write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset, - sizeof(entry->SecurityPolicyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent, - write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset, - sizeof(entry->ChannelMaskPresent)); // BOOLEAN - break; - } - case 0x003E: // ActiveNetworkFaultsList - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0040: // Fixed Label Cluster - switch (attributeId) - { - case 0x0000: // label list - // Struct _LabelStruct - entryLength = 36; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - case 0x0034: // Software Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // ThreadMetrics - // Struct _ThreadMetrics - entryLength = 30; - break; - } - break; - case 0x0035: // Thread Network Diagnostics Cluster - switch (attributeId) - { - case 0x0007: // NeighborTableList - // Struct _NeighborTable - entryLength = 31; - break; - case 0x0008: // RouteTableList - // Struct _RouteTable - entryLength = 18; - break; - case 0x003B: // SecurityPolicy - // Struct _SecurityPolicy - entryLength = 4; - break; - case 0x003D: // OperationalDatasetComponents - // Struct _OperationalDatasetComponents - entryLength = 12; - break; - case 0x003E: // ActiveNetworkFaultsList - // uint8_t - entryLength = 1; - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/bridge-app/zap-generated/callback-stub.cpp b/zzz_generated/bridge-app/zap-generated/callback-stub.cpp index b7b90f75a8f2aa..53d252fe9f3e00 100644 --- a/zzz_generated/bridge-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/bridge-app/zap-generated/callback-stub.cpp @@ -209,14 +209,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp index b8f79cc871f0ac..2c970262d5df95 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ using namespace ::chip; using namespace ::chip::app::DataModel; -using namespace ::chip::app::List; namespace { [[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; diff --git a/zzz_generated/controller-clusters/zap-generated/attribute-size.cpp b/zzz_generated/controller-clusters/zap-generated/attribute-size.cpp deleted file mode 100644 index 6d177c34b97ac7..00000000000000 --- a/zzz_generated/controller-clusters/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/controller-clusters/zap-generated/callback-stub.cpp b/zzz_generated/controller-clusters/zap-generated/callback-stub.cpp index 7f36d9c8471683..facaa03b4653cb 100644 --- a/zzz_generated/controller-clusters/zap-generated/callback-stub.cpp +++ b/zzz_generated/controller-clusters/zap-generated/callback-stub.cpp @@ -553,14 +553,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp index daeade20704895..8aa5b5c517f332 100644 --- a/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/lighting-app/zap-generated/CHIPClientCallbacks.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ using namespace ::chip; using namespace ::chip::app::DataModel; -using namespace ::chip::app::List; namespace { [[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; diff --git a/zzz_generated/lighting-app/zap-generated/attribute-size.cpp b/zzz_generated/lighting-app/zap-generated/attribute-size.cpp deleted file mode 100644 index eefc399fb4e2f3..00000000000000 --- a/zzz_generated/lighting-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,647 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - case 0x0034: // Software Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ThreadMetrics - { - entryLength = 30; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ThreadMetrics - _ThreadMetrics * entry = reinterpret_cast<_ThreadMetrics *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->Id, write ? (uint8_t *) &entry->Id : src, write, &entryOffset, - sizeof(entry->Id)); // INT64U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, NameSpan) : ReadByteSpan(src + entryOffset, 10, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeCurrent, write ? (uint8_t *) &entry->StackFreeCurrent : src, - write, &entryOffset, sizeof(entry->StackFreeCurrent)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeMinimum, write ? (uint8_t *) &entry->StackFreeMinimum : src, - write, &entryOffset, sizeof(entry->StackFreeMinimum)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackSize, write ? (uint8_t *) &entry->StackSize : src, write, - &entryOffset, sizeof(entry->StackSize)); // INT32U - break; - } - } - break; - } - case 0x0035: // Thread Network Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0007: // NeighborTableList - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NeighborTable - _NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src, - write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src, - write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset, - sizeof(entry->LQI)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write, - &entryOffset, sizeof(entry->AverageRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write, - &entryOffset, sizeof(entry->LastRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src, - write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src, - write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write, - &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src, - write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src, - write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write, - &entryOffset, sizeof(entry->IsChild)); // BOOLEAN - break; - } - case 0x0008: // RouteTableList - { - entryLength = 18; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _RouteTable - _RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write, - &entryOffset, sizeof(entry->RouterId)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write, - &entryOffset, sizeof(entry->NextHop)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write, - &entryOffset, sizeof(entry->PathCost)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset, - sizeof(entry->LQIIn)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset, - sizeof(entry->LQIOut)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write, - &entryOffset, sizeof(entry->Allocated)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src, - write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN - break; - } - case 0x003B: // SecurityPolicy - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _SecurityPolicy - _SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write, - &entryOffset, sizeof(entry->RotationTime)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset, - sizeof(entry->Flags)); // BITMAP16 - break; - } - case 0x003D: // OperationalDatasetComponents - { - entryLength = 12; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _OperationalDatasetComponents - _OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent, - write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset, - sizeof(entry->ActiveTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent, - write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset, - sizeof(entry->PendingTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src, - write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent, - write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset, - sizeof(entry->NetworkNamePresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent, - write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset, - sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent, - write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset, - sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write, - &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write, - &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src, - write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write, - &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent, - write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset, - sizeof(entry->SecurityPolicyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent, - write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset, - sizeof(entry->ChannelMaskPresent)); // BOOLEAN - break; - } - case 0x003E: // ActiveNetworkFaultsList - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - case 0x0034: // Software Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // ThreadMetrics - // Struct _ThreadMetrics - entryLength = 30; - break; - } - break; - case 0x0035: // Thread Network Diagnostics Cluster - switch (attributeId) - { - case 0x0007: // NeighborTableList - // Struct _NeighborTable - entryLength = 31; - break; - case 0x0008: // RouteTableList - // Struct _RouteTable - entryLength = 18; - break; - case 0x003B: // SecurityPolicy - // Struct _SecurityPolicy - entryLength = 4; - break; - case 0x003D: // OperationalDatasetComponents - // Struct _OperationalDatasetComponents - entryLength = 12; - break; - case 0x003E: // ActiveNetworkFaultsList - // uint8_t - entryLength = 1; - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/lighting-app/zap-generated/callback-stub.cpp b/zzz_generated/lighting-app/zap-generated/callback-stub.cpp index 5e7d5bcbbe1379..695579a09c20c6 100644 --- a/zzz_generated/lighting-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/lighting-app/zap-generated/callback-stub.cpp @@ -233,14 +233,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/lock-app/zap-generated/attribute-size.cpp b/zzz_generated/lock-app/zap-generated/attribute-size.cpp deleted file mode 100644 index 6e6e8f4466ee16..00000000000000 --- a/zzz_generated/lock-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,676 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - case 0x002E: // Power Source Configuration Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // Sources - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // INT8U - break; - } - } - break; - } - case 0x0034: // Software Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ThreadMetrics - { - entryLength = 30; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ThreadMetrics - _ThreadMetrics * entry = reinterpret_cast<_ThreadMetrics *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->Id, write ? (uint8_t *) &entry->Id : src, write, &entryOffset, - sizeof(entry->Id)); // INT64U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, NameSpan) : ReadByteSpan(src + entryOffset, 10, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeCurrent, write ? (uint8_t *) &entry->StackFreeCurrent : src, - write, &entryOffset, sizeof(entry->StackFreeCurrent)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeMinimum, write ? (uint8_t *) &entry->StackFreeMinimum : src, - write, &entryOffset, sizeof(entry->StackFreeMinimum)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackSize, write ? (uint8_t *) &entry->StackSize : src, write, - &entryOffset, sizeof(entry->StackSize)); // INT32U - break; - } - } - break; - } - case 0x0035: // Thread Network Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0007: // NeighborTableList - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NeighborTable - _NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src, - write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src, - write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset, - sizeof(entry->LQI)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write, - &entryOffset, sizeof(entry->AverageRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write, - &entryOffset, sizeof(entry->LastRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src, - write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src, - write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write, - &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src, - write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src, - write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write, - &entryOffset, sizeof(entry->IsChild)); // BOOLEAN - break; - } - case 0x0008: // RouteTableList - { - entryLength = 18; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _RouteTable - _RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write, - &entryOffset, sizeof(entry->RouterId)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write, - &entryOffset, sizeof(entry->NextHop)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write, - &entryOffset, sizeof(entry->PathCost)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset, - sizeof(entry->LQIIn)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset, - sizeof(entry->LQIOut)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write, - &entryOffset, sizeof(entry->Allocated)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src, - write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN - break; - } - case 0x003B: // SecurityPolicy - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _SecurityPolicy - _SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write, - &entryOffset, sizeof(entry->RotationTime)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset, - sizeof(entry->Flags)); // BITMAP16 - break; - } - case 0x003D: // OperationalDatasetComponents - { - entryLength = 12; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _OperationalDatasetComponents - _OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent, - write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset, - sizeof(entry->ActiveTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent, - write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset, - sizeof(entry->PendingTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src, - write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent, - write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset, - sizeof(entry->NetworkNamePresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent, - write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset, - sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent, - write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset, - sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write, - &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write, - &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src, - write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write, - &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent, - write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset, - sizeof(entry->SecurityPolicyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent, - write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset, - sizeof(entry->ChannelMaskPresent)); // BOOLEAN - break; - } - case 0x003E: // ActiveNetworkFaultsList - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - case 0x002E: // Power Source Configuration Cluster - switch (attributeId) - { - case 0x0000: // Sources - // uint8_t - entryLength = 1; - break; - } - break; - case 0x0034: // Software Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // ThreadMetrics - // Struct _ThreadMetrics - entryLength = 30; - break; - } - break; - case 0x0035: // Thread Network Diagnostics Cluster - switch (attributeId) - { - case 0x0007: // NeighborTableList - // Struct _NeighborTable - entryLength = 31; - break; - case 0x0008: // RouteTableList - // Struct _RouteTable - entryLength = 18; - break; - case 0x003B: // SecurityPolicy - // Struct _SecurityPolicy - entryLength = 4; - break; - case 0x003D: // OperationalDatasetComponents - // Struct _OperationalDatasetComponents - entryLength = 12; - break; - case 0x003E: // ActiveNetworkFaultsList - // uint8_t - entryLength = 1; - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/lock-app/zap-generated/callback-stub.cpp b/zzz_generated/lock-app/zap-generated/callback-stub.cpp index 5eb2564220b05e..5786b4224d94de 100644 --- a/zzz_generated/lock-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/lock-app/zap-generated/callback-stub.cpp @@ -201,14 +201,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/ota-provider-app/zap-generated/attribute-size.cpp b/zzz_generated/ota-provider-app/zap-generated/attribute-size.cpp deleted file mode 100644 index 11bb303cbdd145..00000000000000 --- a/zzz_generated/ota-provider-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/ota-provider-app/zap-generated/callback-stub.cpp b/zzz_generated/ota-provider-app/zap-generated/callback-stub.cpp index 74b998418ef3d1..7bb69d7e8a255b 100644 --- a/zzz_generated/ota-provider-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/ota-provider-app/zap-generated/callback-stub.cpp @@ -113,14 +113,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp index daeade20704895..8aa5b5c517f332 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/ota-requestor-app/zap-generated/CHIPClientCallbacks.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ using namespace ::chip; using namespace ::chip::app::DataModel; -using namespace ::chip::app::List; namespace { [[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; diff --git a/zzz_generated/ota-requestor-app/zap-generated/attribute-size.cpp b/zzz_generated/ota-requestor-app/zap-generated/attribute-size.cpp deleted file mode 100644 index 11bb303cbdd145..00000000000000 --- a/zzz_generated/ota-requestor-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/ota-requestor-app/zap-generated/callback-stub.cpp b/zzz_generated/ota-requestor-app/zap-generated/callback-stub.cpp index 1dd3d27caf86f0..87bbd91ee33619 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/ota-requestor-app/zap-generated/callback-stub.cpp @@ -121,14 +121,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/placeholder/app1/zap-generated/attribute-size.cpp b/zzz_generated/placeholder/app1/zap-generated/attribute-size.cpp deleted file mode 100644 index b9c158596694f8..00000000000000 --- a/zzz_generated/placeholder/app1/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/placeholder/app1/zap-generated/callback-stub.cpp b/zzz_generated/placeholder/app1/zap-generated/callback-stub.cpp index 214e50775b0b35..a1648e1d566d94 100644 --- a/zzz_generated/placeholder/app1/zap-generated/callback-stub.cpp +++ b/zzz_generated/placeholder/app1/zap-generated/callback-stub.cpp @@ -161,14 +161,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/placeholder/app2/zap-generated/attribute-size.cpp b/zzz_generated/placeholder/app2/zap-generated/attribute-size.cpp deleted file mode 100644 index b9c158596694f8..00000000000000 --- a/zzz_generated/placeholder/app2/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/placeholder/app2/zap-generated/callback-stub.cpp b/zzz_generated/placeholder/app2/zap-generated/callback-stub.cpp index a37d7d50cf56f0..cb4dc2c8c0f765 100644 --- a/zzz_generated/placeholder/app2/zap-generated/callback-stub.cpp +++ b/zzz_generated/placeholder/app2/zap-generated/callback-stub.cpp @@ -153,14 +153,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp index e28673418b09cd..98ee177d541321 100644 --- a/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/pump-app/zap-generated/CHIPClientCallbacks.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ using namespace ::chip; using namespace ::chip::app::DataModel; -using namespace ::chip::app::List; namespace { [[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; diff --git a/zzz_generated/pump-app/zap-generated/attribute-size.cpp b/zzz_generated/pump-app/zap-generated/attribute-size.cpp deleted file mode 100644 index eefc399fb4e2f3..00000000000000 --- a/zzz_generated/pump-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,647 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - case 0x0034: // Software Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ThreadMetrics - { - entryLength = 30; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ThreadMetrics - _ThreadMetrics * entry = reinterpret_cast<_ThreadMetrics *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->Id, write ? (uint8_t *) &entry->Id : src, write, &entryOffset, - sizeof(entry->Id)); // INT64U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, NameSpan) : ReadByteSpan(src + entryOffset, 10, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeCurrent, write ? (uint8_t *) &entry->StackFreeCurrent : src, - write, &entryOffset, sizeof(entry->StackFreeCurrent)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeMinimum, write ? (uint8_t *) &entry->StackFreeMinimum : src, - write, &entryOffset, sizeof(entry->StackFreeMinimum)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackSize, write ? (uint8_t *) &entry->StackSize : src, write, - &entryOffset, sizeof(entry->StackSize)); // INT32U - break; - } - } - break; - } - case 0x0035: // Thread Network Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0007: // NeighborTableList - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NeighborTable - _NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src, - write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src, - write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset, - sizeof(entry->LQI)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write, - &entryOffset, sizeof(entry->AverageRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write, - &entryOffset, sizeof(entry->LastRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src, - write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src, - write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write, - &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src, - write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src, - write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write, - &entryOffset, sizeof(entry->IsChild)); // BOOLEAN - break; - } - case 0x0008: // RouteTableList - { - entryLength = 18; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _RouteTable - _RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write, - &entryOffset, sizeof(entry->RouterId)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write, - &entryOffset, sizeof(entry->NextHop)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write, - &entryOffset, sizeof(entry->PathCost)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset, - sizeof(entry->LQIIn)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset, - sizeof(entry->LQIOut)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write, - &entryOffset, sizeof(entry->Allocated)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src, - write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN - break; - } - case 0x003B: // SecurityPolicy - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _SecurityPolicy - _SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write, - &entryOffset, sizeof(entry->RotationTime)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset, - sizeof(entry->Flags)); // BITMAP16 - break; - } - case 0x003D: // OperationalDatasetComponents - { - entryLength = 12; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _OperationalDatasetComponents - _OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent, - write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset, - sizeof(entry->ActiveTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent, - write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset, - sizeof(entry->PendingTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src, - write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent, - write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset, - sizeof(entry->NetworkNamePresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent, - write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset, - sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent, - write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset, - sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write, - &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write, - &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src, - write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write, - &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent, - write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset, - sizeof(entry->SecurityPolicyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent, - write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset, - sizeof(entry->ChannelMaskPresent)); // BOOLEAN - break; - } - case 0x003E: // ActiveNetworkFaultsList - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - case 0x0034: // Software Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // ThreadMetrics - // Struct _ThreadMetrics - entryLength = 30; - break; - } - break; - case 0x0035: // Thread Network Diagnostics Cluster - switch (attributeId) - { - case 0x0007: // NeighborTableList - // Struct _NeighborTable - entryLength = 31; - break; - case 0x0008: // RouteTableList - // Struct _RouteTable - entryLength = 18; - break; - case 0x003B: // SecurityPolicy - // Struct _SecurityPolicy - entryLength = 4; - break; - case 0x003D: // OperationalDatasetComponents - // Struct _OperationalDatasetComponents - entryLength = 12; - break; - case 0x003E: // ActiveNetworkFaultsList - // uint8_t - entryLength = 1; - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/pump-app/zap-generated/callback-stub.cpp b/zzz_generated/pump-app/zap-generated/callback-stub.cpp index e28ea0efe2cfe7..7f54b171cff60f 100644 --- a/zzz_generated/pump-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/pump-app/zap-generated/callback-stub.cpp @@ -225,14 +225,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp index e28673418b09cd..98ee177d541321 100644 --- a/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/pump-controller-app/zap-generated/CHIPClientCallbacks.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ using namespace ::chip; using namespace ::chip::app::DataModel; -using namespace ::chip::app::List; namespace { [[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; diff --git a/zzz_generated/pump-controller-app/zap-generated/attribute-size.cpp b/zzz_generated/pump-controller-app/zap-generated/attribute-size.cpp deleted file mode 100644 index eefc399fb4e2f3..00000000000000 --- a/zzz_generated/pump-controller-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,647 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - case 0x0034: // Software Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ThreadMetrics - { - entryLength = 30; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ThreadMetrics - _ThreadMetrics * entry = reinterpret_cast<_ThreadMetrics *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->Id, write ? (uint8_t *) &entry->Id : src, write, &entryOffset, - sizeof(entry->Id)); // INT64U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, NameSpan) : ReadByteSpan(src + entryOffset, 10, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeCurrent, write ? (uint8_t *) &entry->StackFreeCurrent : src, - write, &entryOffset, sizeof(entry->StackFreeCurrent)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeMinimum, write ? (uint8_t *) &entry->StackFreeMinimum : src, - write, &entryOffset, sizeof(entry->StackFreeMinimum)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackSize, write ? (uint8_t *) &entry->StackSize : src, write, - &entryOffset, sizeof(entry->StackSize)); // INT32U - break; - } - } - break; - } - case 0x0035: // Thread Network Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0007: // NeighborTableList - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NeighborTable - _NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src, - write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src, - write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset, - sizeof(entry->LQI)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write, - &entryOffset, sizeof(entry->AverageRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write, - &entryOffset, sizeof(entry->LastRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src, - write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src, - write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write, - &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src, - write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src, - write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write, - &entryOffset, sizeof(entry->IsChild)); // BOOLEAN - break; - } - case 0x0008: // RouteTableList - { - entryLength = 18; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _RouteTable - _RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write, - &entryOffset, sizeof(entry->RouterId)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write, - &entryOffset, sizeof(entry->NextHop)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write, - &entryOffset, sizeof(entry->PathCost)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset, - sizeof(entry->LQIIn)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset, - sizeof(entry->LQIOut)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write, - &entryOffset, sizeof(entry->Allocated)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src, - write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN - break; - } - case 0x003B: // SecurityPolicy - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _SecurityPolicy - _SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write, - &entryOffset, sizeof(entry->RotationTime)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset, - sizeof(entry->Flags)); // BITMAP16 - break; - } - case 0x003D: // OperationalDatasetComponents - { - entryLength = 12; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _OperationalDatasetComponents - _OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent, - write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset, - sizeof(entry->ActiveTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent, - write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset, - sizeof(entry->PendingTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src, - write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent, - write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset, - sizeof(entry->NetworkNamePresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent, - write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset, - sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent, - write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset, - sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write, - &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write, - &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src, - write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write, - &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent, - write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset, - sizeof(entry->SecurityPolicyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent, - write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset, - sizeof(entry->ChannelMaskPresent)); // BOOLEAN - break; - } - case 0x003E: // ActiveNetworkFaultsList - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - case 0x0034: // Software Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // ThreadMetrics - // Struct _ThreadMetrics - entryLength = 30; - break; - } - break; - case 0x0035: // Thread Network Diagnostics Cluster - switch (attributeId) - { - case 0x0007: // NeighborTableList - // Struct _NeighborTable - entryLength = 31; - break; - case 0x0008: // RouteTableList - // Struct _RouteTable - entryLength = 18; - break; - case 0x003B: // SecurityPolicy - // Struct _SecurityPolicy - entryLength = 4; - break; - case 0x003D: // OperationalDatasetComponents - // Struct _OperationalDatasetComponents - entryLength = 12; - break; - case 0x003E: // ActiveNetworkFaultsList - // uint8_t - entryLength = 1; - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/pump-controller-app/zap-generated/callback-stub.cpp b/zzz_generated/pump-controller-app/zap-generated/callback-stub.cpp index e28ea0efe2cfe7..7f54b171cff60f 100644 --- a/zzz_generated/pump-controller-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/pump-controller-app/zap-generated/callback-stub.cpp @@ -225,14 +225,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/temperature-measurement-app/zap-generated/attribute-size.cpp b/zzz_generated/temperature-measurement-app/zap-generated/attribute-size.cpp deleted file mode 100644 index 6fef2429d7f1df..00000000000000 --- a/zzz_generated/temperature-measurement-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,420 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/temperature-measurement-app/zap-generated/callback-stub.cpp b/zzz_generated/temperature-measurement-app/zap-generated/callback-stub.cpp index 0dfb7164a4b61d..ed6d128ca43656 100644 --- a/zzz_generated/temperature-measurement-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/temperature-measurement-app/zap-generated/callback-stub.cpp @@ -177,14 +177,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp index b913d71dee199a..b36455f164431b 100644 --- a/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/thermostat/zap-generated/CHIPClientCallbacks.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ using namespace ::chip; using namespace ::chip::app::DataModel; -using namespace ::chip::app::List; namespace { [[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; diff --git a/zzz_generated/thermostat/zap-generated/attribute-size.cpp b/zzz_generated/thermostat/zap-generated/attribute-size.cpp deleted file mode 100644 index db03dd8b31f28a..00000000000000 --- a/zzz_generated/thermostat/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,719 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003F: // Group Key Management Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // groups - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _GroupState - _GroupState * entry = reinterpret_cast<_GroupState *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->VendorGroupId, write ? (uint8_t *) &entry->VendorGroupId : src, write, - &entryOffset, sizeof(entry->VendorGroupId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeySetIndex, write ? (uint8_t *) &entry->GroupKeySetIndex : src, - write, &entryOffset, sizeof(entry->GroupKeySetIndex)); // INT16U - break; - } - case 0x0001: // group keys - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _GroupKey - _GroupKey * entry = reinterpret_cast<_GroupKey *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyIndex, write ? (uint8_t *) &entry->GroupKeyIndex : src, write, - &entryOffset, sizeof(entry->GroupKeyIndex)); // INT16U - ByteSpan * GroupKeyRootSpan = &entry->GroupKeyRoot; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 18, GroupKeyRootSpan) - : ReadByteSpan(src + entryOffset, 18, GroupKeyRootSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 18); - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyEpochStartTime, - write ? (uint8_t *) &entry->GroupKeyEpochStartTime : src, write, &entryOffset, - sizeof(entry->GroupKeyEpochStartTime)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeySecurityPolicy, - write ? (uint8_t *) &entry->GroupKeySecurityPolicy : src, write, &entryOffset, - sizeof(entry->GroupKeySecurityPolicy)); // GroupKeySecurityPolicy - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - case 0x0034: // Software Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ThreadMetrics - { - entryLength = 30; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ThreadMetrics - _ThreadMetrics * entry = reinterpret_cast<_ThreadMetrics *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->Id, write ? (uint8_t *) &entry->Id : src, write, &entryOffset, - sizeof(entry->Id)); // INT64U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, NameSpan) : ReadByteSpan(src + entryOffset, 10, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeCurrent, write ? (uint8_t *) &entry->StackFreeCurrent : src, - write, &entryOffset, sizeof(entry->StackFreeCurrent)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeMinimum, write ? (uint8_t *) &entry->StackFreeMinimum : src, - write, &entryOffset, sizeof(entry->StackFreeMinimum)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackSize, write ? (uint8_t *) &entry->StackSize : src, write, - &entryOffset, sizeof(entry->StackSize)); // INT32U - break; - } - } - break; - } - case 0x0035: // Thread Network Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0007: // NeighborTableList - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NeighborTable - _NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src, - write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src, - write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset, - sizeof(entry->LQI)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write, - &entryOffset, sizeof(entry->AverageRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write, - &entryOffset, sizeof(entry->LastRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src, - write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src, - write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write, - &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src, - write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src, - write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write, - &entryOffset, sizeof(entry->IsChild)); // BOOLEAN - break; - } - case 0x0008: // RouteTableList - { - entryLength = 18; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _RouteTable - _RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write, - &entryOffset, sizeof(entry->RouterId)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write, - &entryOffset, sizeof(entry->NextHop)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write, - &entryOffset, sizeof(entry->PathCost)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset, - sizeof(entry->LQIIn)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset, - sizeof(entry->LQIOut)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write, - &entryOffset, sizeof(entry->Allocated)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src, - write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN - break; - } - case 0x003B: // SecurityPolicy - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _SecurityPolicy - _SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write, - &entryOffset, sizeof(entry->RotationTime)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset, - sizeof(entry->Flags)); // BITMAP16 - break; - } - case 0x003D: // OperationalDatasetComponents - { - entryLength = 12; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _OperationalDatasetComponents - _OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent, - write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset, - sizeof(entry->ActiveTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent, - write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset, - sizeof(entry->PendingTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src, - write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent, - write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset, - sizeof(entry->NetworkNamePresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent, - write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset, - sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent, - write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset, - sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write, - &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write, - &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src, - write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write, - &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent, - write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset, - sizeof(entry->SecurityPolicyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent, - write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset, - sizeof(entry->ChannelMaskPresent)); // BOOLEAN - break; - } - case 0x003E: // ActiveNetworkFaultsList - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003F: // Group Key Management Cluster - switch (attributeId) - { - case 0x0000: // groups - // Struct _GroupState - entryLength = 6; - break; - case 0x0001: // group keys - // Struct _GroupKey - entryLength = 31; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - case 0x0034: // Software Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // ThreadMetrics - // Struct _ThreadMetrics - entryLength = 30; - break; - } - break; - case 0x0035: // Thread Network Diagnostics Cluster - switch (attributeId) - { - case 0x0007: // NeighborTableList - // Struct _NeighborTable - entryLength = 31; - break; - case 0x0008: // RouteTableList - // Struct _RouteTable - entryLength = 18; - break; - case 0x003B: // SecurityPolicy - // Struct _SecurityPolicy - entryLength = 4; - break; - case 0x003D: // OperationalDatasetComponents - // Struct _OperationalDatasetComponents - entryLength = 12; - break; - case 0x003E: // ActiveNetworkFaultsList - // uint8_t - entryLength = 1; - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/thermostat/zap-generated/callback-stub.cpp b/zzz_generated/thermostat/zap-generated/callback-stub.cpp index 950ac48a14f3a1..a488cdc972e469 100644 --- a/zzz_generated/thermostat/zap-generated/callback-stub.cpp +++ b/zzz_generated/thermostat/zap-generated/callback-stub.cpp @@ -233,14 +233,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp index 949122cedd4a42..1d751ad6530fab 100644 --- a/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/tv-app/zap-generated/CHIPClientCallbacks.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,6 @@ using namespace ::chip; using namespace ::chip::app::DataModel; -using namespace ::chip::app::List; namespace { [[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2; diff --git a/zzz_generated/tv-app/zap-generated/attribute-size.cpp b/zzz_generated/tv-app/zap-generated/attribute-size.cpp deleted file mode 100644 index 8e4ed725f9d200..00000000000000 --- a/zzz_generated/tv-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,1009 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x050C: // Application Launcher Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // application launcher list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // INT16U - break; - } - } - break; - } - case 0x050B: // Audio Output Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // audio output list - { - entryLength = 36; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _AudioOutputInfo - _AudioOutputInfo * entry = reinterpret_cast<_AudioOutputInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->index, write ? (uint8_t *) &entry->index : src, write, &entryOffset, - sizeof(entry->index)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->outputType, write ? (uint8_t *) &entry->outputType : src, write, - &entryOffset, sizeof(entry->outputType)); // AudioOutputType - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x050A: // Content Launcher Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // accepts header list - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * acceptsHeaderListSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t acceptsHeaderListRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, acceptsHeaderListRemainingSpace, acceptsHeaderListSpan) - : ReadByteSpan(src + entryOffset, acceptsHeaderListRemainingSpace, acceptsHeaderListSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(acceptsHeaderListSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", acceptsHeaderListSpan->size()); - return 0; - } - entryLength = static_cast(acceptsHeaderListSpan->size()); - break; - } - case 0x0001: // supported streaming types - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ContentLaunchStreamingType - break; - } - } - break; - } - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003F: // Group Key Management Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // groups - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _GroupState - _GroupState * entry = reinterpret_cast<_GroupState *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->VendorGroupId, write ? (uint8_t *) &entry->VendorGroupId : src, write, - &entryOffset, sizeof(entry->VendorGroupId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeySetIndex, write ? (uint8_t *) &entry->GroupKeySetIndex : src, - write, &entryOffset, sizeof(entry->GroupKeySetIndex)); // INT16U - break; - } - case 0x0001: // group keys - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _GroupKey - _GroupKey * entry = reinterpret_cast<_GroupKey *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyIndex, write ? (uint8_t *) &entry->GroupKeyIndex : src, write, - &entryOffset, sizeof(entry->GroupKeyIndex)); // INT16U - ByteSpan * GroupKeyRootSpan = &entry->GroupKeyRoot; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 18, GroupKeyRootSpan) - : ReadByteSpan(src + entryOffset, 18, GroupKeyRootSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 18); - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyEpochStartTime, - write ? (uint8_t *) &entry->GroupKeyEpochStartTime : src, write, &entryOffset, - sizeof(entry->GroupKeyEpochStartTime)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeySecurityPolicy, - write ? (uint8_t *) &entry->GroupKeySecurityPolicy : src, write, &entryOffset, - sizeof(entry->GroupKeySecurityPolicy)); // GroupKeySecurityPolicy - break; - } - } - break; - } - case 0x0507: // Media Input Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // media input list - { - entryLength = 70; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _MediaInputInfo - _MediaInputInfo * entry = reinterpret_cast<_MediaInputInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->index, write ? (uint8_t *) &entry->index : src, write, &entryOffset, - sizeof(entry->index)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->inputType, write ? (uint8_t *) &entry->inputType : src, write, - &entryOffset, sizeof(entry->inputType)); // MediaInputType - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - ByteSpan descriptionSpanStorage(Uint8::from_const_char(entry->description.data()), - entry->description.size()); // CHAR_STRING - ByteSpan * descriptionSpan = &descriptionSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, descriptionSpan) - : ReadByteSpan(src + entryOffset, 34, descriptionSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - case 0x0034: // Software Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ThreadMetrics - { - entryLength = 30; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ThreadMetrics - _ThreadMetrics * entry = reinterpret_cast<_ThreadMetrics *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->Id, write ? (uint8_t *) &entry->Id : src, write, &entryOffset, - sizeof(entry->Id)); // INT64U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, NameSpan) : ReadByteSpan(src + entryOffset, 10, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeCurrent, write ? (uint8_t *) &entry->StackFreeCurrent : src, - write, &entryOffset, sizeof(entry->StackFreeCurrent)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeMinimum, write ? (uint8_t *) &entry->StackFreeMinimum : src, - write, &entryOffset, sizeof(entry->StackFreeMinimum)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackSize, write ? (uint8_t *) &entry->StackSize : src, write, - &entryOffset, sizeof(entry->StackSize)); // INT32U - break; - } - } - break; - } - case 0x0504: // TV Channel Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // tv channel list - { - entryLength = 106; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _TvChannelInfo - _TvChannelInfo * entry = reinterpret_cast<_TvChannelInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->majorNumber, write ? (uint8_t *) &entry->majorNumber : src, write, - &entryOffset, sizeof(entry->majorNumber)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->minorNumber, write ? (uint8_t *) &entry->minorNumber : src, write, - &entryOffset, sizeof(entry->minorNumber)); // INT16U - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - ByteSpan callSignSpanStorage(Uint8::from_const_char(entry->callSign.data()), entry->callSign.size()); // CHAR_STRING - ByteSpan * callSignSpan = &callSignSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, callSignSpan) : ReadByteSpan(src + entryOffset, 34, callSignSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - ByteSpan affiliateCallSignSpanStorage(Uint8::from_const_char(entry->affiliateCallSign.data()), - entry->affiliateCallSign.size()); // CHAR_STRING - ByteSpan * affiliateCallSignSpan = &affiliateCallSignSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, affiliateCallSignSpan) - : ReadByteSpan(src + entryOffset, 34, affiliateCallSignSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x0505: // Target Navigator Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // target navigator list - { - entryLength = 35; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NavigateTargetTargetInfo - _NavigateTargetTargetInfo * entry = reinterpret_cast<_NavigateTargetTargetInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->identifier, write ? (uint8_t *) &entry->identifier : src, write, - &entryOffset, sizeof(entry->identifier)); // INT8U - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x0035: // Thread Network Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0007: // NeighborTableList - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NeighborTable - _NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src, - write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src, - write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset, - sizeof(entry->LQI)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write, - &entryOffset, sizeof(entry->AverageRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write, - &entryOffset, sizeof(entry->LastRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src, - write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src, - write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write, - &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src, - write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src, - write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write, - &entryOffset, sizeof(entry->IsChild)); // BOOLEAN - break; - } - case 0x0008: // RouteTableList - { - entryLength = 18; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _RouteTable - _RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write, - &entryOffset, sizeof(entry->RouterId)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write, - &entryOffset, sizeof(entry->NextHop)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write, - &entryOffset, sizeof(entry->PathCost)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset, - sizeof(entry->LQIIn)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset, - sizeof(entry->LQIOut)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write, - &entryOffset, sizeof(entry->Allocated)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src, - write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN - break; - } - case 0x003B: // SecurityPolicy - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _SecurityPolicy - _SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write, - &entryOffset, sizeof(entry->RotationTime)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset, - sizeof(entry->Flags)); // BITMAP16 - break; - } - case 0x003D: // OperationalDatasetComponents - { - entryLength = 12; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _OperationalDatasetComponents - _OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent, - write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset, - sizeof(entry->ActiveTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent, - write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset, - sizeof(entry->PendingTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src, - write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent, - write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset, - sizeof(entry->NetworkNamePresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent, - write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset, - sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent, - write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset, - sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write, - &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write, - &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src, - write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write, - &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent, - write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset, - sizeof(entry->SecurityPolicyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent, - write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset, - sizeof(entry->ChannelMaskPresent)); // BOOLEAN - break; - } - case 0x003E: // ActiveNetworkFaultsList - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x050C: // Application Launcher Cluster - switch (attributeId) - { - case 0x0000: // application launcher list - // uint16_t - entryLength = 2; - break; - } - break; - case 0x050B: // Audio Output Cluster - switch (attributeId) - { - case 0x0000: // audio output list - // Struct _AudioOutputInfo - entryLength = 36; - break; - } - break; - case 0x050A: // Content Launcher Cluster - switch (attributeId) - { - case 0x0000: // accepts header list - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 256, entryCount); - break; - case 0x0001: // supported streaming types - // uint8_t - entryLength = 1; - break; - } - break; - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003F: // Group Key Management Cluster - switch (attributeId) - { - case 0x0000: // groups - // Struct _GroupState - entryLength = 6; - break; - case 0x0001: // group keys - // Struct _GroupKey - entryLength = 31; - break; - } - break; - case 0x0507: // Media Input Cluster - switch (attributeId) - { - case 0x0000: // media input list - // Struct _MediaInputInfo - entryLength = 70; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - case 0x0034: // Software Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // ThreadMetrics - // Struct _ThreadMetrics - entryLength = 30; - break; - } - break; - case 0x0504: // TV Channel Cluster - switch (attributeId) - { - case 0x0000: // tv channel list - // Struct _TvChannelInfo - entryLength = 106; - break; - } - break; - case 0x0505: // Target Navigator Cluster - switch (attributeId) - { - case 0x0000: // target navigator list - // Struct _NavigateTargetTargetInfo - entryLength = 35; - break; - } - break; - case 0x0035: // Thread Network Diagnostics Cluster - switch (attributeId) - { - case 0x0007: // NeighborTableList - // Struct _NeighborTable - entryLength = 31; - break; - case 0x0008: // RouteTableList - // Struct _RouteTable - entryLength = 18; - break; - case 0x003B: // SecurityPolicy - // Struct _SecurityPolicy - entryLength = 4; - break; - case 0x003D: // OperationalDatasetComponents - // Struct _OperationalDatasetComponents - entryLength = 12; - break; - case 0x003E: // ActiveNetworkFaultsList - // uint8_t - entryLength = 1; - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/tv-app/zap-generated/callback-stub.cpp b/zzz_generated/tv-app/zap-generated/callback-stub.cpp index aa408f3d620c07..0dc537565554fc 100644 --- a/zzz_generated/tv-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/tv-app/zap-generated/callback-stub.cpp @@ -321,14 +321,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/tv-casting-app/zap-generated/attribute-size.cpp b/zzz_generated/tv-casting-app/zap-generated/attribute-size.cpp deleted file mode 100644 index 42cd3bf183506c..00000000000000 --- a/zzz_generated/tv-casting-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,1145 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x050C: // Application Launcher Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // application launcher list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // INT16U - break; - } - } - break; - } - case 0x050B: // Audio Output Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // audio output list - { - entryLength = 36; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _AudioOutputInfo - _AudioOutputInfo * entry = reinterpret_cast<_AudioOutputInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->index, write ? (uint8_t *) &entry->index : src, write, &entryOffset, - sizeof(entry->index)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->outputType, write ? (uint8_t *) &entry->outputType : src, write, - &entryOffset, sizeof(entry->outputType)); // AudioOutputType - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x050A: // Content Launcher Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // accepts header list - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * acceptsHeaderListSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t acceptsHeaderListRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, acceptsHeaderListRemainingSpace, acceptsHeaderListSpan) - : ReadByteSpan(src + entryOffset, acceptsHeaderListRemainingSpace, acceptsHeaderListSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(acceptsHeaderListSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", acceptsHeaderListSpan->size()); - return 0; - } - entryLength = static_cast(acceptsHeaderListSpan->size()); - break; - } - case 0x0001: // supported streaming types - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ContentLaunchStreamingType - break; - } - } - break; - } - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0040: // Fixed Label Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // label list - { - entryLength = 36; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _LabelStruct - _LabelStruct * entry = reinterpret_cast<_LabelStruct *>(write ? src : dest); - ByteSpan labelSpanStorage(Uint8::from_const_char(entry->label.data()), entry->label.size()); // CHAR_STRING - ByteSpan * labelSpan = &labelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 18, labelSpan) : ReadByteSpan(src + entryOffset, 18, labelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 18); - ByteSpan valueSpanStorage(Uint8::from_const_char(entry->value.data()), entry->value.size()); // CHAR_STRING - ByteSpan * valueSpan = &valueSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 18, valueSpan) : ReadByteSpan(src + entryOffset, 18, valueSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 18); - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003F: // Group Key Management Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // groups - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _GroupState - _GroupState * entry = reinterpret_cast<_GroupState *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->VendorGroupId, write ? (uint8_t *) &entry->VendorGroupId : src, write, - &entryOffset, sizeof(entry->VendorGroupId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeySetIndex, write ? (uint8_t *) &entry->GroupKeySetIndex : src, - write, &entryOffset, sizeof(entry->GroupKeySetIndex)); // INT16U - break; - } - case 0x0001: // group keys - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _GroupKey - _GroupKey * entry = reinterpret_cast<_GroupKey *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyIndex, write ? (uint8_t *) &entry->GroupKeyIndex : src, write, - &entryOffset, sizeof(entry->GroupKeyIndex)); // INT16U - ByteSpan * GroupKeyRootSpan = &entry->GroupKeyRoot; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 18, GroupKeyRootSpan) - : ReadByteSpan(src + entryOffset, 18, GroupKeyRootSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 18); - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeyEpochStartTime, - write ? (uint8_t *) &entry->GroupKeyEpochStartTime : src, write, &entryOffset, - sizeof(entry->GroupKeyEpochStartTime)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->GroupKeySecurityPolicy, - write ? (uint8_t *) &entry->GroupKeySecurityPolicy : src, write, &entryOffset, - sizeof(entry->GroupKeySecurityPolicy)); // GroupKeySecurityPolicy - break; - } - } - break; - } - case 0x0507: // Media Input Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // media input list - { - entryLength = 70; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _MediaInputInfo - _MediaInputInfo * entry = reinterpret_cast<_MediaInputInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->index, write ? (uint8_t *) &entry->index : src, write, &entryOffset, - sizeof(entry->index)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->inputType, write ? (uint8_t *) &entry->inputType : src, write, - &entryOffset, sizeof(entry->inputType)); // MediaInputType - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - ByteSpan descriptionSpanStorage(Uint8::from_const_char(entry->description.data()), - entry->description.size()); // CHAR_STRING - ByteSpan * descriptionSpan = &descriptionSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, descriptionSpan) - : ReadByteSpan(src + entryOffset, 34, descriptionSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - case 0x0034: // Software Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ThreadMetrics - { - entryLength = 30; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ThreadMetrics - _ThreadMetrics * entry = reinterpret_cast<_ThreadMetrics *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->Id, write ? (uint8_t *) &entry->Id : src, write, &entryOffset, - sizeof(entry->Id)); // INT64U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, NameSpan) : ReadByteSpan(src + entryOffset, 10, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeCurrent, write ? (uint8_t *) &entry->StackFreeCurrent : src, - write, &entryOffset, sizeof(entry->StackFreeCurrent)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeMinimum, write ? (uint8_t *) &entry->StackFreeMinimum : src, - write, &entryOffset, sizeof(entry->StackFreeMinimum)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackSize, write ? (uint8_t *) &entry->StackSize : src, write, - &entryOffset, sizeof(entry->StackSize)); // INT32U - break; - } - } - break; - } - case 0x0504: // TV Channel Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // tv channel list - { - entryLength = 106; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _TvChannelInfo - _TvChannelInfo * entry = reinterpret_cast<_TvChannelInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->majorNumber, write ? (uint8_t *) &entry->majorNumber : src, write, - &entryOffset, sizeof(entry->majorNumber)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->minorNumber, write ? (uint8_t *) &entry->minorNumber : src, write, - &entryOffset, sizeof(entry->minorNumber)); // INT16U - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - ByteSpan callSignSpanStorage(Uint8::from_const_char(entry->callSign.data()), entry->callSign.size()); // CHAR_STRING - ByteSpan * callSignSpan = &callSignSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, callSignSpan) : ReadByteSpan(src + entryOffset, 34, callSignSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - ByteSpan affiliateCallSignSpanStorage(Uint8::from_const_char(entry->affiliateCallSign.data()), - entry->affiliateCallSign.size()); // CHAR_STRING - ByteSpan * affiliateCallSignSpan = &affiliateCallSignSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, affiliateCallSignSpan) - : ReadByteSpan(src + entryOffset, 34, affiliateCallSignSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x0505: // Target Navigator Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // target navigator list - { - entryLength = 35; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NavigateTargetTargetInfo - _NavigateTargetTargetInfo * entry = reinterpret_cast<_NavigateTargetTargetInfo *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->identifier, write ? (uint8_t *) &entry->identifier : src, write, - &entryOffset, sizeof(entry->identifier)); // INT8U - ByteSpan nameSpanStorage(Uint8::from_const_char(entry->name.data()), entry->name.size()); // CHAR_STRING - ByteSpan * nameSpan = &nameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, nameSpan) : ReadByteSpan(src + entryOffset, 34, nameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x050F: // Test Cluster Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x001A: // list_int8u - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // INT8U - break; - } - case 0x001B: // list_octet_string - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * listOctetStringSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t listOctetStringRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, listOctetStringRemainingSpace, listOctetStringSpan) - : ReadByteSpan(src + entryOffset, listOctetStringRemainingSpace, listOctetStringSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(listOctetStringSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", listOctetStringSpan->size()); - return 0; - } - entryLength = static_cast(listOctetStringSpan->size()); - break; - } - case 0x001C: // list_struct_octet_string - { - entryLength = 42; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _TestListStructOctet - _TestListStructOctet * entry = reinterpret_cast<_TestListStructOctet *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->fabricIndex, write ? (uint8_t *) &entry->fabricIndex : src, write, - &entryOffset, sizeof(entry->fabricIndex)); // INT64U - ByteSpan * operationalCertSpan = &entry->operationalCert; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, operationalCertSpan) - : ReadByteSpan(src + entryOffset, 34, operationalCertSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - } - break; - } - case 0x0035: // Thread Network Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0007: // NeighborTableList - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NeighborTable - _NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src, - write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src, - write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset, - sizeof(entry->LQI)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write, - &entryOffset, sizeof(entry->AverageRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write, - &entryOffset, sizeof(entry->LastRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src, - write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src, - write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write, - &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src, - write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src, - write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write, - &entryOffset, sizeof(entry->IsChild)); // BOOLEAN - break; - } - case 0x0008: // RouteTableList - { - entryLength = 18; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _RouteTable - _RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write, - &entryOffset, sizeof(entry->RouterId)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write, - &entryOffset, sizeof(entry->NextHop)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write, - &entryOffset, sizeof(entry->PathCost)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset, - sizeof(entry->LQIIn)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset, - sizeof(entry->LQIOut)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write, - &entryOffset, sizeof(entry->Allocated)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src, - write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN - break; - } - case 0x003B: // SecurityPolicy - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _SecurityPolicy - _SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write, - &entryOffset, sizeof(entry->RotationTime)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset, - sizeof(entry->Flags)); // BITMAP16 - break; - } - case 0x003D: // OperationalDatasetComponents - { - entryLength = 12; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _OperationalDatasetComponents - _OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent, - write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset, - sizeof(entry->ActiveTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent, - write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset, - sizeof(entry->PendingTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src, - write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent, - write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset, - sizeof(entry->NetworkNamePresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent, - write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset, - sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent, - write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset, - sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write, - &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write, - &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src, - write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write, - &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent, - write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset, - sizeof(entry->SecurityPolicyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent, - write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset, - sizeof(entry->ChannelMaskPresent)); // BOOLEAN - break; - } - case 0x003E: // ActiveNetworkFaultsList - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x050C: // Application Launcher Cluster - switch (attributeId) - { - case 0x0000: // application launcher list - // uint16_t - entryLength = 2; - break; - } - break; - case 0x050B: // Audio Output Cluster - switch (attributeId) - { - case 0x0000: // audio output list - // Struct _AudioOutputInfo - entryLength = 36; - break; - } - break; - case 0x050A: // Content Launcher Cluster - switch (attributeId) - { - case 0x0000: // accepts header list - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 256, entryCount); - break; - case 0x0001: // supported streaming types - // uint8_t - entryLength = 1; - break; - } - break; - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0040: // Fixed Label Cluster - switch (attributeId) - { - case 0x0000: // label list - // Struct _LabelStruct - entryLength = 36; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003F: // Group Key Management Cluster - switch (attributeId) - { - case 0x0000: // groups - // Struct _GroupState - entryLength = 6; - break; - case 0x0001: // group keys - // Struct _GroupKey - entryLength = 31; - break; - } - break; - case 0x0507: // Media Input Cluster - switch (attributeId) - { - case 0x0000: // media input list - // Struct _MediaInputInfo - entryLength = 70; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - case 0x0034: // Software Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // ThreadMetrics - // Struct _ThreadMetrics - entryLength = 30; - break; - } - break; - case 0x0504: // TV Channel Cluster - switch (attributeId) - { - case 0x0000: // tv channel list - // Struct _TvChannelInfo - entryLength = 106; - break; - } - break; - case 0x0505: // Target Navigator Cluster - switch (attributeId) - { - case 0x0000: // target navigator list - // Struct _NavigateTargetTargetInfo - entryLength = 35; - break; - } - break; - case 0x050F: // Test Cluster Cluster - switch (attributeId) - { - case 0x001A: // list_int8u - // uint8_t - entryLength = 1; - break; - case 0x001B: // list_octet_string - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 256, entryCount); - break; - case 0x001C: // list_struct_octet_string - // Struct _TestListStructOctet - entryLength = 42; - break; - } - break; - case 0x0035: // Thread Network Diagnostics Cluster - switch (attributeId) - { - case 0x0007: // NeighborTableList - // Struct _NeighborTable - entryLength = 31; - break; - case 0x0008: // RouteTableList - // Struct _RouteTable - entryLength = 18; - break; - case 0x003B: // SecurityPolicy - // Struct _SecurityPolicy - entryLength = 4; - break; - case 0x003D: // OperationalDatasetComponents - // Struct _OperationalDatasetComponents - entryLength = 12; - break; - case 0x003E: // ActiveNetworkFaultsList - // uint8_t - entryLength = 1; - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/tv-casting-app/zap-generated/callback-stub.cpp b/zzz_generated/tv-casting-app/zap-generated/callback-stub.cpp index 3cd254a4fe0cfd..65fc2d2288b4b3 100644 --- a/zzz_generated/tv-casting-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/tv-casting-app/zap-generated/callback-stub.cpp @@ -457,14 +457,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; } diff --git a/zzz_generated/window-app/zap-generated/attribute-size.cpp b/zzz_generated/window-app/zap-generated/attribute-size.cpp deleted file mode 100644 index af7699ec273df2..00000000000000 --- a/zzz_generated/window-app/zap-generated/attribute-size.cpp +++ /dev/null @@ -1,676 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app::List; - -// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid -// and data is undefined. -constexpr uint16_t kSizeLengthInBytes = 2u; - -void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length) -{ - if (write) - { - memmove(dest + *offset, src, length); - } - else - { - memmove(dest, src + *offset, length); - } - - *offset = static_cast(*offset + length); -} - -uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, - int32_t index) -{ - if (index == -1) - { - memmove(dest, src, am->size); - return am->size; - } - - if (index == 0) - { - if (write) - { - // src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value - emberAfCopyInt16u(dest, 0, *reinterpret_cast(src)); - } - else - { - // src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t - *reinterpret_cast(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes); - } - return kSizeLengthInBytes; - } - - if (!CanCastTo(index)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // device list - { - entryLength = 6; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _DeviceType - _DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->type, write ? (uint8_t *) &entry->type : src, write, &entryOffset, - sizeof(entry->type)); // DEVTYPE_ID - copyListMember(write ? dest : (uint8_t *) &entry->revision, write ? (uint8_t *) &entry->revision : src, write, - &entryOffset, sizeof(entry->revision)); // INT16U - break; - } - case 0x0001: // server list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0002: // client list - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID - break; - } - case 0x0003: // parts list - { - entryLength = 2; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO - break; - } - } - break; - } - case 0x0030: // General Commissioning Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // BasicCommissioningInfoList - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _BasicCommissioningInfoType - _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, - write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, - sizeof(entry->FailSafeExpiryLengthMs)); // INT32U - break; - } - } - break; - } - case 0x0033: // General Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // NetworkInterfaces - { - entryLength = 48; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NetworkInterfaceType - _NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest); - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - copyListMember(write ? dest : (uint8_t *) &entry->FabricConnected, write ? (uint8_t *) &entry->FabricConnected : src, - write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv4, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->OffPremiseServicesReachableIPv6, - write ? (uint8_t *) &entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, - sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN - ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) - : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->Type, write ? (uint8_t *) &entry->Type : src, write, &entryOffset, - sizeof(entry->Type)); // InterfaceType - break; - } - case 0x0005: // ActiveHardwareFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0006: // ActiveRadioFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - case 0x0007: // ActiveNetworkFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x003E: // Operational Credentials Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0001: // fabrics list - { - entryLength = 120; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _FabricDescriptor - _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->FabricIndex, write ? (uint8_t *) &entry->FabricIndex : src, write, - &entryOffset, sizeof(entry->FabricIndex)); // INT8U - ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) - : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 67); - copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, - &entryOffset, sizeof(entry->VendorId)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, - &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID - copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING - ByteSpan * LabelSpan = &LabelSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 34); - break; - } - case 0x0004: // TrustedRootCertificates - { - entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast(index - 1)); - if (entryOffset == 0) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - - ByteSpan * trustedRootCertificatesSpan = reinterpret_cast(write ? src : dest); // OCTET_STRING - uint16_t trustedRootCertificatesRemainingSpace = static_cast(am->size - entryOffset); - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) - : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - - if (!CanCastTo(trustedRootCertificatesSpan->size())) - { - ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size()); - return 0; - } - entryLength = static_cast(trustedRootCertificatesSpan->size()); - break; - } - } - break; - } - case 0x002F: // Power Source Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0012: // ActiveBatteryFaults - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // ENUM8 - break; - } - } - break; - } - case 0x0034: // Software Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0000: // ThreadMetrics - { - entryLength = 30; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _ThreadMetrics - _ThreadMetrics * entry = reinterpret_cast<_ThreadMetrics *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->Id, write ? (uint8_t *) &entry->Id : src, write, &entryOffset, - sizeof(entry->Id)); // INT64U - ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING - ByteSpan * NameSpan = &NameSpanStorage; - if (CHIP_NO_ERROR != - (write ? WriteByteSpan(dest + entryOffset, 10, NameSpan) : ReadByteSpan(src + entryOffset, 10, NameSpan))) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); - return 0; - } - entryOffset = static_cast(entryOffset + 10); - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeCurrent, write ? (uint8_t *) &entry->StackFreeCurrent : src, - write, &entryOffset, sizeof(entry->StackFreeCurrent)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackFreeMinimum, write ? (uint8_t *) &entry->StackFreeMinimum : src, - write, &entryOffset, sizeof(entry->StackFreeMinimum)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->StackSize, write ? (uint8_t *) &entry->StackSize : src, write, - &entryOffset, sizeof(entry->StackSize)); // INT32U - break; - } - } - break; - } - case 0x0035: // Thread Network Diagnostics Cluster - { - uint16_t entryOffset = kSizeLengthInBytes; - switch (am->attributeId) - { - case 0x0007: // NeighborTableList - { - entryLength = 31; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _NeighborTable - _NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src, - write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src, - write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U - copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset, - sizeof(entry->LQI)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write, - &entryOffset, sizeof(entry->AverageRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write, - &entryOffset, sizeof(entry->LastRssi)); // INT8S - copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src, - write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src, - write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write, - &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src, - write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src, - write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write, - &entryOffset, sizeof(entry->IsChild)); // BOOLEAN - break; - } - case 0x0008: // RouteTableList - { - entryLength = 18; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _RouteTable - _RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write, - &entryOffset, sizeof(entry->ExtAddress)); // INT64U - copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset, - sizeof(entry->Rloc16)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write, - &entryOffset, sizeof(entry->RouterId)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write, - &entryOffset, sizeof(entry->NextHop)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write, - &entryOffset, sizeof(entry->PathCost)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset, - sizeof(entry->LQIIn)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset, - sizeof(entry->LQIOut)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset, - sizeof(entry->Age)); // INT8U - copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write, - &entryOffset, sizeof(entry->Allocated)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src, - write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN - break; - } - case 0x003B: // SecurityPolicy - { - entryLength = 4; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _SecurityPolicy - _SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write, - &entryOffset, sizeof(entry->RotationTime)); // INT16U - copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset, - sizeof(entry->Flags)); // BITMAP16 - break; - } - case 0x003D: // OperationalDatasetComponents - { - entryLength = 12; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - // Struct _OperationalDatasetComponents - _OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest); - copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent, - write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset, - sizeof(entry->ActiveTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent, - write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset, - sizeof(entry->PendingTimestampPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src, - write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent, - write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset, - sizeof(entry->NetworkNamePresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent, - write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset, - sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent, - write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset, - sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write, - &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write, - &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src, - write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write, - &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent, - write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset, - sizeof(entry->SecurityPolicyPresent)); // BOOLEAN - copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent, - write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset, - sizeof(entry->ChannelMaskPresent)); // BOOLEAN - break; - } - case 0x003E: // ActiveNetworkFaultsList - { - entryLength = 1; - if (((index - 1) * entryLength) > (am->size - entryLength)) - { - ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); - return 0; - } - entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); - copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault - break; - } - } - break; - } - } - - return entryLength; -} - -// A list is a collection of entries of the same data type. The data type may be any defined data type. -uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer) -{ - // The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid - // and data is undefined. - uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes); - if (entryCount == 0xFFFF) - { - return 0; - } - - uint16_t entryLength = 0; - switch (clusterId) - { - case 0x001D: // Descriptor Cluster - switch (attributeId) - { - case 0x0000: // device list - // Struct _DeviceType - entryLength = 6; - break; - case 0x0001: // server list - // chip::ClusterId - entryLength = 4; - break; - case 0x0002: // client list - // chip::ClusterId - entryLength = 4; - break; - case 0x0003: // parts list - // chip::EndpointId - entryLength = 2; - break; - } - break; - case 0x0030: // General Commissioning Cluster - switch (attributeId) - { - case 0x0001: // BasicCommissioningInfoList - // Struct _BasicCommissioningInfoType - entryLength = 4; - break; - } - break; - case 0x0033: // General Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // NetworkInterfaces - // Struct _NetworkInterfaceType - entryLength = 48; - break; - case 0x0005: // ActiveHardwareFaults - // uint8_t - entryLength = 1; - break; - case 0x0006: // ActiveRadioFaults - // uint8_t - entryLength = 1; - break; - case 0x0007: // ActiveNetworkFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x003E: // Operational Credentials Cluster - switch (attributeId) - { - case 0x0001: // fabrics list - // Struct _FabricDescriptor - entryLength = 120; - break; - case 0x0004: // TrustedRootCertificates - // chip::ByteSpan - return GetByteSpanOffsetFromIndex(buffer, 402, entryCount); - break; - } - break; - case 0x002F: // Power Source Cluster - switch (attributeId) - { - case 0x0012: // ActiveBatteryFaults - // uint8_t - entryLength = 1; - break; - } - break; - case 0x0034: // Software Diagnostics Cluster - switch (attributeId) - { - case 0x0000: // ThreadMetrics - // Struct _ThreadMetrics - entryLength = 30; - break; - } - break; - case 0x0035: // Thread Network Diagnostics Cluster - switch (attributeId) - { - case 0x0007: // NeighborTableList - // Struct _NeighborTable - entryLength = 31; - break; - case 0x0008: // RouteTableList - // Struct _RouteTable - entryLength = 18; - break; - case 0x003B: // SecurityPolicy - // Struct _SecurityPolicy - entryLength = 4; - break; - case 0x003D: // OperationalDatasetComponents - // Struct _OperationalDatasetComponents - entryLength = 12; - break; - case 0x003E: // ActiveNetworkFaultsList - // uint8_t - entryLength = 1; - break; - } - break; - } - - uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!CanCastTo(totalSize)) - { - ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", - ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); - return 0; - } - - return static_cast(totalSize); -} diff --git a/zzz_generated/window-app/zap-generated/callback-stub.cpp b/zzz_generated/window-app/zap-generated/callback-stub.cpp index 9d49ac2d351357..3f2e318f8a3d1f 100644 --- a/zzz_generated/window-app/zap-generated/callback-stub.cpp +++ b/zzz_generated/window-app/zap-generated/callback-stub.cpp @@ -193,14 +193,14 @@ bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestinati EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength) { return EMBER_ZCL_STATUS_FAILURE; } EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata, - uint16_t manufacturerCode, uint8_t * buffer, int32_t index) + uint16_t manufacturerCode, uint8_t * buffer) { return EMBER_ZCL_STATUS_FAILURE; }