From f88fe0a3f5617a9ad76bb57eba42fe647ad6d26c Mon Sep 17 00:00:00 2001 From: Song Guo Date: Tue, 29 Jun 2021 04:19:12 +0800 Subject: [PATCH] [im] Land ReadAttribute using Interaction Model protocol (#7634) * [im] Implement cluster reading * Cleanup ember code for attribute reading * Disable CRMP for AttributeReading * Address comments * Revert changes to callback types. * Add TLVDataFilter for checking values in TLV * Fix python script for attribute reading * Address comments * Add secure session handle to SendReadRequest * Run codegen --- .../all-clusters-common/gen/CHIPClusters.cpp | 1 + .../all-clusters-common/gen/callback-stub.cpp | 16 - .../all-clusters-common/gen/callback.h | 13 - .../bridge-common/gen/CHIPClusters.cpp | 1 + .../bridge-common/gen/callback-stub.cpp | 16 - .../bridge-app/bridge-common/gen/callback.h | 13 - .../lighting-common/gen/CHIPClusters.cpp | 1 + .../lighting-common/gen/callback-stub.cpp | 16 - .../lighting-common/gen/callback.h | 13 - .../lock-app/lock-common/gen/CHIPClusters.cpp | 1 + .../lock-common/gen/callback-stub.cpp | 16 - examples/lock-app/lock-common/gen/callback.h | 13 - .../pump-common/gen/CHIPClientCallbacks.cpp | 482 ++- .../pump-common/gen/CHIPClientCallbacks.h | 37 + .../pump-app/pump-common/gen/CHIPClusters.cpp | 121 +- .../pump-common/gen/callback-stub.cpp | 16 - examples/pump-app/pump-common/gen/callback.h | 13 - .../gen/CHIPClientCallbacks.cpp | 482 ++- .../gen/CHIPClientCallbacks.h | 37 + .../gen/CHIPClusters.cpp | 245 +- .../gen/callback-stub.cpp | 16 - .../pump-controller-common/gen/callback.h | 13 - .../esp32/main/gen/CHIPClusters.cpp | 1 + .../esp32/main/gen/callback-stub.cpp | 16 - .../esp32/main/gen/callback.h | 13 - .../tv-app/tv-common/gen/CHIPClusters.cpp | 1 + .../tv-app/tv-common/gen/callback-stub.cpp | 16 - examples/tv-app/tv-common/gen/callback.h | 13 - .../window-app/common/gen/CHIPClusters.cpp | 1 + .../window-app/common/gen/callback-stub.cpp | 16 - examples/window-app/common/gen/callback.h | 13 - src/app/AttributePathParams.h | 4 +- src/app/ClusterInfo.h | 2 +- src/app/InteractionModelDelegate.h | 16 + src/app/InteractionModelEngine.cpp | 32 +- src/app/InteractionModelEngine.h | 49 +- src/app/MessageDef/AttributeDataElement.cpp | 33 +- src/app/MessageDef/AttributeDataElement.h | 13 +- src/app/MessageDef/AttributePath.cpp | 4 +- src/app/MessageDef/AttributePath.h | 4 +- src/app/ReadClient.cpp | 54 +- src/app/ReadClient.h | 14 +- src/app/ReadHandler.cpp | 1 - src/app/reporting/Engine.cpp | 10 +- src/app/tests/TestCommandInteraction.cpp | 9 + src/app/tests/TestMessageDef.cpp | 2 +- src/app/tests/TestReadInteraction.cpp | 20 +- src/app/tests/TestReportingEngine.cpp | 7 +- .../tests/integration/chip_im_initiator.cpp | 32 +- .../tests/integration/chip_im_responder.cpp | 7 +- src/app/util/CHIPDeviceCallbacksMgr.cpp | 62 +- src/app/util/CHIPDeviceCallbacksMgr.h | 44 +- .../util/ember-compatibility-functions.cpp | 202 ++ src/app/util/process-global-message.cpp | 80 - .../app/CHIPClientCallbacks-src.zapt | 572 ++-- .../templates/app/CHIPClientCallbacks.zapt | 41 +- .../templates/app/CHIPClusters-src.zapt | 16 +- .../templates/app/callback-stub-src.zapt | 17 - .../zap-templates/templates/app/callback.zapt | 13 - src/controller/CHIPDevice.cpp | 30 +- src/controller/CHIPDevice.h | 12 +- src/controller/CHIPDeviceController.cpp | 16 + src/controller/CHIPDeviceController.h | 4 + .../data_model/gen/CHIPClientCallbacks.cpp | 1995 ++++++----- .../data_model/gen/CHIPClientCallbacks.h | 100 + .../data_model/gen/CHIPClusters.cpp | 3021 ++++++++++++----- .../data_model/gen/callback-stub.cpp | 16 - src/controller/data_model/gen/callback.h | 13 - .../python/chip/clusters/CHIPClusters.cpp | 50 +- .../python/chip/clusters/CHIPClusters.py | 8 +- .../templates/python-CHIPClusters-cpp.zapt | 30 +- .../templates/python-CHIPClusters-py.zapt | 8 +- src/lib/support/FunctionTraits.h | 40 + 73 files changed, 5176 insertions(+), 3199 deletions(-) create mode 100644 src/lib/support/FunctionTraits.h diff --git a/examples/all-clusters-app/all-clusters-common/gen/CHIPClusters.cpp b/examples/all-clusters-app/all-clusters-common/gen/CHIPClusters.cpp index 58bc84801b4b97..2913d05aba8399 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/CHIPClusters.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/CHIPClusters.cpp @@ -21,6 +21,7 @@ #include #include "chip-zcl-zpro-codec-api.h" +#include #include namespace chip { diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp b/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp index d320b277bdf2a8..c9154911858a58 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp @@ -752,22 +752,6 @@ emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, Att uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) {} -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback.h b/examples/all-clusters-app/all-clusters-common/gen/callback.h index da4ba6521ef97b..7c8a3832ff2caf 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback.h +++ b/examples/all-clusters-app/all-clusters-common/gen/callback.h @@ -4722,19 +4722,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/bridge-app/bridge-common/gen/CHIPClusters.cpp b/examples/bridge-app/bridge-common/gen/CHIPClusters.cpp index 58bc84801b4b97..2913d05aba8399 100644 --- a/examples/bridge-app/bridge-common/gen/CHIPClusters.cpp +++ b/examples/bridge-app/bridge-common/gen/CHIPClusters.cpp @@ -21,6 +21,7 @@ #include #include "chip-zcl-zpro-codec-api.h" +#include #include namespace chip { diff --git a/examples/bridge-app/bridge-common/gen/callback-stub.cpp b/examples/bridge-app/bridge-common/gen/callback-stub.cpp index f3c45700872ae2..d7ded3270083ac 100644 --- a/examples/bridge-app/bridge-common/gen/callback-stub.cpp +++ b/examples/bridge-app/bridge-common/gen/callback-stub.cpp @@ -480,22 +480,6 @@ emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, Att uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) {} -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/bridge-app/bridge-common/gen/callback.h b/examples/bridge-app/bridge-common/gen/callback.h index 30b89961e422d7..9f82a69be58df7 100644 --- a/examples/bridge-app/bridge-common/gen/callback.h +++ b/examples/bridge-app/bridge-common/gen/callback.h @@ -1644,19 +1644,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/lighting-app/lighting-common/gen/CHIPClusters.cpp b/examples/lighting-app/lighting-common/gen/CHIPClusters.cpp index 58bc84801b4b97..2913d05aba8399 100644 --- a/examples/lighting-app/lighting-common/gen/CHIPClusters.cpp +++ b/examples/lighting-app/lighting-common/gen/CHIPClusters.cpp @@ -21,6 +21,7 @@ #include #include "chip-zcl-zpro-codec-api.h" +#include #include namespace chip { diff --git a/examples/lighting-app/lighting-common/gen/callback-stub.cpp b/examples/lighting-app/lighting-common/gen/callback-stub.cpp index 4b9136fdfc2505..1c4e6b9304a1fc 100644 --- a/examples/lighting-app/lighting-common/gen/callback-stub.cpp +++ b/examples/lighting-app/lighting-common/gen/callback-stub.cpp @@ -464,22 +464,6 @@ emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, Att uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) {} -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/lighting-app/lighting-common/gen/callback.h b/examples/lighting-app/lighting-common/gen/callback.h index 6ba5e10aac5c2a..59899f6545c720 100644 --- a/examples/lighting-app/lighting-common/gen/callback.h +++ b/examples/lighting-app/lighting-common/gen/callback.h @@ -1490,19 +1490,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/lock-app/lock-common/gen/CHIPClusters.cpp b/examples/lock-app/lock-common/gen/CHIPClusters.cpp index 58bc84801b4b97..2913d05aba8399 100644 --- a/examples/lock-app/lock-common/gen/CHIPClusters.cpp +++ b/examples/lock-app/lock-common/gen/CHIPClusters.cpp @@ -21,6 +21,7 @@ #include #include "chip-zcl-zpro-codec-api.h" +#include #include namespace chip { diff --git a/examples/lock-app/lock-common/gen/callback-stub.cpp b/examples/lock-app/lock-common/gen/callback-stub.cpp index 47bcd263712239..8d0b887cd8bb6e 100644 --- a/examples/lock-app/lock-common/gen/callback-stub.cpp +++ b/examples/lock-app/lock-common/gen/callback-stub.cpp @@ -456,22 +456,6 @@ emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, Att uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) {} -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/lock-app/lock-common/gen/callback.h b/examples/lock-app/lock-common/gen/callback.h index fd5d8ec6147cfe..012c2f9b1ca675 100644 --- a/examples/lock-app/lock-common/gen/callback.h +++ b/examples/lock-app/lock-common/gen/callback.h @@ -1360,19 +1360,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/pump-app/pump-common/gen/CHIPClientCallbacks.cpp b/examples/pump-app/pump-common/gen/CHIPClientCallbacks.cpp index b6d4e79d154630..51eeeb0a86f312 100644 --- a/examples/pump-app/pump-common/gen/CHIPClientCallbacks.cpp +++ b/examples/pump-app/pump-common/gen/CHIPClientCallbacks.cpp @@ -37,7 +37,7 @@ using namespace ::chip::app::List; constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -#define CHECK_STATUS(error) \ +#define CHECK_STATUS_WITH_RETVAL(error, retval) \ if (CHIP_NO_ERROR != error) \ { \ ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ @@ -47,10 +47,13 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } -#define CHECK_MESSAGE_LENGTH(value) \ +#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) +#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) + +#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ if (!chip::CanCastTo(value)) \ { \ ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ @@ -60,7 +63,7 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } \ \ if (messageLen < value) \ @@ -72,11 +75,14 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } \ \ messageLen = static_cast(messageLen - static_cast(value)); +#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) +#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) + #define GET_RESPONSE_CALLBACKS(name) \ Callback::Cancelable * onSuccessCallback = nullptr; \ Callback::Cancelable * onFailureCallback = nullptr; \ @@ -241,6 +247,139 @@ void LogStatus(uint8_t status) } } +static void LogIMStatus(Protocols::InteractionModel::ProtocolCode status) +{ + switch (status) + { + case Protocols::InteractionModel::ProtocolCode::Success: + ChipLogProgress(Zcl, " status: Success (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Failure: + ChipLogProgress(Zcl, " status: Failure (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidSubscription: + ChipLogProgress(Zcl, " status: InvalidSubscription (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedAccess: + ChipLogProgress(Zcl, " status: UnsupportedAccess (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedEndpoint: + ChipLogProgress(Zcl, " status: UnsupportedEndpoint (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidAction: + ChipLogProgress(Zcl, " status: InvalidAction (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedCommand: + ChipLogProgress(Zcl, " status: UnsupportedCommand (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved82: + ChipLogProgress(Zcl, " status: Reserved82 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved83: + ChipLogProgress(Zcl, " status: Reserved83 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved84: + ChipLogProgress(Zcl, " status: Reserved84 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidCommand: + ChipLogProgress(Zcl, " status: InvalidCommand (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedAttribute: + ChipLogProgress(Zcl, " status: UnsupportedAttribute (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidValue: + ChipLogProgress(Zcl, " status: InvalidValue (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedWrite: + ChipLogProgress(Zcl, " status: UnsupportedWrite (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::ResourceExhausted: + ChipLogProgress(Zcl, " status: ResourceExhausted (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved8a: + ChipLogProgress(Zcl, " status: Reserved8a (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::NotFound: + ChipLogProgress(Zcl, " status: NotFound (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnreportableAttribute: + ChipLogProgress(Zcl, " status: UnreportableAttribute (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidDataType: + ChipLogProgress(Zcl, " status: InvalidDataType (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved8e: + ChipLogProgress(Zcl, " status: Reserved8e (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedRead: + ChipLogProgress(Zcl, " status: UnsupportedRead (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved90: + ChipLogProgress(Zcl, " status: Reserved90 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved91: + ChipLogProgress(Zcl, " status: Reserved91 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved92: + ChipLogProgress(Zcl, " status: Reserved92 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved93: + ChipLogProgress(Zcl, " status: Reserved93 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Timeout: + ChipLogProgress(Zcl, " status: Timeout (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved95: + ChipLogProgress(Zcl, " status: Reserved95 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved96: + ChipLogProgress(Zcl, " status: Reserved96 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved97: + ChipLogProgress(Zcl, " status: Reserved97 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved98: + ChipLogProgress(Zcl, " status: Reserved98 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved99: + ChipLogProgress(Zcl, " status: Reserved99 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved9a: + ChipLogProgress(Zcl, " status: Reserved9a (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::ConstraintError: + ChipLogProgress(Zcl, " status: ConstraintError (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Busy: + ChipLogProgress(Zcl, " status: Busy (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc0: + ChipLogProgress(Zcl, " status: Reservedc0 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc1: + ChipLogProgress(Zcl, " status: Reservedc1 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc2: + ChipLogProgress(Zcl, " status: Reservedc2 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedCluster: + ChipLogProgress(Zcl, " status: UnsupportedCluster (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc4: + ChipLogProgress(Zcl, " status: Reservedc4 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::NoUpstreamSubscription: + ChipLogProgress(Zcl, " status: NoUpstreamSubscription (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidArgument: + ChipLogProgress(Zcl, " status: InvalidArgument (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + default: + ChipLogError(Zcl, "Unknown status: 0x%04" PRIx16, Protocols::InteractionModel::ToUint16(status)); + break; + } +} + void LogStringAttribute(const uint8_t * string, const uint16_t length, const bool isAscii) { if (isAscii) @@ -312,259 +451,87 @@ bool IMDefaultResponseCallback(const chip::app::Command * commandObj, EmberAfSta return true; } -bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * message, uint16_t messageLen) +template <> +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure) { - ChipLogProgress(Zcl, "ReadAttributesResponse:"); - ChipLogProgress(Zcl, " ClusterId: 0x%04x", clusterId); + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t * val; + uint32_t len; - GET_RESPONSE_CALLBACKS("emberAfReadAttributesResponseCallback"); - - // struct readAttributeResponseRecord[] - while (messageLen) + if (data->GetType() != chip::TLV::kTLVType_ByteString && data->GetType() != chip::TLV::kTLVType_UTF8String) { - CHECK_MESSAGE_LENGTH(2); - uint16_t attributeId = chip::Encoding::LittleEndian::Read16(message); // attribId - ChipLogProgress(Zcl, " attributeId: 0x%04x", attributeId); - - CHECK_MESSAGE_LENGTH(1); - uint8_t status = chip::Encoding::Read8(message); // zclStatus - LogStatus(status); - - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - CHECK_MESSAGE_LENGTH(1); - uint8_t attributeType = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " attributeType: 0x%02x", attributeType); - - switch (attributeType) - { - case 0x00: // nodata / No data - case 0x0A: // data24 / 24-bit data - case 0x0C: // data40 / 40-bit data - case 0x0D: // data48 / 48-bit data - case 0x0E: // data56 / 56-bit data - case 0x1A: // map24 / 24-bit bitmap - case 0x1C: // map40 / 40-bit bitmap - case 0x1D: // map48 / 48-bit bitmap - case 0x1E: // map56 / 56-bit bitmap - case 0x22: // uint24 / Unsigned 24-bit integer - case 0x24: // uint40 / Unsigned 40-bit integer - case 0x25: // uint48 / Unsigned 48-bit integer - case 0x26: // uint56 / Unsigned 56-bit integer - case 0x2A: // int24 / Signed 24-bit integer - case 0x2C: // int40 / Signed 40-bit integer - case 0x2D: // int48 / Signed 48-bit integer - case 0x2E: // int56 / Signed 56-bit integer - case 0x38: // semi / Semi-precision - case 0x39: // single / Single precision - case 0x3A: // double / Double precision - case 0x49: // struct / Structure - case 0x50: // set / Set - case 0x51: // bag / Bag - case 0xE0: // ToD / Time of day - { - ChipLogError(Zcl, "attributeType 0x%02x is not supported", attributeType); - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - return true; - } - - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - { - // Short Strings must contains at least one byte for the length - CHECK_MESSAGE_LENGTH(1); - uint8_t length = chip::Encoding::Read8(message); - - // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. - if (length == 0xFF) - { - length = 0; - } - - CHECK_MESSAGE_LENGTH(length); - LogStringAttribute(message, length, attributeType == 0x42); - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, chip::ByteSpan(message, length)); - break; - } - - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string - { - // Long Strings must contains at least two bytes for the length - CHECK_MESSAGE_LENGTH(2); - uint16_t length = chip::Encoding::LittleEndian::Read16(message); - - // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. - if (length == 0xFFFF) - { - length = 0; - } - - CHECK_MESSAGE_LENGTH(length); - LogStringAttribute(message, length, attributeType == 0x44); - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, chip::ByteSpan(message, length)); - break; - } - case 0x48: // array / Array - { - CHECK_MESSAGE_LENGTH(2); - uint16_t count = chip::Encoding::LittleEndian::Read16(message); - ChipLogProgress(Zcl, " count: %" PRIu16, count); - - switch (clusterId) - { - } - break; - } - - case 0x08: // data8 / 8-bit data - case 0x18: // map8 / 8-bit bitmap - case 0x20: // uint8 / Unsigned 8-bit integer - case 0x30: // enum8 / 8-bit enumeration - { - CHECK_MESSAGE_LENGTH(1); - uint8_t value = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " value: 0x%02x", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x09: // data16 / 16-bit data - case 0x19: // map16 / 16-bit bitmap - case 0x21: // uint16 / Unsigned 16-bit integer - case 0x31: // enum16 / 16-bit enumeration - case 0xE8: // clusterId / Cluster ID - case 0xE9: // attribId / Attribute ID - case 0xEA: // bacOID / BACnet OID - case 0xF1: // key128 / 128-bit security key - case 0xFF: // unk / Unknown - { - CHECK_MESSAGE_LENGTH(2); - uint16_t value = chip::Encoding::LittleEndian::Read16(message); - ChipLogProgress(Zcl, " value: 0x%04x", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x0B: // data32 / 32-bit data - case 0x1B: // map32 / 32-bit bitmap - case 0x23: // uint32 / Unsigned 32-bit integer - case 0xE1: // date / Date - case 0xE2: // UTC / UTCTime - { - CHECK_MESSAGE_LENGTH(4); - uint32_t value = chip::Encoding::LittleEndian::Read32(message); - ChipLogProgress(Zcl, " value: 0x%08x", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x0F: // data64 / 64-bit data - case 0x1F: // map64 / 64-bit bitmap - case 0x27: // uint64 / Unsigned 64-bit integer - case 0xF0: // EUI64 / IEEE address - { - CHECK_MESSAGE_LENGTH(8); - uint64_t value = chip::Encoding::LittleEndian::Read64(message); - ChipLogProgress(Zcl, " value: 0x" ChipLogFormatX64, ChipLogValueX64(value)); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x10: // bool / Boolean - { - CHECK_MESSAGE_LENGTH(1); - uint8_t value = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " value: %d", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } + err = CHIP_ERROR_INVALID_ARGUMENT; + } + else + { + err = data->GetDataPtr(val); + len = data->GetLength(); + } - case 0x28: // int8 / Signed 8-bit integer - { - CHECK_MESSAGE_LENGTH(1); - int8_t value = chip::CastToSigned(chip::Encoding::Read8(message)); - ChipLogProgress(Zcl, " value: %" PRId8, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } + if (CHIP_NO_ERROR == err) + { + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onSuccess); + cb->mCall(cb->mContext, chip::ByteSpan(val, len)); + } + else + { + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onFailure); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } +} - case 0x29: // int16 / Signed 16-bit integer - { - CHECK_MESSAGE_LENGTH(2); - int16_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read16(message)); - ChipLogProgress(Zcl, " value: %" PRId16, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } +bool IMReadReportAttributesResponseCallback(const app::ReadClient * apReadClient, const app::ClusterInfo & aPath, + TLV::TLVReader * apData, Protocols::InteractionModel::ProtocolCode status) +{ + ChipLogProgress(Zcl, "ReadAttributesResponse:"); + ChipLogProgress(Zcl, " ClusterId: 0x%04x", aPath.mClusterId); - case 0x2B: // int32 / Signed 32-bit integer - { - CHECK_MESSAGE_LENGTH(4); - int32_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read32(message)); - ChipLogProgress(Zcl, " value: %" PRId32, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } + Callback::Cancelable * onSuccessCallback = nullptr; + Callback::Cancelable * onFailureCallback = nullptr; + app::TLVDataFilter tlvFilter = nullptr; + NodeId sourceId = aPath.mNodeId; + // In CHIPClusters.cpp, we are using sequenceNumber as application identifier. + uint8_t sequenceNumber = static_cast(apReadClient->GetAppIdentifier()); + CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback, &tlvFilter); - case 0x2F: // int64 / Signed 64-bit integer - { - CHECK_MESSAGE_LENGTH(8); - int64_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read64(message)); - ChipLogProgress(Zcl, " value: %" PRId64, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - } + if (CHIP_NO_ERROR != err) + { + if (onSuccessCallback == nullptr) + { + ChipLogDetail(Zcl, "%s: Missing success callback", __FUNCTION__); } - else + + if (onFailureCallback == nullptr) { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, status); + ChipLogDetail(Zcl, "%s: Missing failure callback", __FUNCTION__); } - // The current code is written matching the current API where there is a single attribute read - // per read command. So if multiple attributes are read at the same time, something is wrong - // somewhere. - if (messageLen) + if (tlvFilter == nullptr) { - ChipLogError(Zcl, "Multiple attributes read at the same time. Something went wrong."); - break; + ChipLogDetail(Zcl, "%s: Missing TLV Data Filter", __FUNCTION__); } + return true; + } + + uint16_t attributeId = aPath.mFieldId; // attribId + ChipLogProgress(Zcl, " attributeId: 0x%04x", attributeId); + LogIMStatus(status); + + if (status == Protocols::InteractionModel::ProtocolCode::Success && apData != nullptr) + { + chip::TLV::TLVType attributeType = apData->GetType(); + ChipLogProgress(Zcl, " attribute TLV Type: 0x%02x", attributeType); + tlvFilter(apData, onSuccessCallback, onFailureCallback); + } + else + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + // TODO: Should change failure callbacks to accept uint16 status code. + cb->mCall(cb->mContext, static_cast(Protocols::InteractionModel::ToUint16(status))); } return true; @@ -782,6 +749,31 @@ bool emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16 return true; } +static EmberAfStatus PrepareListFromTLV(TLV::TLVReader * tlvData, const uint8_t *& message, uint16_t & messageLen) +{ + CHIP_ERROR tlvError = CHIP_NO_ERROR; + TLV::TLVReader reader; + TLV::TLVType type; + reader.Init(*tlvData); + reader.EnterContainer(type); + tlvError = reader.Next(); + if (tlvError != CHIP_NO_ERROR && tlvError != CHIP_END_OF_TLV && chip::CanCastTo(reader.GetLength())) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + if (tlvError == CHIP_NO_ERROR) + { + tlvError = reader.GetDataPtr(message); + messageLen = static_cast(reader.GetLength()); + } + if (tlvError != CHIP_NO_ERROR) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + reader.ExitContainer(type); + return EMBER_ZCL_STATUS_SUCCESS; +} + bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uint16_t messageLen) { ChipLogProgress(Zcl, "emberAfReportAttributeCallback:"); diff --git a/examples/pump-app/pump-common/gen/CHIPClientCallbacks.h b/examples/pump-app/pump-common/gen/CHIPClientCallbacks.h index dfbf602efc90f0..f83f7fa2d10158 100644 --- a/examples/pump-app/pump-common/gen/CHIPClientCallbacks.h +++ b/examples/pump-app/pump-common/gen/CHIPClientCallbacks.h @@ -20,15 +20,19 @@ #pragma once #include +#include #include #include #include +#include #include // Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus // instead of IM status code. // #6308 should handle IM error code on the application side, either modify this function or remove this. bool IMDefaultResponseCallback(const chip::app::Command * commandObj, EmberAfStatus status); +bool IMReadReportAttributesResponseCallback(const chip::app::ReadClient * apReadClient, const chip::app::ClusterInfo & aPath, + chip::TLV::TLVReader * apData, chip::Protocols::InteractionModel::ProtocolCode status); // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -43,6 +47,39 @@ typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); +typedef void (*AttributeResponseFilter)(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure); + +/** + * BasicAttributeFilter accepts the actual type of onSuccess callback as template parameter. + * It will check whether the type of the TLV data is expected by onSuccess callback. + * If a non expected value received, onFailure callback will be called with EMBER_ZCL_STATUS_INVALID_VALUE. + */ +template +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + typename chip::FunctionTraits::template ArgType<1> value; + + if ((err = data->Get(value)) == CHIP_NO_ERROR) + { + chip::Callback::Callback * cb = chip::Callback::Callback::FromCancelable(onSuccess); + cb->mCall(cb->mContext, value); + } + else + { + ChipLogError(Zcl, "Failed to get value from TLV data for attribute reading response: %d", err); + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onFailure); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } +} + +template <> +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure); + typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); diff --git a/examples/pump-app/pump-common/gen/CHIPClusters.cpp b/examples/pump-app/pump-common/gen/CHIPClusters.cpp index 35ac7fd528e3e0..515cdb50c2898b 100644 --- a/examples/pump-app/pump-common/gen/CHIPClusters.cpp +++ b/examples/pump-app/pump-common/gen/CHIPClusters.cpp @@ -21,6 +21,7 @@ #include #include "chip-zcl-zpro-codec-api.h" +#include #include namespace chip { @@ -42,9 +43,13 @@ CHIP_ERROR FlowMeasurementCluster::DiscoverAttributes(Callback::Cancelable * onS CHIP_ERROR FlowMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeFlowMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR FlowMeasurementCluster::ConfigureAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, @@ -65,25 +70,37 @@ CHIP_ERROR FlowMeasurementCluster::ReportAttributeMeasuredValue(Callback::Cancel CHIP_ERROR FlowMeasurementCluster::ReadAttributeMinMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeFlowMeasurementClusterReadMinMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR FlowMeasurementCluster::ReadAttributeMaxMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeFlowMeasurementClusterReadMaxMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR FlowMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeFlowMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // PressureMeasurement Cluster Commands @@ -98,9 +115,13 @@ CHIP_ERROR PressureMeasurementCluster::DiscoverAttributes(Callback::Cancelable * CHIP_ERROR PressureMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PressureMeasurementCluster::ConfigureAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, @@ -121,25 +142,37 @@ CHIP_ERROR PressureMeasurementCluster::ReportAttributeMeasuredValue(Callback::Ca CHIP_ERROR PressureMeasurementCluster::ReadAttributeMinMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadMinMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PressureMeasurementCluster::ReadAttributeMaxMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadMaxMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PressureMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // TemperatureMeasurement Cluster Commands @@ -154,9 +187,13 @@ CHIP_ERROR TemperatureMeasurementCluster::DiscoverAttributes(Callback::Cancelabl CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TemperatureMeasurementCluster::ConfigureAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, @@ -178,25 +215,37 @@ CHIP_ERROR TemperatureMeasurementCluster::ReportAttributeMeasuredValue(Callback: CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMinMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMinMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMaxMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMaxMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } } // namespace Controller diff --git a/examples/pump-app/pump-common/gen/callback-stub.cpp b/examples/pump-app/pump-common/gen/callback-stub.cpp index 139792334c93a2..be9d9900d5fdce 100644 --- a/examples/pump-app/pump-common/gen/callback-stub.cpp +++ b/examples/pump-app/pump-common/gen/callback-stub.cpp @@ -496,22 +496,6 @@ emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, Att uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) {} -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/pump-app/pump-common/gen/callback.h b/examples/pump-app/pump-common/gen/callback.h index c5335e6b03822b..2ce79f41938211 100644 --- a/examples/pump-app/pump-common/gen/callback.h +++ b/examples/pump-app/pump-common/gen/callback.h @@ -2019,19 +2019,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/pump-controller-app/pump-controller-common/gen/CHIPClientCallbacks.cpp b/examples/pump-controller-app/pump-controller-common/gen/CHIPClientCallbacks.cpp index b6d4e79d154630..51eeeb0a86f312 100644 --- a/examples/pump-controller-app/pump-controller-common/gen/CHIPClientCallbacks.cpp +++ b/examples/pump-controller-app/pump-controller-common/gen/CHIPClientCallbacks.cpp @@ -37,7 +37,7 @@ using namespace ::chip::app::List; constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -#define CHECK_STATUS(error) \ +#define CHECK_STATUS_WITH_RETVAL(error, retval) \ if (CHIP_NO_ERROR != error) \ { \ ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ @@ -47,10 +47,13 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } -#define CHECK_MESSAGE_LENGTH(value) \ +#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) +#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) + +#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ if (!chip::CanCastTo(value)) \ { \ ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ @@ -60,7 +63,7 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } \ \ if (messageLen < value) \ @@ -72,11 +75,14 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } \ \ messageLen = static_cast(messageLen - static_cast(value)); +#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) +#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) + #define GET_RESPONSE_CALLBACKS(name) \ Callback::Cancelable * onSuccessCallback = nullptr; \ Callback::Cancelable * onFailureCallback = nullptr; \ @@ -241,6 +247,139 @@ void LogStatus(uint8_t status) } } +static void LogIMStatus(Protocols::InteractionModel::ProtocolCode status) +{ + switch (status) + { + case Protocols::InteractionModel::ProtocolCode::Success: + ChipLogProgress(Zcl, " status: Success (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Failure: + ChipLogProgress(Zcl, " status: Failure (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidSubscription: + ChipLogProgress(Zcl, " status: InvalidSubscription (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedAccess: + ChipLogProgress(Zcl, " status: UnsupportedAccess (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedEndpoint: + ChipLogProgress(Zcl, " status: UnsupportedEndpoint (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidAction: + ChipLogProgress(Zcl, " status: InvalidAction (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedCommand: + ChipLogProgress(Zcl, " status: UnsupportedCommand (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved82: + ChipLogProgress(Zcl, " status: Reserved82 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved83: + ChipLogProgress(Zcl, " status: Reserved83 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved84: + ChipLogProgress(Zcl, " status: Reserved84 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidCommand: + ChipLogProgress(Zcl, " status: InvalidCommand (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedAttribute: + ChipLogProgress(Zcl, " status: UnsupportedAttribute (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidValue: + ChipLogProgress(Zcl, " status: InvalidValue (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedWrite: + ChipLogProgress(Zcl, " status: UnsupportedWrite (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::ResourceExhausted: + ChipLogProgress(Zcl, " status: ResourceExhausted (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved8a: + ChipLogProgress(Zcl, " status: Reserved8a (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::NotFound: + ChipLogProgress(Zcl, " status: NotFound (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnreportableAttribute: + ChipLogProgress(Zcl, " status: UnreportableAttribute (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidDataType: + ChipLogProgress(Zcl, " status: InvalidDataType (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved8e: + ChipLogProgress(Zcl, " status: Reserved8e (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedRead: + ChipLogProgress(Zcl, " status: UnsupportedRead (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved90: + ChipLogProgress(Zcl, " status: Reserved90 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved91: + ChipLogProgress(Zcl, " status: Reserved91 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved92: + ChipLogProgress(Zcl, " status: Reserved92 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved93: + ChipLogProgress(Zcl, " status: Reserved93 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Timeout: + ChipLogProgress(Zcl, " status: Timeout (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved95: + ChipLogProgress(Zcl, " status: Reserved95 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved96: + ChipLogProgress(Zcl, " status: Reserved96 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved97: + ChipLogProgress(Zcl, " status: Reserved97 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved98: + ChipLogProgress(Zcl, " status: Reserved98 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved99: + ChipLogProgress(Zcl, " status: Reserved99 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved9a: + ChipLogProgress(Zcl, " status: Reserved9a (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::ConstraintError: + ChipLogProgress(Zcl, " status: ConstraintError (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Busy: + ChipLogProgress(Zcl, " status: Busy (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc0: + ChipLogProgress(Zcl, " status: Reservedc0 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc1: + ChipLogProgress(Zcl, " status: Reservedc1 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc2: + ChipLogProgress(Zcl, " status: Reservedc2 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedCluster: + ChipLogProgress(Zcl, " status: UnsupportedCluster (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc4: + ChipLogProgress(Zcl, " status: Reservedc4 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::NoUpstreamSubscription: + ChipLogProgress(Zcl, " status: NoUpstreamSubscription (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidArgument: + ChipLogProgress(Zcl, " status: InvalidArgument (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + default: + ChipLogError(Zcl, "Unknown status: 0x%04" PRIx16, Protocols::InteractionModel::ToUint16(status)); + break; + } +} + void LogStringAttribute(const uint8_t * string, const uint16_t length, const bool isAscii) { if (isAscii) @@ -312,259 +451,87 @@ bool IMDefaultResponseCallback(const chip::app::Command * commandObj, EmberAfSta return true; } -bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * message, uint16_t messageLen) +template <> +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure) { - ChipLogProgress(Zcl, "ReadAttributesResponse:"); - ChipLogProgress(Zcl, " ClusterId: 0x%04x", clusterId); + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t * val; + uint32_t len; - GET_RESPONSE_CALLBACKS("emberAfReadAttributesResponseCallback"); - - // struct readAttributeResponseRecord[] - while (messageLen) + if (data->GetType() != chip::TLV::kTLVType_ByteString && data->GetType() != chip::TLV::kTLVType_UTF8String) { - CHECK_MESSAGE_LENGTH(2); - uint16_t attributeId = chip::Encoding::LittleEndian::Read16(message); // attribId - ChipLogProgress(Zcl, " attributeId: 0x%04x", attributeId); - - CHECK_MESSAGE_LENGTH(1); - uint8_t status = chip::Encoding::Read8(message); // zclStatus - LogStatus(status); - - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - CHECK_MESSAGE_LENGTH(1); - uint8_t attributeType = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " attributeType: 0x%02x", attributeType); - - switch (attributeType) - { - case 0x00: // nodata / No data - case 0x0A: // data24 / 24-bit data - case 0x0C: // data40 / 40-bit data - case 0x0D: // data48 / 48-bit data - case 0x0E: // data56 / 56-bit data - case 0x1A: // map24 / 24-bit bitmap - case 0x1C: // map40 / 40-bit bitmap - case 0x1D: // map48 / 48-bit bitmap - case 0x1E: // map56 / 56-bit bitmap - case 0x22: // uint24 / Unsigned 24-bit integer - case 0x24: // uint40 / Unsigned 40-bit integer - case 0x25: // uint48 / Unsigned 48-bit integer - case 0x26: // uint56 / Unsigned 56-bit integer - case 0x2A: // int24 / Signed 24-bit integer - case 0x2C: // int40 / Signed 40-bit integer - case 0x2D: // int48 / Signed 48-bit integer - case 0x2E: // int56 / Signed 56-bit integer - case 0x38: // semi / Semi-precision - case 0x39: // single / Single precision - case 0x3A: // double / Double precision - case 0x49: // struct / Structure - case 0x50: // set / Set - case 0x51: // bag / Bag - case 0xE0: // ToD / Time of day - { - ChipLogError(Zcl, "attributeType 0x%02x is not supported", attributeType); - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - return true; - } - - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - { - // Short Strings must contains at least one byte for the length - CHECK_MESSAGE_LENGTH(1); - uint8_t length = chip::Encoding::Read8(message); - - // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. - if (length == 0xFF) - { - length = 0; - } - - CHECK_MESSAGE_LENGTH(length); - LogStringAttribute(message, length, attributeType == 0x42); - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, chip::ByteSpan(message, length)); - break; - } - - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string - { - // Long Strings must contains at least two bytes for the length - CHECK_MESSAGE_LENGTH(2); - uint16_t length = chip::Encoding::LittleEndian::Read16(message); - - // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. - if (length == 0xFFFF) - { - length = 0; - } - - CHECK_MESSAGE_LENGTH(length); - LogStringAttribute(message, length, attributeType == 0x44); - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, chip::ByteSpan(message, length)); - break; - } - case 0x48: // array / Array - { - CHECK_MESSAGE_LENGTH(2); - uint16_t count = chip::Encoding::LittleEndian::Read16(message); - ChipLogProgress(Zcl, " count: %" PRIu16, count); - - switch (clusterId) - { - } - break; - } - - case 0x08: // data8 / 8-bit data - case 0x18: // map8 / 8-bit bitmap - case 0x20: // uint8 / Unsigned 8-bit integer - case 0x30: // enum8 / 8-bit enumeration - { - CHECK_MESSAGE_LENGTH(1); - uint8_t value = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " value: 0x%02x", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x09: // data16 / 16-bit data - case 0x19: // map16 / 16-bit bitmap - case 0x21: // uint16 / Unsigned 16-bit integer - case 0x31: // enum16 / 16-bit enumeration - case 0xE8: // clusterId / Cluster ID - case 0xE9: // attribId / Attribute ID - case 0xEA: // bacOID / BACnet OID - case 0xF1: // key128 / 128-bit security key - case 0xFF: // unk / Unknown - { - CHECK_MESSAGE_LENGTH(2); - uint16_t value = chip::Encoding::LittleEndian::Read16(message); - ChipLogProgress(Zcl, " value: 0x%04x", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x0B: // data32 / 32-bit data - case 0x1B: // map32 / 32-bit bitmap - case 0x23: // uint32 / Unsigned 32-bit integer - case 0xE1: // date / Date - case 0xE2: // UTC / UTCTime - { - CHECK_MESSAGE_LENGTH(4); - uint32_t value = chip::Encoding::LittleEndian::Read32(message); - ChipLogProgress(Zcl, " value: 0x%08x", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x0F: // data64 / 64-bit data - case 0x1F: // map64 / 64-bit bitmap - case 0x27: // uint64 / Unsigned 64-bit integer - case 0xF0: // EUI64 / IEEE address - { - CHECK_MESSAGE_LENGTH(8); - uint64_t value = chip::Encoding::LittleEndian::Read64(message); - ChipLogProgress(Zcl, " value: 0x" ChipLogFormatX64, ChipLogValueX64(value)); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x10: // bool / Boolean - { - CHECK_MESSAGE_LENGTH(1); - uint8_t value = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " value: %d", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } + err = CHIP_ERROR_INVALID_ARGUMENT; + } + else + { + err = data->GetDataPtr(val); + len = data->GetLength(); + } - case 0x28: // int8 / Signed 8-bit integer - { - CHECK_MESSAGE_LENGTH(1); - int8_t value = chip::CastToSigned(chip::Encoding::Read8(message)); - ChipLogProgress(Zcl, " value: %" PRId8, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } + if (CHIP_NO_ERROR == err) + { + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onSuccess); + cb->mCall(cb->mContext, chip::ByteSpan(val, len)); + } + else + { + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onFailure); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } +} - case 0x29: // int16 / Signed 16-bit integer - { - CHECK_MESSAGE_LENGTH(2); - int16_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read16(message)); - ChipLogProgress(Zcl, " value: %" PRId16, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } +bool IMReadReportAttributesResponseCallback(const app::ReadClient * apReadClient, const app::ClusterInfo & aPath, + TLV::TLVReader * apData, Protocols::InteractionModel::ProtocolCode status) +{ + ChipLogProgress(Zcl, "ReadAttributesResponse:"); + ChipLogProgress(Zcl, " ClusterId: 0x%04x", aPath.mClusterId); - case 0x2B: // int32 / Signed 32-bit integer - { - CHECK_MESSAGE_LENGTH(4); - int32_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read32(message)); - ChipLogProgress(Zcl, " value: %" PRId32, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } + Callback::Cancelable * onSuccessCallback = nullptr; + Callback::Cancelable * onFailureCallback = nullptr; + app::TLVDataFilter tlvFilter = nullptr; + NodeId sourceId = aPath.mNodeId; + // In CHIPClusters.cpp, we are using sequenceNumber as application identifier. + uint8_t sequenceNumber = static_cast(apReadClient->GetAppIdentifier()); + CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback, &tlvFilter); - case 0x2F: // int64 / Signed 64-bit integer - { - CHECK_MESSAGE_LENGTH(8); - int64_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read64(message)); - ChipLogProgress(Zcl, " value: %" PRId64, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - } + if (CHIP_NO_ERROR != err) + { + if (onSuccessCallback == nullptr) + { + ChipLogDetail(Zcl, "%s: Missing success callback", __FUNCTION__); } - else + + if (onFailureCallback == nullptr) { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, status); + ChipLogDetail(Zcl, "%s: Missing failure callback", __FUNCTION__); } - // The current code is written matching the current API where there is a single attribute read - // per read command. So if multiple attributes are read at the same time, something is wrong - // somewhere. - if (messageLen) + if (tlvFilter == nullptr) { - ChipLogError(Zcl, "Multiple attributes read at the same time. Something went wrong."); - break; + ChipLogDetail(Zcl, "%s: Missing TLV Data Filter", __FUNCTION__); } + return true; + } + + uint16_t attributeId = aPath.mFieldId; // attribId + ChipLogProgress(Zcl, " attributeId: 0x%04x", attributeId); + LogIMStatus(status); + + if (status == Protocols::InteractionModel::ProtocolCode::Success && apData != nullptr) + { + chip::TLV::TLVType attributeType = apData->GetType(); + ChipLogProgress(Zcl, " attribute TLV Type: 0x%02x", attributeType); + tlvFilter(apData, onSuccessCallback, onFailureCallback); + } + else + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + // TODO: Should change failure callbacks to accept uint16 status code. + cb->mCall(cb->mContext, static_cast(Protocols::InteractionModel::ToUint16(status))); } return true; @@ -782,6 +749,31 @@ bool emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16 return true; } +static EmberAfStatus PrepareListFromTLV(TLV::TLVReader * tlvData, const uint8_t *& message, uint16_t & messageLen) +{ + CHIP_ERROR tlvError = CHIP_NO_ERROR; + TLV::TLVReader reader; + TLV::TLVType type; + reader.Init(*tlvData); + reader.EnterContainer(type); + tlvError = reader.Next(); + if (tlvError != CHIP_NO_ERROR && tlvError != CHIP_END_OF_TLV && chip::CanCastTo(reader.GetLength())) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + if (tlvError == CHIP_NO_ERROR) + { + tlvError = reader.GetDataPtr(message); + messageLen = static_cast(reader.GetLength()); + } + if (tlvError != CHIP_NO_ERROR) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + reader.ExitContainer(type); + return EMBER_ZCL_STATUS_SUCCESS; +} + bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uint16_t messageLen) { ChipLogProgress(Zcl, "emberAfReportAttributeCallback:"); diff --git a/examples/pump-controller-app/pump-controller-common/gen/CHIPClientCallbacks.h b/examples/pump-controller-app/pump-controller-common/gen/CHIPClientCallbacks.h index dfbf602efc90f0..f83f7fa2d10158 100644 --- a/examples/pump-controller-app/pump-controller-common/gen/CHIPClientCallbacks.h +++ b/examples/pump-controller-app/pump-controller-common/gen/CHIPClientCallbacks.h @@ -20,15 +20,19 @@ #pragma once #include +#include #include #include #include +#include #include // Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus // instead of IM status code. // #6308 should handle IM error code on the application side, either modify this function or remove this. bool IMDefaultResponseCallback(const chip::app::Command * commandObj, EmberAfStatus status); +bool IMReadReportAttributesResponseCallback(const chip::app::ReadClient * apReadClient, const chip::app::ClusterInfo & aPath, + chip::TLV::TLVReader * apData, chip::Protocols::InteractionModel::ProtocolCode status); // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -43,6 +47,39 @@ typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); +typedef void (*AttributeResponseFilter)(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure); + +/** + * BasicAttributeFilter accepts the actual type of onSuccess callback as template parameter. + * It will check whether the type of the TLV data is expected by onSuccess callback. + * If a non expected value received, onFailure callback will be called with EMBER_ZCL_STATUS_INVALID_VALUE. + */ +template +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + typename chip::FunctionTraits::template ArgType<1> value; + + if ((err = data->Get(value)) == CHIP_NO_ERROR) + { + chip::Callback::Callback * cb = chip::Callback::Callback::FromCancelable(onSuccess); + cb->mCall(cb->mContext, value); + } + else + { + ChipLogError(Zcl, "Failed to get value from TLV data for attribute reading response: %d", err); + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onFailure); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } +} + +template <> +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure); + typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); diff --git a/examples/pump-controller-app/pump-controller-common/gen/CHIPClusters.cpp b/examples/pump-controller-app/pump-controller-common/gen/CHIPClusters.cpp index 83564fc9bd57a4..883474e4787809 100644 --- a/examples/pump-controller-app/pump-controller-common/gen/CHIPClusters.cpp +++ b/examples/pump-controller-app/pump-controller-common/gen/CHIPClusters.cpp @@ -21,6 +21,7 @@ #include #include "chip-zcl-zpro-codec-api.h" +#include #include namespace chip { @@ -42,9 +43,13 @@ CHIP_ERROR FlowMeasurementCluster::DiscoverAttributes(Callback::Cancelable * onS CHIP_ERROR FlowMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeFlowMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR FlowMeasurementCluster::ConfigureAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, @@ -65,25 +70,37 @@ CHIP_ERROR FlowMeasurementCluster::ReportAttributeMeasuredValue(Callback::Cancel CHIP_ERROR FlowMeasurementCluster::ReadAttributeMinMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeFlowMeasurementClusterReadMinMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR FlowMeasurementCluster::ReadAttributeMaxMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeFlowMeasurementClusterReadMaxMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR FlowMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeFlowMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // LevelControl Cluster Commands @@ -455,9 +472,13 @@ CHIP_ERROR LevelControlCluster::DiscoverAttributes(Callback::Cancelable * onSucc CHIP_ERROR LevelControlCluster::ReadAttributeCurrentLevel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeLevelControlClusterReadCurrentLevelAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR LevelControlCluster::ConfigureAttributeCurrentLevel(Callback::Cancelable * onSuccessCallback, @@ -478,9 +499,13 @@ CHIP_ERROR LevelControlCluster::ReportAttributeCurrentLevel(Callback::Cancelable CHIP_ERROR LevelControlCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeLevelControlClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // OnOff Cluster Commands @@ -607,17 +632,25 @@ CHIP_ERROR OnOffCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCall } CHIP_ERROR OnOffCluster::ReadAttributeOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadOnOffAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR OnOffCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // PressureMeasurement Cluster Commands @@ -632,9 +665,13 @@ CHIP_ERROR PressureMeasurementCluster::DiscoverAttributes(Callback::Cancelable * CHIP_ERROR PressureMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PressureMeasurementCluster::ConfigureAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, @@ -655,25 +692,37 @@ CHIP_ERROR PressureMeasurementCluster::ReportAttributeMeasuredValue(Callback::Ca CHIP_ERROR PressureMeasurementCluster::ReadAttributeMinMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadMinMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PressureMeasurementCluster::ReadAttributeMaxMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadMaxMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PressureMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // PumpConfigurationAndControl Cluster Commands @@ -688,51 +737,73 @@ CHIP_ERROR PumpConfigurationAndControlCluster::DiscoverAttributes(Callback::Canc CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeMaxPressure(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadMaxPressureAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeMaxSpeed(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadMaxSpeedAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeMaxFlow(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadMaxFlowAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeEffectiveOperationMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodePumpConfigurationAndControlClusterReadEffectiveOperationModeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0011; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeEffectiveControlMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodePumpConfigurationAndControlClusterReadEffectiveControlModeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0012; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeCapacity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadCapacityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0013; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ConfigureAttributeCapacity(Callback::Cancelable * onSuccessCallback, @@ -754,10 +825,13 @@ CHIP_ERROR PumpConfigurationAndControlCluster::ReportAttributeCapacity(Callback: CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeOperationMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodePumpConfigurationAndControlClusterReadOperationModeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0020; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::WriteAttributeOperationMode(Callback::Cancelable * onSuccessCallback, @@ -772,10 +846,13 @@ CHIP_ERROR PumpConfigurationAndControlCluster::WriteAttributeOperationMode(Callb CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodePumpConfigurationAndControlClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // TemperatureMeasurement Cluster Commands @@ -790,9 +867,13 @@ CHIP_ERROR TemperatureMeasurementCluster::DiscoverAttributes(Callback::Cancelabl CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TemperatureMeasurementCluster::ConfigureAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, @@ -814,25 +895,37 @@ CHIP_ERROR TemperatureMeasurementCluster::ReportAttributeMeasuredValue(Callback: CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMinMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMinMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMaxMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMaxMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } } // namespace Controller diff --git a/examples/pump-controller-app/pump-controller-common/gen/callback-stub.cpp b/examples/pump-controller-app/pump-controller-common/gen/callback-stub.cpp index 139792334c93a2..be9d9900d5fdce 100644 --- a/examples/pump-controller-app/pump-controller-common/gen/callback-stub.cpp +++ b/examples/pump-controller-app/pump-controller-common/gen/callback-stub.cpp @@ -496,22 +496,6 @@ emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, Att uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) {} -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/pump-controller-app/pump-controller-common/gen/callback.h b/examples/pump-controller-app/pump-controller-common/gen/callback.h index 9226d6345f2fa2..d411214facd438 100644 --- a/examples/pump-controller-app/pump-controller-common/gen/callback.h +++ b/examples/pump-controller-app/pump-controller-common/gen/callback.h @@ -1742,19 +1742,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/temperature-measurement-app/esp32/main/gen/CHIPClusters.cpp b/examples/temperature-measurement-app/esp32/main/gen/CHIPClusters.cpp index 58bc84801b4b97..2913d05aba8399 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/CHIPClusters.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/CHIPClusters.cpp @@ -21,6 +21,7 @@ #include #include "chip-zcl-zpro-codec-api.h" +#include #include namespace chip { diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp b/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp index 5eee779386c36d..39f4f643af77cd 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp @@ -448,22 +448,6 @@ emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, Att uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) {} -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback.h b/examples/temperature-measurement-app/esp32/main/gen/callback.h index 37379312b4ad62..d7a3ea57930e0b 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback.h +++ b/examples/temperature-measurement-app/esp32/main/gen/callback.h @@ -1251,19 +1251,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/tv-app/tv-common/gen/CHIPClusters.cpp b/examples/tv-app/tv-common/gen/CHIPClusters.cpp index 58bc84801b4b97..2913d05aba8399 100644 --- a/examples/tv-app/tv-common/gen/CHIPClusters.cpp +++ b/examples/tv-app/tv-common/gen/CHIPClusters.cpp @@ -21,6 +21,7 @@ #include #include "chip-zcl-zpro-codec-api.h" +#include #include namespace chip { diff --git a/examples/tv-app/tv-common/gen/callback-stub.cpp b/examples/tv-app/tv-common/gen/callback-stub.cpp index aa7450e935f217..b24fffba103cc9 100644 --- a/examples/tv-app/tv-common/gen/callback-stub.cpp +++ b/examples/tv-app/tv-common/gen/callback-stub.cpp @@ -600,22 +600,6 @@ emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, Att uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) {} -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/tv-app/tv-common/gen/callback.h b/examples/tv-app/tv-common/gen/callback.h index e8772aefd46826..1b8b83a9ceeeaa 100644 --- a/examples/tv-app/tv-common/gen/callback.h +++ b/examples/tv-app/tv-common/gen/callback.h @@ -2954,19 +2954,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/window-app/common/gen/CHIPClusters.cpp b/examples/window-app/common/gen/CHIPClusters.cpp index 58bc84801b4b97..2913d05aba8399 100644 --- a/examples/window-app/common/gen/CHIPClusters.cpp +++ b/examples/window-app/common/gen/CHIPClusters.cpp @@ -21,6 +21,7 @@ #include #include "chip-zcl-zpro-codec-api.h" +#include #include namespace chip { diff --git a/examples/window-app/common/gen/callback-stub.cpp b/examples/window-app/common/gen/callback-stub.cpp index ccfcc4c270b7bd..ef54b18b1813b5 100644 --- a/examples/window-app/common/gen/callback-stub.cpp +++ b/examples/window-app/common/gen/callback-stub.cpp @@ -448,22 +448,6 @@ emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, Att uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) {} -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/examples/window-app/common/gen/callback.h b/examples/window-app/common/gen/callback.h index 015ea0a10680c1..10c98ba26070fd 100644 --- a/examples/window-app/common/gen/callback.h +++ b/examples/window-app/common/gen/callback.h @@ -1303,19 +1303,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/src/app/AttributePathParams.h b/src/app/AttributePathParams.h index 9350dd329c1b99..6c96c0dc0102e9 100644 --- a/src/app/AttributePathParams.h +++ b/src/app/AttributePathParams.h @@ -31,7 +31,7 @@ struct AttributePathParams kListIndexValid = 0x02, }; - AttributePathParams(NodeId aNodeId, EndpointId aEndpointId, ClusterId aClusterId, FieldId aFieldId, ListIndex aListIndex, + AttributePathParams(NodeId aNodeId, EndpointId aEndpointId, ClusterId aClusterId, AttributeId aFieldId, ListIndex aListIndex, const BitFlags aFlags) : mNodeId(aNodeId), mEndpointId(aEndpointId), mClusterId(aClusterId), mFieldId(aFieldId), mListIndex(aListIndex), mFlags(aFlags) @@ -40,7 +40,7 @@ struct AttributePathParams NodeId mNodeId = 0; EndpointId mEndpointId = 0; ClusterId mClusterId = 0; - FieldId mFieldId = 0; + AttributeId mFieldId = 0; ListIndex mListIndex = 0; BitFlags mFlags; }; diff --git a/src/app/ClusterInfo.h b/src/app/ClusterInfo.h index 77284f3750d2ca..ba646c20780730 100644 --- a/src/app/ClusterInfo.h +++ b/src/app/ClusterInfo.h @@ -39,7 +39,7 @@ struct ClusterInfo NodeId mNodeId = 0; ClusterId mClusterId = 0; ListIndex mListIndex = 0; - FieldId mFieldId = 0; + AttributeId mFieldId = 0; EndpointId mEndpointId = 0; bool mDirty = false; BitFlags mFlags; diff --git a/src/app/InteractionModelDelegate.h b/src/app/InteractionModelDelegate.h index e9f8165643e801..48540f9dc08324 100644 --- a/src/app/InteractionModelDelegate.h +++ b/src/app/InteractionModelDelegate.h @@ -24,6 +24,7 @@ #pragma once #include +#include #include #include #include @@ -62,6 +63,21 @@ class InteractionModelDelegate return CHIP_ERROR_NOT_IMPLEMENTED; } + /** + * Notification that the interaction model has received a list of attribute data in response to a Read request. apData might be + * nullptr if status is not ProtocolCode::Success. + * + * @param[in] apReadClient The read client object, the application can use GetAppIdentifier() for the read client to + * distinguish different read requests. + * @param[in] aPath The path of the attribute, contains node id, endpoint id, cluster id, field id etc. + * @param[in] apData The attribute data TLV + * @param[in] status Interaction model status code + * + */ + virtual void OnReportData(const ReadClient * apReadClient, const ClusterInfo & aPath, TLV::TLVReader * apData, + Protocols::InteractionModel::ProtocolCode status) + {} + /** * Notification that the last message for a Report Data action for the given ReadClient has been received and processed. * @param[in] apReadClient A current readClient which can identify the read to the consumer, particularly during diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index fdd740b24ab8d9..2291764920733b 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -138,7 +138,7 @@ CHIP_ERROR InteractionModelEngine::NewCommandSender(CommandSender ** const apCom return CHIP_ERROR_NO_MEMORY; } -CHIP_ERROR InteractionModelEngine::NewReadClient(ReadClient ** const apReadClient) +CHIP_ERROR InteractionModelEngine::NewReadClient(ReadClient ** const apReadClient, intptr_t aAppIdentifier) { CHIP_ERROR err = CHIP_ERROR_NO_MEMORY; @@ -147,7 +147,7 @@ CHIP_ERROR InteractionModelEngine::NewReadClient(ReadClient ** const apReadClien if (readClient.IsFree()) { *apReadClient = &readClient; - err = readClient.Init(mpExchangeMgr, mpDelegate); + err = readClient.Init(mpExchangeMgr, mpDelegate, aAppIdentifier); if (CHIP_NO_ERROR != err) { *apReadClient = nullptr; @@ -319,18 +319,22 @@ void InteractionModelEngine::OnResponseTimeout(Messaging::ExchangeContext * ec) ChipLogProgress(DataManagement, "Time out! failed to receive echo response from Exchange: %d", ec->GetExchangeId()); } -// The default implementation to make compiler happy before codegen for this is ready. -// TODO: Remove this after codegen is ready. -CHIP_ERROR __attribute__((weak)) ReadSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVWriter & aWriter) +CHIP_ERROR InteractionModelEngine::SendReadRequest(NodeId aNodeId, Transport::AdminId aAdminId, + SecureSessionHandle * apSecureSession, EventPathParams * apEventPathParamsList, + size_t aEventPathParamsListSize, AttributePathParams * apAttributePathParamsList, + size_t aAttributePathParamsListSize, EventNumber aEventNumber, + intptr_t aAppIdentifier) { - ChipLogDetail(DataManagement, - "Received Cluster Command: Cluster=%" PRIx16 " NodeId=0x" ChipLogFormatX64 " Endpoint=%" PRIx8 " FieldId=%" PRIx8 - " ListIndex=%" PRIx16, - aClusterInfo.mClusterId, ChipLogValueX64(aClusterInfo.mNodeId), aClusterInfo.mEndpointId, aClusterInfo.mFieldId, - aClusterInfo.mListIndex); - ChipLogError(DataManagement, - "Default ReadSingleClusterData is called, this should be replaced by actual dispatched for cluster"); - return CHIP_NO_ERROR; + ReadClient * client = nullptr; + CHIP_ERROR err = CHIP_NO_ERROR; + ReturnErrorOnFailure(NewReadClient(&client, aAppIdentifier)); + err = client->SendReadRequest(aNodeId, aAdminId, apSecureSession, apEventPathParamsList, aEventPathParamsListSize, + apAttributePathParamsList, aAttributePathParamsListSize, aEventNumber); + if (err != CHIP_NO_ERROR) + { + client->Shutdown(); + } + return err; } CHIP_ERROR __attribute__((weak)) @@ -338,7 +342,7 @@ WriteSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVReader & aReader, Wri { ChipLogDetail(DataManagement, "Received Cluster Attribute: Cluster=%" PRIx16 " NodeId=0x" ChipLogFormatX64 " Endpoint=%" PRIx8 - " FieldId=%" PRIx8 " ListIndex=%" PRIx16, + " FieldId=%" PRIx16 " ListIndex=%" PRIx16, aClusterInfo.mClusterId, ChipLogValueX64(aClusterInfo.mNodeId), aClusterInfo.mEndpointId, aClusterInfo.mFieldId, aClusterInfo.mListIndex); ChipLogError(DataManagement, diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index 9ae4af8e491ef3..ccec584ee0482c 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -52,8 +52,8 @@ // TODO: Make number of command handler and command sender configurable #define CHIP_MAX_NUM_COMMAND_HANDLER 4 #define CHIP_MAX_NUM_COMMAND_SENDER 4 -#define CHIP_MAX_NUM_READ_CLIENT 1 -#define CHIP_MAX_NUM_READ_HANDLER 1 +#define CHIP_MAX_NUM_READ_CLIENT 4 +#define CHIP_MAX_NUM_READ_HANDLER 4 #define CHIP_MAX_REPORTS_IN_FLIGHT 1 #define IM_SERVER_MAX_NUM_PATH_GROUPS 8 #define CHIP_MAX_NUM_WRITE_CLIENT 1 @@ -116,15 +116,16 @@ class InteractionModelEngine : public Messaging::ExchangeDelegate CHIP_ERROR NewCommandSender(CommandSender ** const apCommandSender); /** - * Retrieve a ReadClient that the SDK consumer can use to send do a read. If the call succeeds, the consumer - * is responsible for calling Shutdown() on the ReadClient once it's done using it. + * Creates a new read client and send ReadRequest message to the node using the read client. User should use this method since + * it takes care of the life cycle of ReadClient. * - * @param[out] apReadClient A pointer to the ReadClient object. - * - * @retval #CHIP_ERROR_INCORRECT_STATE If there is no ReadClient available + * @retval #CHIP_ERROR_NO_MEMORY If there is no ReadClient available * @retval #CHIP_NO_ERROR On success. */ - CHIP_ERROR NewReadClient(ReadClient ** const apReadClient); + CHIP_ERROR SendReadRequest(NodeId aNodeId, Transport::AdminId aAdminId, SecureSessionHandle * apSecureSession, + EventPathParams * apEventPathParamsList, size_t aEventPathParamsListSize, + AttributePathParams * apAttributePathParamsList, size_t aAttributePathParamsListSize, + EventNumber aEventNumber, intptr_t aAppIdentifier = 0); /** * Retrieve a WriteClient that the SDK consumer can use to send do a write. If the call succeeds, the consumer @@ -177,6 +178,17 @@ class InteractionModelEngine : public Messaging::ExchangeDelegate CHIP_ERROR OnWriteRequest(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload); + /** + * Retrieve a ReadClient that the SDK consumer can use to send do a read. If the call succeeds, the consumer + * is responsible for calling Shutdown() on the ReadClient once it's done using it. + * + * @param[out] apReadClient A pointer to the ReadClient object. + * + * @retval #CHIP_ERROR_INCORRECT_STATE If there is no ReadClient available + * @retval #CHIP_NO_ERROR On success. + */ + CHIP_ERROR NewReadClient(ReadClient ** const apReadClient, intptr_t aAppIdentifier); + Messaging::ExchangeManager * mpExchangeMgr = nullptr; InteractionModelDelegate * mpDelegate = nullptr; CommandHandler mCommandHandlerObjs[CHIP_MAX_NUM_COMMAND_HANDLER]; @@ -204,7 +216,26 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC * otherwise. */ bool ServerClusterCommandExists(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId); -CHIP_ERROR ReadSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVWriter & aWriter); + +/** + * Fetch attribute value and version info and write to the TLVWriter provided. + * When the endpoint / cluster / attribute / event data specified by aClusterInfo does not exist, corresponding interaction model + * error code will be put into the writer, and CHIP_NO_ERROR will be returned and apDataExists will be set to false. + * If the data exists on the server, the data (with tag kCsTag_Data) and the data version (with tag kCsTag_DataVersion) will be put + * into the TLVWriter and apDataExists will be set to true. TLVWriter error will be returned if any error occurred during encoding + * these values. + * This function is implemented by CHIP as a part of cluster data storage & management. + * The apWriter and apDataExists can be nullptr. + * + * @param[in] aClusterInfo The cluster info object, for the path of cluster data. + * @param[in] apWriter The TLVWriter for holding cluster data. Can be a nullptr if the caller does not care + * the exact value of the attribute. + * @param[out] apDataExists Tell whether the cluster data exist on server. Can be a nullptr if the caller does not care + * whether the data exists. + * + * @retval CHIP_NO_ERROR on success + */ +CHIP_ERROR ReadSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVWriter * apWriter, bool * apDataExists); CHIP_ERROR WriteSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVReader & aReader, WriteHandler * apWriteHandler); } // namespace app } // namespace chip diff --git a/src/app/MessageDef/AttributeDataElement.cpp b/src/app/MessageDef/AttributeDataElement.cpp index 8f8861e5833e3a..e4fabb78f84555 100644 --- a/src/app/MessageDef/AttributeDataElement.cpp +++ b/src/app/MessageDef/AttributeDataElement.cpp @@ -280,6 +280,23 @@ CHIP_ERROR AttributeDataElement::Parser::CheckSchemaValidity() const err = ParseData(reader, 0); SuccessOrExit(err); break; + case kCsTag_Status: + // check if this tag has appeared before + VerifyOrExit(!(TagPresenceMask & (1 << kCsTag_Status)), err = CHIP_ERROR_INVALID_TLV_TAG); + TagPresenceMask |= (1 << kCsTag_Status); + VerifyOrExit(chip::TLV::kTLVType_UnsignedInteger == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE); + +#if CHIP_DETAIL_LOGGING + { + uint16_t status; + err = reader.Get(status); + SuccessOrExit(err); + + PRETTY_PRINT("\tStatus = 0x%" PRIx16 ",", status); + } + +#endif // CHIP_DETAIL_LOGGING + break; case kCsTag_MoreClusterDataFlag: // check if this tag has appeared before VerifyOrExit(!(TagPresenceMask & (1 << kCsTag_MoreClusterDataFlag)), err = CHIP_ERROR_INVALID_TLV_TAG); @@ -311,9 +328,11 @@ CHIP_ERROR AttributeDataElement::Parser::CheckSchemaValidity() const if (CHIP_END_OF_TLV == err) { // check for required fields: - // Either the data or deleted keys should be present. - const uint16_t RequiredFields = (1 << kCsTag_AttributePath) | (1 << kCsTag_DataVersion) | (1 << kCsTag_Data); - if ((TagPresenceMask & RequiredFields) == RequiredFields) + // Either the data or the status code should exist. + const uint16_t RequiredFieldSetSuccess = (1 << kCsTag_AttributePath) | (1 << kCsTag_Data) | (1 << kCsTag_DataVersion); + const uint16_t RequiredFieldSetFailure = (1 << kCsTag_AttributePath) | (1 << kCsTag_Status); + if (((TagPresenceMask & RequiredFieldSetSuccess) == RequiredFieldSetSuccess) || + ((TagPresenceMask & RequiredFieldSetFailure) == RequiredFieldSetFailure)) { err = CHIP_NO_ERROR; } @@ -369,6 +388,14 @@ CHIP_ERROR AttributeDataElement::Parser::GetData(chip::TLV::TLVReader * const ap return err; } +CHIP_ERROR AttributeDataElement::Parser::GetStatus(uint16_t * const apStatus) const +{ + chip::TLV::TLVReader reader; + VerifyOrReturnError(apStatus != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + ReturnErrorOnFailure(mReader.FindElementWithTag(chip::TLV::ContextTag(kCsTag_Status), reader)); + return reader.Get(*apStatus); +} + CHIP_ERROR AttributeDataElement::Parser::GetMoreClusterDataFlag(bool * const apGetMoreClusterDataFlag) const { return GetSimpleValue(kCsTag_MoreClusterDataFlag, chip::TLV::kTLVType_Boolean, apGetMoreClusterDataFlag); diff --git a/src/app/MessageDef/AttributeDataElement.h b/src/app/MessageDef/AttributeDataElement.h index 3430ab4a8d6895..5059981d82263b 100644 --- a/src/app/MessageDef/AttributeDataElement.h +++ b/src/app/MessageDef/AttributeDataElement.h @@ -42,7 +42,8 @@ enum kCsTag_AttributePath = 0, kCsTag_DataVersion = 1, kCsTag_Data = 2, - kCsTag_MoreClusterDataFlag = 3, + kCsTag_Status = 3, + kCsTag_MoreClusterDataFlag = 4, }; class Parser : public chip::app::Parser @@ -106,6 +107,16 @@ class Parser : public chip::app::Parser */ CHIP_ERROR GetData(chip::TLV::TLVReader * const apReader) const; + /** + * @brief Get the IM status code. + * + * @param [out] apStatus A pointer to result + * + * @return #CHIP_NO_ERROR on success + * #CHIP_END_OF_TLV if there is not such element + */ + CHIP_ERROR GetStatus(uint16_t * const apStatus) const; + /** * @brief Check whether it need more cluster data Next() must be called before accessing them. * diff --git a/src/app/MessageDef/AttributePath.cpp b/src/app/MessageDef/AttributePath.cpp index 1af8ad8f686cf7..d769b79d05abff 100644 --- a/src/app/MessageDef/AttributePath.cpp +++ b/src/app/MessageDef/AttributePath.cpp @@ -185,7 +185,7 @@ CHIP_ERROR AttributePath::Parser::GetClusterId(chip::ClusterId * const apCluster return GetUnsignedInteger(kCsTag_ClusterId, apClusterId); } -CHIP_ERROR AttributePath::Parser::GetFieldId(chip::FieldId * const apFieldId) const +CHIP_ERROR AttributePath::Parser::GetFieldId(chip::AttributeId * const apFieldId) const { return GetUnsignedInteger(kCsTag_FieldId, apFieldId); } @@ -249,7 +249,7 @@ AttributePath::Builder & AttributePath::Builder::ClusterId(const chip::ClusterId return *this; } -AttributePath::Builder & AttributePath::Builder::FieldId(const chip::FieldId aFieldId) +AttributePath::Builder & AttributePath::Builder::FieldId(const chip::AttributeId aFieldId) { // skip if error has already been set if (mError == CHIP_NO_ERROR) diff --git a/src/app/MessageDef/AttributePath.h b/src/app/MessageDef/AttributePath.h index b1512875bf0f39..b55f888808c1a7 100644 --- a/src/app/MessageDef/AttributePath.h +++ b/src/app/MessageDef/AttributePath.h @@ -115,7 +115,7 @@ class Parser : public chip::app::Parser * #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types * #CHIP_END_OF_TLV if there is no such element */ - CHIP_ERROR GetFieldId(chip::FieldId * const apFieldId) const; + CHIP_ERROR GetFieldId(chip::AttributeId * const apFieldId) const; /** * @brief Get a TLVReader for the ListIndex. Next() must be called before accessing them. @@ -186,7 +186,7 @@ class Builder : public chip::app::Builder * * @return A reference to *this */ - AttributePath::Builder & FieldId(const chip::FieldId aFieldId); + AttributePath::Builder & FieldId(const chip::AttributeId aFieldId); /** * @brief Inject NodeId into the TLV stream. diff --git a/src/app/ReadClient.cpp b/src/app/ReadClient.cpp index 475b57985b31cf..93b5b3bc70b3e1 100644 --- a/src/app/ReadClient.cpp +++ b/src/app/ReadClient.cpp @@ -29,16 +29,18 @@ namespace chip { namespace app { -CHIP_ERROR ReadClient::Init(Messaging::ExchangeManager * apExchangeMgr, InteractionModelDelegate * apDelegate) +CHIP_ERROR ReadClient::Init(Messaging::ExchangeManager * apExchangeMgr, InteractionModelDelegate * apDelegate, + intptr_t aAppIdentifier) { CHIP_ERROR err = CHIP_NO_ERROR; // Error if already initialized. VerifyOrExit(apExchangeMgr != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mpExchangeMgr == nullptr, err = CHIP_ERROR_INCORRECT_STATE); - mpExchangeMgr = apExchangeMgr; - mpDelegate = apDelegate; - mState = ClientState::Initialized; + mpExchangeMgr = apExchangeMgr; + mpDelegate = apDelegate; + mState = ClientState::Initialized; + mAppIdentifier = aAppIdentifier; AbortExistingExchangeContext(); @@ -78,9 +80,10 @@ void ReadClient::MoveToState(const ClientState aTargetState) GetStateStr()); } -CHIP_ERROR ReadClient::SendReadRequest(NodeId aNodeId, Transport::AdminId aAdminId, EventPathParams * apEventPathParamsList, - size_t aEventPathParamsListSize, AttributePathParams * apAttributePathParamsList, - size_t aAttributePathParamsListSize, EventNumber aEventNumber) +CHIP_ERROR ReadClient::SendReadRequest(NodeId aNodeId, Transport::AdminId aAdminId, SecureSessionHandle * apSecureSession, + EventPathParams * apEventPathParamsList, size_t aEventPathParamsListSize, + AttributePathParams * apAttributePathParamsList, size_t aAttributePathParamsListSize, + EventNumber aEventNumber) { // TODO: SendRequest parameter is too long, need to have the structure to represent it CHIP_ERROR err = CHIP_NO_ERROR; @@ -144,12 +147,21 @@ CHIP_ERROR ReadClient::SendReadRequest(NodeId aNodeId, Transport::AdminId aAdmin SuccessOrExit(err); } - mpExchangeCtx = mpExchangeMgr->NewContext({ aNodeId, 0, aAdminId }, this); + if (apSecureSession != nullptr) + { + mpExchangeCtx = mpExchangeMgr->NewContext(*apSecureSession, this); + } + else + { + mpExchangeCtx = mpExchangeMgr->NewContext({ aNodeId, 0, aAdminId }, this); + } VerifyOrExit(mpExchangeCtx != nullptr, err = CHIP_ERROR_NO_MEMORY); mpExchangeCtx->SetResponseTimeout(kImMessageTimeoutMsec); - err = mpExchangeCtx->SendMessage(Protocols::InteractionModel::MsgType::ReadRequest, std::move(msgBuf), - Messaging::SendFlags(Messaging::SendMessageFlags::kExpectResponse)); + // TODO (#7909): Disable CRMP temporary for duplicate ACK issues, should be enabled later. + err = mpExchangeCtx->SendMessage( + Protocols::InteractionModel::MsgType::ReadRequest, std::move(msgBuf), + Messaging::SendFlags(Messaging::SendMessageFlags::kExpectResponse).Set(Messaging::SendMessageFlags::kNoAutoRequestAck)); SuccessOrExit(err); MoveToState(ClientState::AwaitingResponse); @@ -224,6 +236,9 @@ CHIP_ERROR ReadClient::OnMessageReceived(Messaging::ExchangeContext * apExchange } } + // TODO(#7521): Should close it after checking moreChunkedMessages flag is not set. + Shutdown(); + return err; } @@ -322,12 +337,11 @@ void ReadClient::OnResponseTimeout(Messaging::ExchangeContext * apExchangeContex { ChipLogProgress(DataManagement, "Time out! failed to receive report data from Exchange: %d", apExchangeContext->GetExchangeId()); - AbortExistingExchangeContext(); - MoveToState(ClientState::Initialized); if (nullptr != mpDelegate) { mpDelegate->ReportError(this, CHIP_ERROR_TIMEOUT); } + Shutdown(); } CHIP_ERROR ReadClient::ProcessAttributeDataList(TLV::TLVReader & aAttributeDataListReader) @@ -339,6 +353,9 @@ CHIP_ERROR ReadClient::ProcessAttributeDataList(TLV::TLVReader & aAttributeDataL AttributeDataElement::Parser element; AttributePath::Parser attributePathParser; ClusterInfo clusterInfo; + uint16_t statusU16 = 0; + auto status = Protocols::InteractionModel::ProtocolCode::Success; + TLV::TLVReader reader = aAttributeDataListReader; err = element.Init(reader); SuccessOrExit(err); @@ -379,7 +396,18 @@ CHIP_ERROR ReadClient::ProcessAttributeDataList(TLV::TLVReader & aAttributeDataL SuccessOrExit(err); err = element.GetData(&dataReader); - SuccessOrExit(err); + if (err == CHIP_END_OF_TLV) + { + // The spec requires that one of data or status code must exist, thus failure to read data and status code means we + // received malformed data from server. + SuccessOrExit(err = element.GetStatus(&statusU16)); + status = static_cast(statusU16); + } + else if (err != CHIP_NO_ERROR) + { + ExitNow(); + } + mpDelegate->OnReportData(this, clusterInfo, &dataReader, status); } if (CHIP_END_OF_TLV == err) diff --git a/src/app/ReadClient.h b/src/app/ReadClient.h index bfdb4aa56e5cf6..72669f7ed6939b 100644 --- a/src/app/ReadClient.h +++ b/src/app/ReadClient.h @@ -69,9 +69,13 @@ class ReadClient : public Messaging::ExchangeDelegate * @retval #others fail to send read request * @retval #CHIP_NO_ERROR On success. */ - CHIP_ERROR SendReadRequest(NodeId aNodeId, Transport::AdminId aAdminId, EventPathParams * apEventPathParamsList, - size_t aEventPathParamsListSize, AttributePathParams * apAttributePathParamsList, - size_t aAttributePathParamsListSize, EventNumber aEventNumber); + CHIP_ERROR SendReadRequest(NodeId aNodeId, Transport::AdminId aAdminId, SecureSessionHandle * aSecureSession, + EventPathParams * apEventPathParamsList, size_t aEventPathParamsListSize, + AttributePathParams * apAttributePathParamsList, size_t aAttributePathParamsListSize, + EventNumber aEventNumber); + + intptr_t GetAppIdentifier() const { return mAppIdentifier; } + Messaging::ExchangeContext * GetExchangeContext() const { return mpExchangeCtx; } private: friend class TestReadInteraction; @@ -92,12 +96,13 @@ class ReadClient : public Messaging::ExchangeDelegate * * @param[in] apExchangeMgr A pointer to the ExchangeManager object. * @param[in] apDelegate InteractionModelDelegate set by application. + * @param[in] aAppState Application defined object to distinguish different read requests. * * @retval #CHIP_ERROR_INCORRECT_STATE incorrect state if it is already initialized * @retval #CHIP_NO_ERROR On success. * */ - CHIP_ERROR Init(Messaging::ExchangeManager * apExchangeMgr, InteractionModelDelegate * apDelegate); + CHIP_ERROR Init(Messaging::ExchangeManager * apExchangeMgr, InteractionModelDelegate * apDelegate, intptr_t aAppIdentifier); virtual ~ReadClient() = default; @@ -124,6 +129,7 @@ class ReadClient : public Messaging::ExchangeDelegate Messaging::ExchangeContext * mpExchangeCtx = nullptr; InteractionModelDelegate * mpDelegate = nullptr; ClientState mState = ClientState::Uninitialized; + intptr_t mAppIdentifier = 0; }; }; // namespace app diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index 3e8edb5d814be0..34898f22057cdd 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -34,7 +34,6 @@ CHIP_ERROR ReadHandler::Init(InteractionModelDelegate * apDelegate) { CHIP_ERROR err = CHIP_NO_ERROR; // Error if already initialized. - VerifyOrExit(apDelegate != nullptr, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(mpExchangeCtx == nullptr, err = CHIP_ERROR_INCORRECT_STATE); mpExchangeCtx = nullptr; mpDelegate = apDelegate; diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp index 4fb3a13658e43b..102fcde51c108a 100644 --- a/src/app/reporting/Engine.cpp +++ b/src/app/reporting/Engine.cpp @@ -56,7 +56,6 @@ CHIP_ERROR Engine::RetrieveClusterData(AttributeDataElement::Builder & aAttributeDataElementBuilder, ClusterInfo & aClusterInfo) { CHIP_ERROR err = CHIP_NO_ERROR; - TLV::TLVType type = TLV::kTLVType_NotSpecified; AttributePath::Builder attributePathBuilder = aAttributeDataElementBuilder.CreateAttributePathBuilder(); attributePathBuilder.NodeId(aClusterInfo.mNodeId) .EndpointId(aClusterInfo.mEndpointId) @@ -66,14 +65,11 @@ Engine::RetrieveClusterData(AttributeDataElement::Builder & aAttributeDataElemen err = attributePathBuilder.GetError(); SuccessOrExit(err); - aAttributeDataElementBuilder.GetWriter()->StartContainer(TLV::ContextTag(AttributeDataElement::kCsTag_Data), - TLV::kTLVType_Structure, type); - err = ReadSingleClusterData(aClusterInfo, *(aAttributeDataElementBuilder.GetWriter())); + err = ReadSingleClusterData(aClusterInfo, aAttributeDataElementBuilder.GetWriter(), nullptr /* data exists */); SuccessOrExit(err); - aAttributeDataElementBuilder.GetWriter()->EndContainer(type); - aAttributeDataElementBuilder.DataVersion(0).MoreClusterData(false).EndOfAttributeDataElement(); + aAttributeDataElementBuilder.MoreClusterData(false); + aAttributeDataElementBuilder.EndOfAttributeDataElement(); err = aAttributeDataElementBuilder.GetError(); - // TODO: Add DataVersion support exit: aClusterInfo.ClearDirty(); diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp index 9a406a78d7c885..3d7044eda45137 100644 --- a/src/app/tests/TestCommandInteraction.cpp +++ b/src/app/tests/TestCommandInteraction.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,14 @@ bool ServerClusterCommandExists(chip::ClusterId aClusterId, chip::CommandId aCom return (aEndPointId == kTestEndpointId && aClusterId == kTestClusterId && aCommandId == kTestCommandId); } +CHIP_ERROR ReadSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVWriter * apWriter, bool * apDataExists) +{ + // We do not really care about the value, just return a not found status code. + VerifyOrReturnError(apWriter != nullptr, CHIP_NO_ERROR); + return apWriter->Put(chip::TLV::ContextTag(AttributeDataElement::kCsTag_Status), + static_cast(Protocols::InteractionModel::ProtocolCode::UnsupportedAttribute)); +} + class TestCommandInteraction { public: diff --git a/src/app/tests/TestMessageDef.cpp b/src/app/tests/TestMessageDef.cpp index 66456bd6e58fc8..b31f7ba75fdc57 100644 --- a/src/app/tests/TestMessageDef.cpp +++ b/src/app/tests/TestMessageDef.cpp @@ -83,7 +83,7 @@ void ParseAttributePath(nlTestSuite * apSuite, chip::TLV::TLVReader & aReader) chip::NodeId nodeId = 1; chip::EndpointId endpointId = 2; chip::ClusterId clusterId = 3; - chip::FieldId fieldId = 4; + chip::AttributeId fieldId = 4; chip::ListIndex listIndex = 5; err = attributePathParser.Init(aReader); diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index a072d992b54625..dee35317a7740f 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -150,12 +150,12 @@ void TestReadInteraction::TestReadClient(nlTestSuite * apSuite, void * apContext chip::app::InteractionModelDelegate delegate; System::PacketBufferHandle buf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize); - err = readClient.Init(&gExchangeManager, &delegate); + err = readClient.Init(&gExchangeManager, &delegate, 0 /* application identifier */); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - err = readClient.SendReadRequest(kTestDeviceNodeId, gAdminId, nullptr /*apEventPathParamsList*/, 0 /*aEventPathParamsListSize*/, - nullptr /*apAttributePathParamsList*/, 0 /*aAttributePathParamsListSize*/, - eventNumber /*aEventNumber*/); + err = readClient.SendReadRequest(kTestDeviceNodeId, gAdminId, nullptr /* apSecureSession */, nullptr /*apEventPathParamsList*/, + 0 /*aEventPathParamsListSize*/, nullptr /*apAttributePathParamsList*/, + 0 /*aAttributePathParamsListSize*/, eventNumber /*aEventNumber*/); NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_NOT_CONNECTED); GenerateReportData(apSuite, apContext, buf); @@ -225,7 +225,7 @@ void TestReadInteraction::TestReadClientGenerateAttributePathList(nlTestSuite * err = request.Init(&writer); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - err = readClient.Init(&gExchangeManager, &delegate); + err = readClient.Init(&gExchangeManager, &delegate, 0 /* application identifier */); AttributePathParams attributePathParams[2]; attributePathParams[0].mFlags.Set(AttributePathParams::Flags::kFieldIdValid); @@ -246,7 +246,7 @@ void TestReadInteraction::TestReadClientGenerateInvalidAttributePathList(nlTestS msgBuf = System::PacketBufferHandle::New(kMaxSecureSduLengthBytes); NL_TEST_ASSERT(apSuite, !msgBuf.IsNull()); writer.Init(std::move(msgBuf)); - err = readClient.Init(&gExchangeManager, &delegate); + err = readClient.Init(&gExchangeManager, &delegate, 0 /* application identifier */); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); err = request.Init(&writer); @@ -268,12 +268,12 @@ void TestReadInteraction::TestReadClientInvalidReport(nlTestSuite * apSuite, voi EventNumber eventNumber = 0; System::PacketBufferHandle buf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize); - err = readClient.Init(&gExchangeManager, &delegate); + err = readClient.Init(&gExchangeManager, &delegate, 0 /* application identifier */); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - err = readClient.SendReadRequest(kTestDeviceNodeId, gAdminId, nullptr /*apEventPathParamsList*/, 0 /*aEventPathParamsListSize*/, - nullptr /*apAttributePathParamsList*/, 0 /*aAttributePathParamsListSize*/, - eventNumber /*aEventNumber*/); + err = readClient.SendReadRequest(kTestDeviceNodeId, gAdminId, nullptr /* apSecureSession */, nullptr /*apEventPathParamsList*/, + 0 /*aEventPathParamsListSize*/, nullptr /*apAttributePathParamsList*/, + 0 /*aAttributePathParamsListSize*/, eventNumber /*aEventNumber*/); NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_NOT_CONNECTED); GenerateReportData(apSuite, apContext, buf, true /*aNeedInvalidReport*/); diff --git a/src/app/tests/TestReportingEngine.cpp b/src/app/tests/TestReportingEngine.cpp index 48c13531893bdd..bf3bec25661f0e 100644 --- a/src/app/tests/TestReportingEngine.cpp +++ b/src/app/tests/TestReportingEngine.cpp @@ -58,20 +58,21 @@ constexpr uint8_t kTestFieldValue1 = 1; constexpr uint8_t kTestFieldValue2 = 2; namespace app { -CHIP_ERROR ReadSingleClusterData(AttributePathParams & aAttributePathParams, TLV::TLVWriter & aWriter) +CHIP_ERROR ReadSingleClusterData(AttributePathParams & aAttributePathParams, TLV::TLVWriter * apWriter, bool * apDataExists) { CHIP_ERROR err = CHIP_NO_ERROR; VerifyOrExit(aAttributePathParams.mClusterId == kTestClusterId && aAttributePathParams.mEndpointId == kTestEndpointId, err = CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrExit(apWriter != nullptr, /* no op */); if (aAttributePathParams.mFieldId == kTestFieldId1) { - err = aWriter.Put(TLV::ContextTag(kTestFieldId1), kTestFieldValue1); + err = apWriter->Put(TLV::ContextTag(kTestFieldId1), kTestFieldValue1); SuccessOrExit(err); } if (aAttributePathParams.mFieldId == kTestFieldId2) { - err = aWriter.Put(TLV::ContextTag(kTestFieldId2), kTestFieldValue2); + err = apWriter->Put(TLV::ContextTag(kTestFieldId2), kTestFieldValue2); SuccessOrExit(err); } diff --git a/src/app/tests/integration/chip_im_initiator.cpp b/src/app/tests/integration/chip_im_initiator.cpp index 101e260958e95a..6fe8fdf337f78d 100644 --- a/src/app/tests/integration/chip_im_initiator.cpp +++ b/src/app/tests/integration/chip_im_initiator.cpp @@ -51,9 +51,6 @@ constexpr size_t kMaxWriteMessageCount = 3; constexpr int32_t gMessageIntervalSeconds = 1; constexpr chip::Transport::AdminId gAdminId = 0; -// The ReadClient object. -chip::app::ReadClient * gpReadClient = nullptr; - chip::TransportMgr gTransportManager; chip::Inet::IPAddress gDestAddr; @@ -189,7 +186,8 @@ CHIP_ERROR SendReadRequest() printf("\nSend read request message to Node: %" PRIu64 "\n", chip::kTestDeviceNodeId); - err = gpReadClient->SendReadRequest(chip::kTestDeviceNodeId, gAdminId, &eventPathParams, 1, &attributePathParams, 1, number); + err = chip::app::InteractionModelEngine::GetInstance()->SendReadRequest(chip::kTestDeviceNodeId, gAdminId, nullptr, + &eventPathParams, 1, &attributePathParams, 1, number); SuccessOrExit(err); exit: @@ -382,6 +380,28 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC gLastCommandResult = TestCommandResult::kSuccess; } + +CHIP_ERROR ReadSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVWriter * apWriter, bool * apDataExists) +{ + // We do not really care about the value, just return a not found status code. + VerifyOrReturnError(apWriter != nullptr, CHIP_NO_ERROR); + return apWriter->Put(chip::TLV::ContextTag(AttributeDataElement::kCsTag_Status), + Protocols::InteractionModel::ToUint16(Protocols::InteractionModel::ProtocolCode::UnsupportedAttribute)); +} + +CHIP_ERROR WriteSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVReader & aReader) +{ + if (aClusterInfo.mClusterId != kTestClusterId || aClusterInfo.mEndpointId != kTestEndpointId) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + + if (aReader.GetLength() != 0) + { + chip::TLV::Debug::Dump(aReader, TLVPrettyPrinter); + } + return CHIP_NO_ERROR; +} } // namespace app } // namespace chip @@ -434,9 +454,6 @@ int main(int argc, char * argv[]) err = EstablishSecureSession(); SuccessOrExit(err); - err = chip::app::InteractionModelEngine::GetInstance()->NewReadClient(&gpReadClient); - SuccessOrExit(err); - // Connection has been established. Now send the CommandRequests. for (unsigned int i = 0; i < kMaxCommandMessageCount; i++) { @@ -514,7 +531,6 @@ int main(int argc, char * argv[]) } } - gpReadClient->Shutdown(); chip::app::InteractionModelEngine::GetInstance()->Shutdown(); ShutdownChip(); diff --git a/src/app/tests/integration/chip_im_responder.cpp b/src/app/tests/integration/chip_im_responder.cpp index b4d5aa8b89da6e..f53a05ba047017 100644 --- a/src/app/tests/integration/chip_im_responder.cpp +++ b/src/app/tests/integration/chip_im_responder.cpp @@ -96,20 +96,21 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC statusCodeFlipper = !statusCodeFlipper; } -CHIP_ERROR ReadSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVWriter & aWriter) +CHIP_ERROR ReadSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVWriter * apWriter, bool * apDataExists) { CHIP_ERROR err = CHIP_NO_ERROR; VerifyOrExit(aClusterInfo.mClusterId == kTestClusterId && aClusterInfo.mEndpointId == kTestEndpointId, err = CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrExit(apWriter != nullptr, /* no op */); if (aClusterInfo.mFieldId == kRootFieldId || aClusterInfo.mFieldId == 1) { - err = aWriter.Put(TLV::ContextTag(kTestFieldId1), kTestFieldValue1); + err = apWriter->Put(TLV::ContextTag(kTestFieldId1), kTestFieldValue1); SuccessOrExit(err); } if (aClusterInfo.mFieldId == kRootFieldId || aClusterInfo.mFieldId == 2) { - err = aWriter.Put(TLV::ContextTag(kTestFieldId2), kTestFieldValue2); + err = apWriter->Put(TLV::ContextTag(kTestFieldId2), kTestFieldValue2); SuccessOrExit(err); } diff --git a/src/app/util/CHIPDeviceCallbacksMgr.cpp b/src/app/util/CHIPDeviceCallbacksMgr.cpp index d05e5c7b77d00f..7fd694f1f68882 100644 --- a/src/app/util/CHIPDeviceCallbacksMgr.cpp +++ b/src/app/util/CHIPDeviceCallbacksMgr.cpp @@ -30,13 +30,6 @@ #include namespace { -struct ResponseCallbackInfo -{ - chip::NodeId nodeId; - uint8_t sequenceNumber; - - bool operator==(ResponseCallbackInfo const & other) { return nodeId == other.nodeId && sequenceNumber == other.sequenceNumber; } -}; struct ReportCallbackInfo { @@ -58,7 +51,7 @@ namespace app { CHIP_ERROR CHIPDeviceCallbacksMgr::AddResponseCallback(NodeId nodeId, uint8_t sequenceNumber, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) + Callback::Cancelable * onFailureCallback, TLVDataFilter filter) { VerifyOrReturnError(onSuccessCallback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(onFailureCallback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); @@ -72,7 +65,12 @@ CHIP_ERROR CHIPDeviceCallbacksMgr::AddResponseCallback(NodeId nodeId, uint8_t se // has not been received for a previous command with the same sequenceNumber. Cancel the previously registered callbacks. CancelCallback(info, mResponsesSuccess); CancelCallback(info, mResponsesFailure); + PopResponseFilter(info, nullptr); + if (filter != nullptr) + { + ReturnErrorOnFailure(AddResponseFilter(info, filter)); + } mResponsesSuccess.Enqueue(onSuccessCallback); mResponsesFailure.Enqueue(onFailureCallback); return CHIP_NO_ERROR; @@ -83,12 +81,49 @@ CHIP_ERROR CHIPDeviceCallbacksMgr::CancelResponseCallback(NodeId nodeId, uint8_t ResponseCallbackInfo info = { nodeId, sequenceNumber }; CancelCallback(info, mResponsesSuccess); CancelCallback(info, mResponsesFailure); + PopResponseFilter(info, nullptr); return CHIP_NO_ERROR; } +CHIP_ERROR CHIPDeviceCallbacksMgr::AddResponseFilter(const ResponseCallbackInfo & info, TLVDataFilter filter) +{ + constexpr ResponseCallbackInfo kEmptyInfo{ kAnyNodeId, 0 }; + + for (size_t i = 0; i < kTLVFilterPoolSize; i++) + { + if (mTLVFilterPool[i].info == kEmptyInfo) + { + mTLVFilterPool[i].info = info; + mTLVFilterPool[i].filter = filter; + return CHIP_NO_ERROR; + } + } + + return CHIP_ERROR_NO_MEMORY; +} + +CHIP_ERROR CHIPDeviceCallbacksMgr::PopResponseFilter(const ResponseCallbackInfo & info, TLVDataFilter * outFilter) +{ + for (size_t i = 0; i < kTLVFilterPoolSize; i++) + { + if (mTLVFilterPool[i].info == info) + { + if (outFilter != nullptr) + { + *outFilter = mTLVFilterPool[i].filter; + } + mTLVFilterPool[i].info = ResponseCallbackInfo{ kAnyNodeId, 0 }; + mTLVFilterPool[i].filter = nullptr; + return CHIP_NO_ERROR; + } + } + + return CHIP_ERROR_KEY_NOT_FOUND; +} + CHIP_ERROR CHIPDeviceCallbacksMgr::GetResponseCallback(NodeId nodeId, uint8_t sequenceNumber, Callback::Cancelable ** onSuccessCallback, - Callback::Cancelable ** onFailureCallback) + Callback::Cancelable ** onFailureCallback, TLVDataFilter * outFilter) { ResponseCallbackInfo info = { nodeId, sequenceNumber }; @@ -98,6 +133,15 @@ CHIP_ERROR CHIPDeviceCallbacksMgr::GetResponseCallback(NodeId nodeId, uint8_t se ReturnErrorOnFailure(GetCallback(info, mResponsesFailure, onFailureCallback)); (*onFailureCallback)->Cancel(); + if (outFilter == nullptr) + { + PopResponseFilter(info, nullptr); + } + else + { + ReturnErrorOnFailure(PopResponseFilter(info, outFilter)); + } + return CHIP_NO_ERROR; } diff --git a/src/app/util/CHIPDeviceCallbacksMgr.h b/src/app/util/CHIPDeviceCallbacksMgr.h index 006ea30e7d0ed9..dbf4b262338c3c 100644 --- a/src/app/util/CHIPDeviceCallbacksMgr.h +++ b/src/app/util/CHIPDeviceCallbacksMgr.h @@ -30,12 +30,31 @@ #include #include +#include #include +#include #include namespace chip { namespace app { +#ifndef CHIP_DEVICE_CALLBACK_MANAGER_TLV_FILTER_POOL_SIZE +constexpr size_t kTLVFilterPoolSize = 32; +#else +constexpr size_t kTLVFilterPoolSize = CHIP_DEVICE_CALLBACK_MANAGER_TLV_FILTER_POOL_SIZE; +#endif + +/** + * The filter interface for processing data from TLV. + * The caller of the function will pass the original TLV data, the original success and failure callback to this function. + * Since success callback and failure callback contains necessary context, this function itself is stateless. + * The possible implementation of this function might be: + * - Unpack the data with some schema from TLV + * - Call success callback and failure callback according to the result of unpack routine. + */ +using TLVDataFilter = void (*)(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure); + class DLL_EXPORT CHIPDeviceCallbacksMgr { public: @@ -50,10 +69,10 @@ class DLL_EXPORT CHIPDeviceCallbacksMgr } CHIP_ERROR AddResponseCallback(NodeId nodeId, uint8_t sequenceNumber, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback); + Callback::Cancelable * onFailureCallback, TLVDataFilter callbackFilter = nullptr); CHIP_ERROR CancelResponseCallback(NodeId nodeId, uint8_t sequenceNumber); CHIP_ERROR GetResponseCallback(NodeId nodeId, uint8_t sequenceNumber, Callback::Cancelable ** onSuccessCallback, - Callback::Cancelable ** onFailureCallback); + Callback::Cancelable ** onFailureCallback, TLVDataFilter * callbackFilter = nullptr); CHIP_ERROR AddReportCallback(NodeId nodeId, EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, Callback::Cancelable * onReportCallback); @@ -63,6 +82,23 @@ class DLL_EXPORT CHIPDeviceCallbacksMgr private: CHIPDeviceCallbacksMgr() {} + struct ResponseCallbackInfo + { + chip::NodeId nodeId; + uint8_t sequenceNumber; + + bool operator==(ResponseCallbackInfo const & other) + { + return nodeId == other.nodeId && sequenceNumber == other.sequenceNumber; + } + }; + + struct TLVFilterItem + { + ResponseCallbackInfo info = { kAnyNodeId, 0 }; + TLVDataFilter filter = nullptr; + }; + template CHIP_ERROR CancelCallback(T & info, Callback::CallbackDeque & queue) { @@ -99,8 +135,12 @@ class DLL_EXPORT CHIPDeviceCallbacksMgr return CHIP_ERROR_KEY_NOT_FOUND; } + CHIP_ERROR AddResponseFilter(const ResponseCallbackInfo & info, TLVDataFilter callbackFilter); + CHIP_ERROR PopResponseFilter(const ResponseCallbackInfo & info, TLVDataFilter * callbackFilter); + Callback::CallbackDeque mResponsesSuccess; Callback::CallbackDeque mResponsesFailure; + TLVFilterItem mTLVFilterPool[kTLVFilterPoolSize]; Callback::CallbackDeque mReports; }; diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index 663d002c3ebd2e..08bc3dd6f8af58 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -23,20 +23,85 @@ #include #include +#include +#include #include #include #include #include #include +#include + +#include +#include + +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Compatibility; namespace chip { namespace app { namespace Compatibility { namespace { +constexpr uint32_t kTemporaryDataVersion = 0; +// On some apps, ATTRIBUTE_LARGEST can as small as 3, making compiler unhappy since data[kAttributeReadBufferSize] cannot hold +// uint64_t. Make kAttributeReadBufferSize at least 8 so it can fit all basic types. +constexpr size_t kAttributeReadBufferSize = (ATTRIBUTE_LARGEST >= 8 ? ATTRIBUTE_LARGEST : 8); EmberAfClusterCommand imCompatibilityEmberAfCluster; EmberApsFrame imCompatibilityEmberApsFrame; EmberAfInterpanHeader imCompatibilityInterpanHeader; Command * currentCommandObject; + +// BasicType maps the type to basic int(8|16|32|64)(s|u) types. +EmberAfAttributeType BaseType(EmberAfAttributeType type) +{ + switch (type) + { + case ZCL_ENDPOINT_ID_ATTRIBUTE_TYPE: // Endpoint Id + case ZCL_COMMAND_ID_ATTRIBUTE_TYPE: // Command Id + case ZCL_BITMAP8_ATTRIBUTE_TYPE: // 8-bit bitmap + case ZCL_ENUM8_ATTRIBUTE_TYPE: // 8-bit enumeration + static_assert(std::is_same::value, + "chip::EndpointId is expected to be uint8_t, change this when necessary"); + static_assert(std::is_same::value, + "chip::CommandId is expected to be uint8_t, change this when necessary"); + return ZCL_INT8U_ATTRIBUTE_TYPE; + + case ZCL_GROUP_ID_ATTRIBUTE_TYPE: // Group Id + case ZCL_ENUM16_ATTRIBUTE_TYPE: // 16-bit enumeration + case ZCL_BITMAP16_ATTRIBUTE_TYPE: // 16-bit bitmap + static_assert(std::is_same::value, + "chip::GroupId is expected to be uint16_t, change this when necessary"); + return ZCL_INT16U_ATTRIBUTE_TYPE; + + case ZCL_BITMAP32_ATTRIBUTE_TYPE: // 32-bit bitmap + case ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE: // Device Type Id + static_assert(std::is_same::value, + "chip::DeviceTypeId is expected to be uint32_t, change this when necessary"); + return ZCL_INT32U_ATTRIBUTE_TYPE; + + case ZCL_BITMAP64_ATTRIBUTE_TYPE: // 64-bit bitmap + case ZCL_FABRIC_ID_ATTRIBUTE_TYPE: // Fabric Id + case ZCL_NODE_ID_ATTRIBUTE_TYPE: // Node Id + static_assert(std::is_same::value, + "chip::FabricId is expected to be uint64_t, change this when necessary"); + static_assert(std::is_same::value, + "chip::NodeId is expected to be uint64_t, change this when necessary"); + return ZCL_INT64U_ATTRIBUTE_TYPE; + + case ZCL_CHAR_STRING_ATTRIBUTE_TYPE: // Character string + return ZCL_OCTET_STRING_ATTRIBUTE_TYPE; + + case ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE: + return ZCL_LONG_OCTET_STRING_ATTRIBUTE_TYPE; + + default: + return type; + } +} + } // namespace void SetupEmberAfObjects(Command * command, ClusterId clusterId, CommandId commandId, EndpointId endpointId) @@ -95,5 +160,142 @@ bool ServerClusterCommandExists(chip::ClusterId aClusterId, chip::CommandId aCom return emberAfContainsServer(aEndPointId, aClusterId); } +CHIP_ERROR ReadSingleClusterData(ClusterInfo & aClusterInfo, TLV::TLVWriter * apWriter, bool * apDataExists) +{ + static uint8_t data[kAttributeReadBufferSize]; + + ChipLogDetail(DataManagement, + "Received Cluster Command: Cluster=%" PRIx16 " NodeId=0x" ChipLogFormatX64 " Endpoint=%" PRIx8 " FieldId=%" PRIx16 + " ListIndex=%" PRIx16, + aClusterInfo.mClusterId, ChipLogValueX64(aClusterInfo.mNodeId), aClusterInfo.mEndpointId, aClusterInfo.mFieldId, + aClusterInfo.mListIndex); + + EmberAfAttributeType attributeType; + EmberAfStatus status; + status = emberAfReadAttribute(aClusterInfo.mEndpointId, aClusterInfo.mClusterId, aClusterInfo.mFieldId, CLUSTER_MASK_SERVER, + data, sizeof(data), &attributeType); + + // TODO: Currently, all errors are considered as attribute not exists, should be fixed by mapping ember error code to IM error + // codes. + if (apDataExists != nullptr) + { + *apDataExists = (EMBER_ZCL_STATUS_SUCCESS == status); + } + + VerifyOrReturnError(apWriter != nullptr, CHIP_NO_ERROR); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + return apWriter->Put( + chip::TLV::ContextTag(AttributeDataElement::kCsTag_Status), + Protocols::InteractionModel::ToUint16(Protocols::InteractionModel::ProtocolCode::UnsupportedAttribute)); + } + + // TODO: ZCL_STRUCT_ATTRIBUTE_TYPE is not included in this switch case currently, should add support for structures. + switch (BaseType(attributeType)) + { + case ZCL_NO_DATA_ATTRIBUTE_TYPE: // No data + ReturnErrorOnFailure(apWriter->PutNull(TLV::ContextTag(AttributeDataElement::kCsTag_Data))); + break; + case ZCL_BOOLEAN_ATTRIBUTE_TYPE: // Boolean + ReturnErrorOnFailure(apWriter->PutBoolean(TLV::ContextTag(AttributeDataElement::kCsTag_Data), !!data[0])); + break; + case ZCL_INT8U_ATTRIBUTE_TYPE: // Unsigned 8-bit integer + ReturnErrorOnFailure(apWriter->Put(TLV::ContextTag(AttributeDataElement::kCsTag_Data), data[0])); + break; + case ZCL_INT16U_ATTRIBUTE_TYPE: // Unsigned 16-bit integer + { + uint16_t uint16_data; + memcpy(&uint16_data, data, sizeof(uint16_data)); + ReturnErrorOnFailure(apWriter->Put(TLV::ContextTag(AttributeDataElement::kCsTag_Data), uint16_data)); + break; + } + case ZCL_INT32U_ATTRIBUTE_TYPE: // Unsigned 32-bit integer + { + uint32_t uint32_data; + memcpy(&uint32_data, data, sizeof(uint32_data)); + ReturnErrorOnFailure(apWriter->Put(TLV::ContextTag(AttributeDataElement::kCsTag_Data), uint32_data)); + break; + } + case ZCL_INT64U_ATTRIBUTE_TYPE: // Unsigned 64-bit integer + { + uint64_t uint64_data; + memcpy(&uint64_data, data, sizeof(uint64_data)); + ReturnErrorOnFailure(apWriter->Put(TLV::ContextTag(AttributeDataElement::kCsTag_Data), uint64_data)); + break; + } + case ZCL_INT8S_ATTRIBUTE_TYPE: // Signed 8-bit integer + { + int8_t int8_data; + memcpy(&int8_data, data, sizeof(int8_data)); + ReturnErrorOnFailure(apWriter->Put(TLV::ContextTag(AttributeDataElement::kCsTag_Data), int8_data)); + break; + } + case ZCL_INT16S_ATTRIBUTE_TYPE: // Signed 16-bit integer + { + int16_t int16_data; + memcpy(&int16_data, data, sizeof(int16_data)); + ReturnErrorOnFailure(apWriter->Put(TLV::ContextTag(AttributeDataElement::kCsTag_Data), int16_data)); + break; + } + case ZCL_INT32S_ATTRIBUTE_TYPE: // Signed 32-bit integer + { + int32_t int32_data; + memcpy(&int32_data, data, sizeof(int32_data)); + ReturnErrorOnFailure(apWriter->Put(TLV::ContextTag(AttributeDataElement::kCsTag_Data), int32_data)); + break; + } + case ZCL_INT64S_ATTRIBUTE_TYPE: // Signed 64-bit integer + { + int64_t int64_data; + memcpy(&int64_data, data, sizeof(int64_data)); + ReturnErrorOnFailure(apWriter->Put(TLV::ContextTag(AttributeDataElement::kCsTag_Data), int64_data)); + break; + } + case ZCL_OCTET_STRING_ATTRIBUTE_TYPE: // Octet string + { + uint8_t * actualData = data + 1; + uint8_t dataLength = data[0]; + if (dataLength == 0xFF /* invalid data, put empty value instead */) + { + dataLength = 0; + } + ReturnErrorOnFailure( + apWriter->Put(TLV::ContextTag(AttributeDataElement::kCsTag_Data), chip::ByteSpan(actualData, dataLength))); + break; + } + case ZCL_LONG_OCTET_STRING_ATTRIBUTE_TYPE: { + uint8_t * actualData = data + 2; // The pascal string contains 2 bytes length + uint16_t dataLength; + memcpy(&dataLength, data, sizeof(dataLength)); + if (dataLength == 0xFFFF /* invalid data, put empty value instead */) + { + dataLength = 0; + } + ReturnErrorOnFailure( + apWriter->Put(TLV::ContextTag(AttributeDataElement::kCsTag_Data), chip::ByteSpan(actualData, dataLength))); + break; + } + case ZCL_ARRAY_ATTRIBUTE_TYPE: { + TLV::TLVType containerType; + ReturnErrorOnFailure( + apWriter->StartContainer(TLV::ContextTag(AttributeDataElement::kCsTag_Data), TLV::kTLVType_List, containerType)); + // TODO: Encode data in TLV, now raw buffers + ReturnErrorOnFailure( + apWriter->PutBytes(TLV::AnonymousTag, data, + emberAfAttributeValueSize(aClusterInfo.mClusterId, aClusterInfo.mFieldId, attributeType, data))); + ReturnErrorOnFailure(apWriter->EndContainer(containerType)); + break; + } + default: + ChipLogError(DataManagement, "Attribute type 0x%x not handled", static_cast(attributeType)); + return apWriter->Put(chip::TLV::ContextTag(AttributeDataElement::kCsTag_Status), + Protocols::InteractionModel::ToUint16(Protocols::InteractionModel::ProtocolCode::UnsupportedRead)); + } + + // TODO: Add DataVersion support + ReturnErrorOnFailure(apWriter->Put(chip::TLV::ContextTag(AttributeDataElement::kCsTag_DataVersion), kTemporaryDataVersion)); + return CHIP_NO_ERROR; +} + } // namespace app } // namespace chip diff --git a/src/app/util/process-global-message.cpp b/src/app/util/process-global-message.cpp index d3ac1268ac3f29..2f56c62c0242f5 100644 --- a/src/app/util/process-global-message.cpp +++ b/src/app/util/process-global-message.cpp @@ -155,82 +155,6 @@ bool emAfProcessGlobalCommand(EmberAfClusterCommand * cmd) switch (zclCmd) { - // The format of the read attributes cmd is: - // ([attr ID:2]) * N - // The format of the read attributes response is: - // ([attr ID:2] [status:1] [data type:0/1] [data:0/N]) * N - case ZCL_READ_ATTRIBUTES_COMMAND_ID: { - emberAfAttributesPrintln("%p: clus %2x", "READ_ATTR", clusterId); - // Set the cmd byte - this is byte 3 index 2, but since we have - // already incremented past the 3 byte ZCL header (our index is at 3), - // this gets written to "-1" since 3 - 1 = 2. - emberAfPutInt8uInResp(ZCL_READ_ATTRIBUTES_RESPONSE_COMMAND_ID); - - // This message contains N 2-byte attr IDs after the 3 byte ZCL header, - // for each one we need to look it up and make a response - while (msgIndex + 2 <= msgLen) - { - // Get the attribute ID and store it in the response buffer - // least significant byte is first OTA - attrId = emberAfGetInt16u(message, msgIndex, msgLen); - -#ifdef EMBER_AF_GBCS_COMPATIBLE - // GBCS explicitly lists some commands that need to be sent with "disable - // default response" flag set, including some ReadAttributes responses. - // We make it conditional on GBCS so it does not affect standard SE apps. - { - static const struct - { - ClusterId clusterId; - AttributeId attrId; - } noDefaultResponseSet[] = { - { ZCL_PRICE_CLUSTER_ID, ZCL_THRESHOLD_MULTIPLIER_ATTRIBUTE_ID }, - { ZCL_PRICE_CLUSTER_ID, ZCL_THRESHOLD_DIVISOR_ATTRIBUTE_ID }, - { ZCL_PRICE_CLUSTER_ID, ZCL_STANDING_CHARGE_ATTRIBUTE_ID }, - { ZCL_PRICE_CLUSTER_ID, ZCL_TARIFF_UNIT_OF_MEASURE_ATTRIBUTE_ID }, - { ZCL_SIMPLE_METERING_CLUSTER_ID, ZCL_UNIT_OF_MEASURE_ATTRIBUTE_ID }, - { ZCL_SIMPLE_METERING_CLUSTER_ID, ZCL_MULTIPLIER_ATTRIBUTE_ID }, - { ZCL_SIMPLE_METERING_CLUSTER_ID, ZCL_DIVISOR_ATTRIBUTE_ID }, - }; - uint8_t i; - uint8_t foundMatchingAttrIdsCount = 0; - - for (i = 0; i < sizeof noDefaultResponseSet / sizeof noDefaultResponseSet[0]; ++i) - { - if (noDefaultResponseSet[i].clusterId == clusterId && noDefaultResponseSet[i].attrId == attrId) - { - if (++foundMatchingAttrIdsCount >= MIN_MATCHING_ATTR_IDS_TO_DISABLE_DEFAULT_RESPONSE) - { - emberAfSetDisableDefaultResponse(EMBER_AF_DISABLE_DEFAULT_RESPONSE_ONE_SHOT); - break; - } - } - } - } - -#ifdef EMBER_AF_PLUGIN_COMMS_HUB_FUNCTION_SUB_GHZ - // This plugin sets channel change notification flags and needs to know - // when those flags have been read. - if (clientServerMask == CLUSTER_MASK_SERVER) - { - emAfCommsHubFunctionSubGhzReadAttributeNotification(cmd->source, clusterId, attrId); - } -#endif -#endif - - // This function reads the attribute and creates the correct response - // in the response buffer - emberAfRetrieveAttributeAndCraftResponse(cmd->apsFrame->destinationEndpoint, clusterId, attrId, clientServerMask, - cmd->mfgCode, - static_cast(EMBER_AF_RESPONSE_BUFFER_LEN - appResponseLength)); - // Go to next attrID - msgIndex = static_cast(msgIndex + 2); - } - } - - emberAfSendResponse(); - return true; - // Write undivided means all attributes must be written in order to write // any of them. So first do a check. If the check fails, send back a fail // response. If it works, fall through to the normal write attr code. @@ -549,10 +473,6 @@ bool emAfProcessGlobalCommand(EmberAfClusterCommand * cmd) static_cast(msgLen - msgIndex)); #endif - if (!emberAfReadAttributesResponseCallback(clusterId, message + msgIndex, static_cast(msgLen - msgIndex))) - { - emberAfSendDefaultResponse(cmd, EMBER_ZCL_STATUS_SUCCESS); - } return true; // ([status:1] [attribute id:2])+ diff --git a/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt b/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt index 0984d3cad7fbef..551c4968ce2dc2 100644 --- a/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt +++ b/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt @@ -21,7 +21,7 @@ using namespace ::chip::app::List; constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -#define CHECK_STATUS(error) \ +#define CHECK_STATUS_WITH_RETVAL(error, retval) \ if (CHIP_NO_ERROR != error) \ { \ ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ @@ -31,10 +31,13 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } -#define CHECK_MESSAGE_LENGTH(value) \ +#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) +#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) + +#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ if (!chip::CanCastTo(value)) \ { \ ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ @@ -44,7 +47,7 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } \ \ if (messageLen < value) \ @@ -56,11 +59,14 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } \ \ messageLen = static_cast(messageLen - static_cast(value)); +#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) +#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) + #define GET_RESPONSE_CALLBACKS(name) \ Callback::Cancelable * onSuccessCallback = nullptr; \ Callback::Cancelable * onFailureCallback = nullptr; \ @@ -226,6 +232,139 @@ void LogStatus(uint8_t status) } } +static void LogIMStatus(Protocols::InteractionModel::ProtocolCode status) +{ + switch (status) + { + case Protocols::InteractionModel::ProtocolCode::Success: + ChipLogProgress(Zcl, " status: Success (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Failure: + ChipLogProgress(Zcl, " status: Failure (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidSubscription: + ChipLogProgress(Zcl, " status: InvalidSubscription (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedAccess: + ChipLogProgress(Zcl, " status: UnsupportedAccess (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedEndpoint: + ChipLogProgress(Zcl, " status: UnsupportedEndpoint (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidAction: + ChipLogProgress(Zcl, " status: InvalidAction (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedCommand: + ChipLogProgress(Zcl, " status: UnsupportedCommand (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved82: + ChipLogProgress(Zcl, " status: Reserved82 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved83: + ChipLogProgress(Zcl, " status: Reserved83 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved84: + ChipLogProgress(Zcl, " status: Reserved84 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidCommand: + ChipLogProgress(Zcl, " status: InvalidCommand (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedAttribute: + ChipLogProgress(Zcl, " status: UnsupportedAttribute (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidValue: + ChipLogProgress(Zcl, " status: InvalidValue (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedWrite: + ChipLogProgress(Zcl, " status: UnsupportedWrite (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::ResourceExhausted: + ChipLogProgress(Zcl, " status: ResourceExhausted (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved8a: + ChipLogProgress(Zcl, " status: Reserved8a (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::NotFound: + ChipLogProgress(Zcl, " status: NotFound (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnreportableAttribute: + ChipLogProgress(Zcl, " status: UnreportableAttribute (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidDataType: + ChipLogProgress(Zcl, " status: InvalidDataType (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved8e: + ChipLogProgress(Zcl, " status: Reserved8e (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedRead: + ChipLogProgress(Zcl, " status: UnsupportedRead (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved90: + ChipLogProgress(Zcl, " status: Reserved90 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved91: + ChipLogProgress(Zcl, " status: Reserved91 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved92: + ChipLogProgress(Zcl, " status: Reserved92 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved93: + ChipLogProgress(Zcl, " status: Reserved93 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Timeout: + ChipLogProgress(Zcl, " status: Timeout (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved95: + ChipLogProgress(Zcl, " status: Reserved95 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved96: + ChipLogProgress(Zcl, " status: Reserved96 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved97: + ChipLogProgress(Zcl, " status: Reserved97 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved98: + ChipLogProgress(Zcl, " status: Reserved98 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved99: + ChipLogProgress(Zcl, " status: Reserved99 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved9a: + ChipLogProgress(Zcl, " status: Reserved9a (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::ConstraintError: + ChipLogProgress(Zcl, " status: ConstraintError (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Busy: + ChipLogProgress(Zcl, " status: Busy (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc0: + ChipLogProgress(Zcl, " status: Reservedc0 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc1: + ChipLogProgress(Zcl, " status: Reservedc1 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc2: + ChipLogProgress(Zcl, " status: Reservedc2 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedCluster: + ChipLogProgress(Zcl, " status: UnsupportedCluster (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc4: + ChipLogProgress(Zcl, " status: Reservedc4 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::NoUpstreamSubscription: + ChipLogProgress(Zcl, " status: NoUpstreamSubscription (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidArgument: + ChipLogProgress(Zcl, " status: InvalidArgument (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + default: + ChipLogError(Zcl, "Unknown status: 0x%04" PRIx16, Protocols::InteractionModel::ToUint16(status)); + break; + } +} + void LogStringAttribute(const uint8_t * string, const uint16_t length, const bool isAscii) { if (isAscii) @@ -293,293 +432,88 @@ bool IMDefaultResponseCallback(const chip::app::Command * commandObj, EmberAfSta return true; } -bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * message, uint16_t messageLen) +template <> +void BasicAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure) { - ChipLogProgress(Zcl, "ReadAttributesResponse:"); - ChipLogProgress(Zcl, " ClusterId: 0x%04x", clusterId); - - GET_RESPONSE_CALLBACKS("emberAfReadAttributesResponseCallback"); + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t * val; + uint32_t len; - // struct readAttributeResponseRecord[] - while (messageLen) + if (data->GetType() != chip::TLV::kTLVType_ByteString && data->GetType() != chip::TLV::kTLVType_UTF8String) { - CHECK_MESSAGE_LENGTH(2); - uint16_t attributeId = chip::Encoding::LittleEndian::Read16(message); // attribId - ChipLogProgress(Zcl, " attributeId: 0x%04x", attributeId); - - CHECK_MESSAGE_LENGTH(1); - uint8_t status = chip::Encoding::Read8(message); // zclStatus - LogStatus(status); - - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - CHECK_MESSAGE_LENGTH(1); - uint8_t attributeType = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " attributeType: 0x%02x", attributeType); - - switch (attributeType) - { - case 0x00: // nodata / No data - case 0x0A: // data24 / 24-bit data - case 0x0C: // data40 / 40-bit data - case 0x0D: // data48 / 48-bit data - case 0x0E: // data56 / 56-bit data - case 0x1A: // map24 / 24-bit bitmap - case 0x1C: // map40 / 40-bit bitmap - case 0x1D: // map48 / 48-bit bitmap - case 0x1E: // map56 / 56-bit bitmap - case 0x22: // uint24 / Unsigned 24-bit integer - case 0x24: // uint40 / Unsigned 40-bit integer - case 0x25: // uint48 / Unsigned 48-bit integer - case 0x26: // uint56 / Unsigned 56-bit integer - case 0x2A: // int24 / Signed 24-bit integer - case 0x2C: // int40 / Signed 40-bit integer - case 0x2D: // int48 / Signed 48-bit integer - case 0x2E: // int56 / Signed 56-bit integer - case 0x38: // semi / Semi-precision - case 0x39: // single / Single precision - case 0x3A: // double / Double precision - case 0x49: // struct / Structure - case 0x50: // set / Set - case 0x51: // bag / Bag - case 0xE0: // ToD / Time of day - { - ChipLogError(Zcl, "attributeType 0x%02x is not supported", attributeType); - Callback::Callback * cb = Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - return true; - } - - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - { - // Short Strings must contains at least one byte for the length - CHECK_MESSAGE_LENGTH(1); - uint8_t length = chip::Encoding::Read8(message); - - // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. - if (length == 0xFF) - { - length = 0; - } - - CHECK_MESSAGE_LENGTH(length); - LogStringAttribute(message, length, attributeType == 0x42); - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, chip::ByteSpan(message, length)); - break; - } - - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string - { - // Long Strings must contains at least two bytes for the length - CHECK_MESSAGE_LENGTH(2); - uint16_t length = chip::Encoding::LittleEndian::Read16(message); - - // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. - if (length == 0xFFFF) - { - length = 0; - } - - CHECK_MESSAGE_LENGTH(length); - LogStringAttribute(message, length, attributeType == 0x44); - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, chip::ByteSpan(message, length)); - break; - } - case 0x48: // array / Array - { - CHECK_MESSAGE_LENGTH(2); - uint16_t count = chip::Encoding::LittleEndian::Read16(message); - ChipLogProgress(Zcl, " count: %" PRIu16 , count); - - switch (clusterId) - { -{{#chip_client_clusters}} -{{#if (chip_server_has_list_attributes)}} - case {{asHex code 4}}: - switch (attributeId) - { -{{#chip_server_cluster_attributes}} - {{#if isList}} - case {{asHex code 4}}: // {{type}} - { - {{chipType}} data[count]; - for (size_t i = 0; i < count; i++) - { - {{#if isStruct}} - {{#chip_attribute_list_entryTypes}} - {{#if (isString type)}} - CHECK_STATUS(ReadByteSpan(message, {{size}}, &data[i].{{name}})); - messageLen = static_cast(messageLen - {{size}}); - {{else}} - CHECK_MESSAGE_LENGTH({{size}}); - data[i].{{name}} = emberAfGet{{asReadType type}}(message, 0, {{size}}); - {{/if}} - message += {{size}}; - {{/chip_attribute_list_entryTypes}} - {{else}} - {{#if (isString type)}} - CHECK_STATUS(ReadByteSpan(message, messageLen, &data[i])); - uint16_t entryLength = static_cast(data[i].size() + kByteSpanSizeLengthInBytes); - messageLen = static_cast(messageLen - entryLength); - message += entryLength; - {{else}} - CHECK_MESSAGE_LENGTH({{size}}); - data[i] = emberAfGet{{asReadType type}}(message, 0, {{size}}); - message += {{size}}; - {{/if}} - {{/if}} - } - - Callback::Callback<{{asCamelCased parent.name false}}{{asCamelCased name false}}ListAttributeCallback> * cb = Callback::Callback<{{asCamelCased parent.name false}}{{asCamelCased name false}}ListAttributeCallback>::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - {{/if}} -{{/chip_server_cluster_attributes}} - } - break; -{{/if}} -{{/chip_client_clusters}} - } - break; - } - - case 0x08: // data8 / 8-bit data - case 0x18: // map8 / 8-bit bitmap - case 0x20: // uint8 / Unsigned 8-bit integer - case 0x30: // enum8 / 8-bit enumeration - { - CHECK_MESSAGE_LENGTH(1); - uint8_t value = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " value: 0x%02x", value); - - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x09: // data16 / 16-bit data - case 0x19: // map16 / 16-bit bitmap - case 0x21: // uint16 / Unsigned 16-bit integer - case 0x31: // enum16 / 16-bit enumeration - case 0xE8: // clusterId / Cluster ID - case 0xE9: // attribId / Attribute ID - case 0xEA: // bacOID / BACnet OID - case 0xF1: // key128 / 128-bit security key - case 0xFF: // unk / Unknown - { - CHECK_MESSAGE_LENGTH(2); - uint16_t value = chip::Encoding::LittleEndian::Read16(message); - ChipLogProgress(Zcl, " value: 0x%04x", value); - - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x0B: // data32 / 32-bit data - case 0x1B: // map32 / 32-bit bitmap - case 0x23: // uint32 / Unsigned 32-bit integer - case 0xE1: // date / Date - case 0xE2: // UTC / UTCTime - { - CHECK_MESSAGE_LENGTH(4); - uint32_t value = chip::Encoding::LittleEndian::Read32(message); - ChipLogProgress(Zcl, " value: 0x%08x", value); - - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x0F: // data64 / 64-bit data - case 0x1F: // map64 / 64-bit bitmap - case 0x27: // uint64 / Unsigned 64-bit integer - case 0xF0: // EUI64 / IEEE address - { - CHECK_MESSAGE_LENGTH(8); - uint64_t value = chip::Encoding::LittleEndian::Read64(message); - ChipLogProgress(Zcl, " value: 0x" ChipLogFormatX64, ChipLogValueX64(value)); - - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x10: // bool / Boolean - { - CHECK_MESSAGE_LENGTH(1); - uint8_t value = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " value: %d", value); - - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x28: // int8 / Signed 8-bit integer - { - CHECK_MESSAGE_LENGTH(1); - int8_t value = chip::CastToSigned(chip::Encoding::Read8(message)); - ChipLogProgress(Zcl, " value: %" PRId8, value); - - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x29: // int16 / Signed 16-bit integer - { - CHECK_MESSAGE_LENGTH(2); - int16_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read16(message)); - ChipLogProgress(Zcl, " value: %" PRId16, value); - - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } + err = CHIP_ERROR_INVALID_ARGUMENT; + } + else + { + err = data->GetDataPtr(val); + len = data->GetLength(); + } - case 0x2B: // int32 / Signed 32-bit integer - { - CHECK_MESSAGE_LENGTH(4); - int32_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read32(message)); - ChipLogProgress(Zcl, " value: %" PRId32, value); + if (CHIP_NO_ERROR == err) + { + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onSuccess); + cb->mCall(cb->mContext, chip::ByteSpan(val, len)); + } + else + { + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onFailure); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } +} - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } +bool IMReadReportAttributesResponseCallback(const app::ReadClient * apReadClient, const app::ClusterInfo & aPath, + TLV::TLVReader * apData, Protocols::InteractionModel::ProtocolCode status) +{ + ChipLogProgress(Zcl, "ReadAttributesResponse:"); + ChipLogProgress(Zcl, " ClusterId: 0x%04x", aPath.mClusterId); - case 0x2F: // int64 / Signed 64-bit integer - { - CHECK_MESSAGE_LENGTH(8); - int64_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read64(message)); - ChipLogProgress(Zcl, " value: %" PRId64, value); + Callback::Cancelable * onSuccessCallback = nullptr; + Callback::Cancelable * onFailureCallback = nullptr; + app::TLVDataFilter tlvFilter = nullptr; + NodeId sourceId = aPath.mNodeId; + // In CHIPClusters.cpp, we are using sequenceNumber as application identifier. + uint8_t sequenceNumber = static_cast(apReadClient->GetAppIdentifier()); + CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback, &tlvFilter); - Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - } + if (CHIP_NO_ERROR != err) + { + if (onSuccessCallback == nullptr) + { + ChipLogDetail(Zcl, "%s: Missing success callback", __FUNCTION__); } - else + + if (onFailureCallback == nullptr) { - Callback::Callback * cb = Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, status); + ChipLogDetail(Zcl, "%s: Missing failure callback", __FUNCTION__); } - // The current code is written matching the current API where there is a single attribute read - // per read command. So if multiple attributes are read at the same time, something is wrong - // somewhere. - if (messageLen) + if (tlvFilter == nullptr) { - ChipLogError(Zcl, "Multiple attributes read at the same time. Something went wrong."); - break; + ChipLogDetail(Zcl, "%s: Missing TLV Data Filter", __FUNCTION__); } + return true; + } + + uint16_t attributeId = aPath.mFieldId; // attribId + ChipLogProgress(Zcl, " attributeId: 0x%04x", attributeId); + LogIMStatus(status); + + if (status == Protocols::InteractionModel::ProtocolCode::Success && apData != nullptr) + { + chip::TLV::TLVType attributeType = apData->GetType(); + ChipLogProgress(Zcl, " attribute TLV Type: 0x%02x", attributeType); + tlvFilter(apData, onSuccessCallback, onFailureCallback); + } + else + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + // TODO: Should change failure callbacks to accept uint16 status code. + cb->mCall(cb->mContext, static_cast(Protocols::InteractionModel::ToUint16(status))); } return true; @@ -791,6 +725,86 @@ bool emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16 return true; } +static EmberAfStatus PrepareListFromTLV(TLV::TLVReader * tlvData, const uint8_t *& message, uint16_t & messageLen) +{ + CHIP_ERROR tlvError = CHIP_NO_ERROR; + TLV::TLVReader reader; + TLV::TLVType type; + reader.Init(*tlvData); + reader.EnterContainer(type); + tlvError = reader.Next(); + if (tlvError != CHIP_NO_ERROR && tlvError != CHIP_END_OF_TLV && chip::CanCastTo(reader.GetLength())) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + if (tlvError == CHIP_NO_ERROR) + { + tlvError = reader.GetDataPtr(message); + messageLen = static_cast(reader.GetLength()); + } + if (tlvError != CHIP_NO_ERROR) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + reader.ExitContainer(type); + return EMBER_ZCL_STATUS_SUCCESS; +} + +{{#chip_client_clusters}} +{{#if (chip_server_has_list_attributes)}} +{{#chip_server_cluster_attributes}} +{{#if isList}} +void {{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}ListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + {{chipType}} data[count]; + for (size_t i = 0; i < count; i++) + { + {{#if isStruct}} + {{#chip_attribute_list_entryTypes}} + {{#if (isString type)}} + CHECK_STATUS_VOID(ReadByteSpan(message, {{size}}, &data[i].{{name}})); + messageLen = static_cast(messageLen - {{size}}); + {{else}} + CHECK_MESSAGE_LENGTH_VOID({{size}}); + data[i].{{name}} = emberAfGet{{asReadType type}}(message, 0, {{size}}); + {{/if}} + message += {{size}}; + {{/chip_attribute_list_entryTypes}} + {{else}} + {{#if (isString type)}} + CHECK_STATUS_VOID(ReadByteSpan(message, messageLen, &data[i])); + uint16_t entryLength = static_cast(data[i].size() + kByteSpanSizeLengthInBytes); + messageLen = static_cast(messageLen - entryLength); + message += entryLength; + {{else}} + CHECK_MESSAGE_LENGTH_VOID({{size}}); + data[i] = emberAfGet{{asReadType type}}(message, 0, {{size}}); + message += {{size}}; + {{/if}} + {{/if}} + } + Callback::Callback<{{asCamelCased parent.name false}}{{asCamelCased name false}}ListAttributeCallback> * cb = Callback::Callback<{{asCamelCased parent.name false}}{{asCamelCased name false}}ListAttributeCallback>::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +{{/if}} +{{/chip_server_cluster_attributes}} +{{/if}} +{{/chip_client_clusters}} + {{#chip_client_clusters}} {{#if (user_cluster_has_enabled_command name side)}} {{#all_user_cluster_commands}} diff --git a/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt b/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt index 8f46fea6e4b213..f477c6a56a3f55 100644 --- a/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt +++ b/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt @@ -3,16 +3,20 @@ {{#if (chip_has_client_clusters)}} #pragma once -#include +#include +#include #include #include +#include +#include #include -#include // Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus // instead of IM status code. // #6308 should handle IM error code on the application side, either modify this function or remove this. bool IMDefaultResponseCallback(const chip::app::Command * commandObj, EmberAfStatus status); +bool IMReadReportAttributesResponseCallback(const chip::app::ReadClient * apReadClient, const chip::app::ClusterInfo & aPath, + chip::TLV::TLVReader * apData, chip::Protocols::InteractionModel::ProtocolCode status); // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -27,6 +31,38 @@ typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); +typedef void (*AttributeResponseFilter)(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, chip::Callback::Cancelable * onFailure); + +/** + * BasicAttributeFilter accepts the actual type of onSuccess callback as template parameter. + * It will check whether the type of the TLV data is expected by onSuccess callback. + * If a non expected value received, onFailure callback will be called with EMBER_ZCL_STATUS_INVALID_VALUE. + */ +template +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + typename chip::FunctionTraits::template ArgType<1> value; + + if ((err = data->Get(value)) == CHIP_NO_ERROR) + { + chip::Callback::Callback * cb = chip::Callback::Callback::FromCancelable(onSuccess); + cb->mCall(cb->mContext, value); + } + else + { + ChipLogError(Zcl, "Failed to get value from TLV data for attribute reading response: %d", err); + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onFailure); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } +} + +template <> +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure); + typedef void (*ReadReportingConfigurationReportedCallback)(void* context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void* context, uint16_t timeout); @@ -48,6 +84,7 @@ typedef void (*{{asCamelCased parent.name false}}Cluster{{asCamelCased name fals {{#chip_client_clusters}} {{#chip_server_cluster_attributes}} {{#if isList}} +void {{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}ListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, chip::Callback::Cancelable * onFailureCallback); typedef void (*{{asCamelCased parent.name false}}{{asCamelCased name false}}ListAttributeCallback)(void * context, uint16_t count, {{chipType}} * entries); {{/if}} {{/chip_server_cluster_attributes}} diff --git a/src/app/zap-templates/templates/app/CHIPClusters-src.zapt b/src/app/zap-templates/templates/app/CHIPClusters-src.zapt index a6a2f45fd7ea71..8b8525e5cd7fa0 100644 --- a/src/app/zap-templates/templates/app/CHIPClusters-src.zapt +++ b/src/app/zap-templates/templates/app/CHIPClusters-src.zapt @@ -5,6 +5,7 @@ #include "chip-zcl-zpro-codec-api.h" #include +#include namespace chip { namespace Controller { @@ -74,9 +75,18 @@ CHIP_ERROR {{asCamelCased name false}}Cluster::DiscoverAttributes(Callback::Canc {{#chip_server_cluster_attributes}} CHIP_ERROR {{asCamelCased parent.name false}}Cluster::ReadAttribute{{asCamelCased name false}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encode{{asCamelCased parent.name false}}ClusterRead{{asCamelCased name false}}Attribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = {{asHex code 4}}; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, +{{#if isList}} + {{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}ListAttributeFilter +{{else}} + BasicAttributeFilter<{{asCallbackAttributeType atomicTypeId}}AttributeCallback> +{{/if}} + ); } {{#if (isWritableAttribute)}} 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 13198d56ef0d53..5269235cbedc30 100644 --- a/src/app/zap-templates/templates/app/callback-stub-src.zapt +++ b/src/app/zap-templates/templates/app/callback-stub-src.zapt @@ -377,23 +377,6 @@ void __attribute__((weak)) emberAfPostAttributeChangeCallback( { } -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback( - ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/src/app/zap-templates/templates/app/callback.zapt b/src/app/zap-templates/templates/app/callback.zapt index 61cc5d70d8cd2a..f5919228d965c8 100644 --- a/src/app/zap-templates/templates/app/callback.zapt +++ b/src/app/zap-templates/templates/app/callback.zapt @@ -414,19 +414,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/src/controller/CHIPDevice.cpp b/src/controller/CHIPDevice.cpp index ea41e8d7310953..5daf9ad0422cd7 100644 --- a/src/controller/CHIPDevice.cpp +++ b/src/controller/CHIPDevice.cpp @@ -616,9 +616,10 @@ CHIP_ERROR Device::EstablishConnectivity(Callback::Callback * return CHIP_NO_ERROR; } -void Device::AddResponseHandler(uint8_t seqNum, Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) +void Device::AddResponseHandler(uint8_t seqNum, Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, + app::TLVDataFilter tlvDataFilter) { - mCallbacksMgr.AddResponseCallback(mDeviceId, seqNum, onSuccessCallback, onFailureCallback); + mCallbacksMgr.AddResponseCallback(mDeviceId, seqNum, onSuccessCallback, onFailureCallback, tlvDataFilter); } void Device::CancelResponseHandler(uint8_t seqNum) @@ -654,6 +655,31 @@ void Device::AddReportHandler(EndpointId endpoint, ClusterId cluster, AttributeI mCallbacksMgr.AddReportCallback(mDeviceId, endpoint, cluster, attribute, onReportCallback); } +CHIP_ERROR Device::SendReadAttributeRequest(app::AttributePathParams aPath, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback, app::TLVDataFilter aTlvDataFilter) +{ + bool loadedSecureSession = false; + uint8_t seqNum = GetNextSequenceNumber(); + aPath.mNodeId = GetDeviceId(); + + ReturnErrorOnFailure(LoadSecureSessionParametersIfNeeded(loadedSecureSession)); + + if (onSuccessCallback != nullptr || onFailureCallback != nullptr) + { + AddResponseHandler(seqNum, onSuccessCallback, onFailureCallback, aTlvDataFilter); + } + // The application context is used to identify different requests from client applicaiton the type of it is intptr_t, here we + // use the seqNum. + CHIP_ERROR err = chip::app::InteractionModelEngine::GetInstance()->SendReadRequest( + GetDeviceId(), 0, &mSecureSession, nullptr /*event path params list*/, 0, &aPath, 1, 0 /* event number */, + seqNum /* application context */); + if (err != CHIP_NO_ERROR) + { + CancelResponseHandler(seqNum); + } + return err; +} + Device::~Device() { if (mExchangeMgr) diff --git a/src/controller/CHIPDevice.h b/src/controller/CHIPDevice.h index 99b807a063903e..3fa1da6a016544 100644 --- a/src/controller/CHIPDevice.h +++ b/src/controller/CHIPDevice.h @@ -140,6 +140,9 @@ class DLL_EXPORT Device : public Messaging::ExchangeDelegate, public SessionEsta std::move(message)); } + CHIP_ERROR SendReadAttributeRequest(app::AttributePathParams aPath, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback, app::TLVDataFilter aTlvDataFilter); + /** * @brief * Send the command in internal command sender. @@ -332,7 +335,8 @@ class DLL_EXPORT Device : public Messaging::ExchangeDelegate, public SessionEsta PASESessionSerializable & GetPairing() { return mPairing; } uint8_t GetNextSequenceNumber() { return mSequenceNumber++; }; - void AddResponseHandler(uint8_t seqNum, Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + void AddResponseHandler(uint8_t seqNum, Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, + app::TLVDataFilter tlvDataFilter = nullptr); void CancelResponseHandler(uint8_t seqNum); void AddReportHandler(EndpointId endpoint, ClusterId cluster, AttributeId attribute, Callback::Cancelable * onReportCallback); @@ -347,6 +351,12 @@ class DLL_EXPORT Device : public Messaging::ExchangeDelegate, public SessionEsta void OperationalCertProvisioned(); bool IsOperationalCertProvisioned() const { return mDeviceOperationalCertProvisioned; } + CHIP_ERROR LoadSecureSessionParametersIfNeeded() + { + bool loadedSecureSession = false; + return LoadSecureSessionParametersIfNeeded(loadedSecureSession); + }; + //////////// SessionEstablishmentDelegate Implementation /////////////// void OnSessionEstablishmentError(CHIP_ERROR error) override; void OnSessionEstablished() override; diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 8d871281139606..9f0548a468814a 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -1555,6 +1555,22 @@ CHIP_ERROR DeviceControllerInteractionModelDelegate::CommandResponseProcessed(co // CommandResponseStatus, CommandResponseProtocolError and CommandResponseError. return CHIP_NO_ERROR; } + +void DeviceControllerInteractionModelDelegate::OnReportData(const app::ReadClient * apReadClient, const app::ClusterInfo & aPath, + TLV::TLVReader * apData, + Protocols::InteractionModel::ProtocolCode status) +{ + IMReadReportAttributesResponseCallback(apReadClient, aPath, apData, status); +} + +CHIP_ERROR DeviceControllerInteractionModelDelegate::ReportError(const app::ReadClient * apReadClient, CHIP_ERROR aError) +{ + app::ClusterInfo path; + path.mNodeId = apReadClient->GetExchangeContext()->GetSecureSession().GetPeerNodeId(); + IMReadReportAttributesResponseCallback(apReadClient, path, nullptr, Protocols::InteractionModel::ProtocolCode::Failure); + return CHIP_NO_ERROR; +} + void BasicSuccess(void * context, uint16_t val) { ChipLogProgress(Controller, "Received success response 0x%x\n", val); diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 8a2bb79271ccdf..e11dd88ef03e84 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -173,6 +173,10 @@ class DeviceControllerInteractionModelDelegate : public chip::app::InteractionMo CHIP_ERROR CommandResponseError(const app::CommandSender * apCommandSender, CHIP_ERROR aError) override; CHIP_ERROR CommandResponseProcessed(const app::CommandSender * apCommandSender) override; + + void OnReportData(const app::ReadClient * apReadClient, const app::ClusterInfo & aPath, TLV::TLVReader * apData, + Protocols::InteractionModel::ProtocolCode status) override; + CHIP_ERROR ReportError(const app::ReadClient * apReadClient, CHIP_ERROR aError) override; }; /** diff --git a/src/controller/data_model/gen/CHIPClientCallbacks.cpp b/src/controller/data_model/gen/CHIPClientCallbacks.cpp index 24629e1816c8cb..6d9aa6d1f45b54 100644 --- a/src/controller/data_model/gen/CHIPClientCallbacks.cpp +++ b/src/controller/data_model/gen/CHIPClientCallbacks.cpp @@ -37,7 +37,7 @@ using namespace ::chip::app::List; constexpr uint16_t kByteSpanSizeLengthInBytes = 2; -#define CHECK_STATUS(error) \ +#define CHECK_STATUS_WITH_RETVAL(error, retval) \ if (CHIP_NO_ERROR != error) \ { \ ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \ @@ -47,10 +47,13 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } -#define CHECK_MESSAGE_LENGTH(value) \ +#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true) +#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, ) + +#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \ if (!chip::CanCastTo(value)) \ { \ ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \ @@ -60,7 +63,7 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } \ \ if (messageLen < value) \ @@ -72,11 +75,14 @@ constexpr uint16_t kByteSpanSizeLengthInBytes = 2; Callback::Callback::FromCancelable(onFailureCallback); \ cb->mCall(cb->mContext, static_cast(EMBER_ZCL_STATUS_INVALID_VALUE)); \ } \ - return true; \ + return retval; \ } \ \ messageLen = static_cast(messageLen - static_cast(value)); +#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true) +#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, ) + #define GET_RESPONSE_CALLBACKS(name) \ Callback::Cancelable * onSuccessCallback = nullptr; \ Callback::Cancelable * onFailureCallback = nullptr; \ @@ -241,6 +247,139 @@ void LogStatus(uint8_t status) } } +static void LogIMStatus(Protocols::InteractionModel::ProtocolCode status) +{ + switch (status) + { + case Protocols::InteractionModel::ProtocolCode::Success: + ChipLogProgress(Zcl, " status: Success (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Failure: + ChipLogProgress(Zcl, " status: Failure (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidSubscription: + ChipLogProgress(Zcl, " status: InvalidSubscription (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedAccess: + ChipLogProgress(Zcl, " status: UnsupportedAccess (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedEndpoint: + ChipLogProgress(Zcl, " status: UnsupportedEndpoint (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidAction: + ChipLogProgress(Zcl, " status: InvalidAction (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedCommand: + ChipLogProgress(Zcl, " status: UnsupportedCommand (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved82: + ChipLogProgress(Zcl, " status: Reserved82 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved83: + ChipLogProgress(Zcl, " status: Reserved83 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved84: + ChipLogProgress(Zcl, " status: Reserved84 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidCommand: + ChipLogProgress(Zcl, " status: InvalidCommand (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedAttribute: + ChipLogProgress(Zcl, " status: UnsupportedAttribute (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidValue: + ChipLogProgress(Zcl, " status: InvalidValue (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedWrite: + ChipLogProgress(Zcl, " status: UnsupportedWrite (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::ResourceExhausted: + ChipLogProgress(Zcl, " status: ResourceExhausted (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved8a: + ChipLogProgress(Zcl, " status: Reserved8a (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::NotFound: + ChipLogProgress(Zcl, " status: NotFound (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnreportableAttribute: + ChipLogProgress(Zcl, " status: UnreportableAttribute (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidDataType: + ChipLogProgress(Zcl, " status: InvalidDataType (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved8e: + ChipLogProgress(Zcl, " status: Reserved8e (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedRead: + ChipLogProgress(Zcl, " status: UnsupportedRead (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved90: + ChipLogProgress(Zcl, " status: Reserved90 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved91: + ChipLogProgress(Zcl, " status: Reserved91 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved92: + ChipLogProgress(Zcl, " status: Reserved92 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved93: + ChipLogProgress(Zcl, " status: Reserved93 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Timeout: + ChipLogProgress(Zcl, " status: Timeout (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved95: + ChipLogProgress(Zcl, " status: Reserved95 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved96: + ChipLogProgress(Zcl, " status: Reserved96 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved97: + ChipLogProgress(Zcl, " status: Reserved97 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved98: + ChipLogProgress(Zcl, " status: Reserved98 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved99: + ChipLogProgress(Zcl, " status: Reserved99 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reserved9a: + ChipLogProgress(Zcl, " status: Reserved9a (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::ConstraintError: + ChipLogProgress(Zcl, " status: ConstraintError (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Busy: + ChipLogProgress(Zcl, " status: Busy (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc0: + ChipLogProgress(Zcl, " status: Reservedc0 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc1: + ChipLogProgress(Zcl, " status: Reservedc1 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc2: + ChipLogProgress(Zcl, " status: Reservedc2 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::UnsupportedCluster: + ChipLogProgress(Zcl, " status: UnsupportedCluster (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::Reservedc4: + ChipLogProgress(Zcl, " status: Reservedc4 (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::NoUpstreamSubscription: + ChipLogProgress(Zcl, " status: NoUpstreamSubscription (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + case Protocols::InteractionModel::ProtocolCode::InvalidArgument: + ChipLogProgress(Zcl, " status: InvalidArgument (0x%04" PRIx16 ")", Protocols::InteractionModel::ToUint16(status)); + break; + default: + ChipLogError(Zcl, "Unknown status: 0x%04" PRIx16, Protocols::InteractionModel::ToUint16(status)); + break; + } +} + void LogStringAttribute(const uint8_t * string, const uint16_t length, const bool isAscii) { if (isAscii) @@ -312,881 +451,87 @@ bool IMDefaultResponseCallback(const chip::app::Command * commandObj, EmberAfSta return true; } -bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * message, uint16_t messageLen) +template <> +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure) { - ChipLogProgress(Zcl, "ReadAttributesResponse:"); - ChipLogProgress(Zcl, " ClusterId: 0x%04x", clusterId); + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t * val; + uint32_t len; - GET_RESPONSE_CALLBACKS("emberAfReadAttributesResponseCallback"); - - // struct readAttributeResponseRecord[] - while (messageLen) + if (data->GetType() != chip::TLV::kTLVType_ByteString && data->GetType() != chip::TLV::kTLVType_UTF8String) { - CHECK_MESSAGE_LENGTH(2); - uint16_t attributeId = chip::Encoding::LittleEndian::Read16(message); // attribId - ChipLogProgress(Zcl, " attributeId: 0x%04x", attributeId); - - CHECK_MESSAGE_LENGTH(1); - uint8_t status = chip::Encoding::Read8(message); // zclStatus - LogStatus(status); - - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - CHECK_MESSAGE_LENGTH(1); - uint8_t attributeType = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " attributeType: 0x%02x", attributeType); - - switch (attributeType) - { - case 0x00: // nodata / No data - case 0x0A: // data24 / 24-bit data - case 0x0C: // data40 / 40-bit data - case 0x0D: // data48 / 48-bit data - case 0x0E: // data56 / 56-bit data - case 0x1A: // map24 / 24-bit bitmap - case 0x1C: // map40 / 40-bit bitmap - case 0x1D: // map48 / 48-bit bitmap - case 0x1E: // map56 / 56-bit bitmap - case 0x22: // uint24 / Unsigned 24-bit integer - case 0x24: // uint40 / Unsigned 40-bit integer - case 0x25: // uint48 / Unsigned 48-bit integer - case 0x26: // uint56 / Unsigned 56-bit integer - case 0x2A: // int24 / Signed 24-bit integer - case 0x2C: // int40 / Signed 40-bit integer - case 0x2D: // int48 / Signed 48-bit integer - case 0x2E: // int56 / Signed 56-bit integer - case 0x38: // semi / Semi-precision - case 0x39: // single / Single precision - case 0x3A: // double / Double precision - case 0x49: // struct / Structure - case 0x50: // set / Set - case 0x51: // bag / Bag - case 0xE0: // ToD / Time of day - { - ChipLogError(Zcl, "attributeType 0x%02x is not supported", attributeType); - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); - return true; - } - - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - { - // Short Strings must contains at least one byte for the length - CHECK_MESSAGE_LENGTH(1); - uint8_t length = chip::Encoding::Read8(message); - - // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. - if (length == 0xFF) - { - length = 0; - } - - CHECK_MESSAGE_LENGTH(length); - LogStringAttribute(message, length, attributeType == 0x42); - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, chip::ByteSpan(message, length)); - break; - } - - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string - { - // Long Strings must contains at least two bytes for the length - CHECK_MESSAGE_LENGTH(2); - uint16_t length = chip::Encoding::LittleEndian::Read16(message); - - // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. - if (length == 0xFFFF) - { - length = 0; - } - - CHECK_MESSAGE_LENGTH(length); - LogStringAttribute(message, length, attributeType == 0x44); - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, chip::ByteSpan(message, length)); - break; - } - case 0x48: // array / Array - { - CHECK_MESSAGE_LENGTH(2); - uint16_t count = chip::Encoding::LittleEndian::Read16(message); - ChipLogProgress(Zcl, " count: %" PRIu16, count); - - switch (clusterId) - { - case 0x050C: - switch (attributeId) - { - case 0x0000: // INT16U - { - uint16_t data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(2); - data[i] = emberAfGetInt16u(message, 0, 2); - message += 2; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x050B: - switch (attributeId) - { - case 0x0000: // AudioOutputInfo - { - _AudioOutputInfo data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(1); - data[i].index = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].outputType = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_STATUS(ReadByteSpan(message, 34, &data[i].name)); - messageLen = static_cast(messageLen - 34); - message += 34; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x050A: - switch (attributeId) - { - case 0x0000: // OCTET_STRING - { - chip::ByteSpan data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_STATUS(ReadByteSpan(message, messageLen, &data[i])); - uint16_t entryLength = static_cast(data[i].size() + kByteSpanSizeLengthInBytes); - messageLen = static_cast(messageLen - entryLength); - message += entryLength; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x0001: // ContentLaunchStreamingType - { - uint8_t data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(1); - data[i] = emberAfGetInt8u(message, 0, 1); - message += 1; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x001D: - switch (attributeId) - { - case 0x0000: // DeviceType - { - _DeviceType data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(4); - data[i].type = emberAfGetInt32u(message, 0, 4); - message += 4; - CHECK_MESSAGE_LENGTH(2); - data[i].revision = emberAfGetInt16u(message, 0, 2); - message += 2; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x0001: // CLUSTER_ID - { - chip::ClusterId data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(2); - data[i] = emberAfGetInt16u(message, 0, 2); - message += 2; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x0002: // CLUSTER_ID - { - chip::ClusterId data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(2); - data[i] = emberAfGetInt16u(message, 0, 2); - message += 2; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x0003: // ENDPOINT_ID - { - chip::EndpointId data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(1); - data[i] = emberAfGetInt8u(message, 0, 1); - message += 1; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x0040: - switch (attributeId) - { - case 0x0000: // LabelStruct - { - _LabelStruct data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_STATUS(ReadByteSpan(message, 18, &data[i].label)); - messageLen = static_cast(messageLen - 18); - message += 18; - CHECK_STATUS(ReadByteSpan(message, 18, &data[i].value)); - messageLen = static_cast(messageLen - 18); - message += 18; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x0033: - switch (attributeId) - { - case 0x0000: // NetworkInterfaceType - { - _NetworkInterfaceType data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_STATUS(ReadByteSpan(message, 34, &data[i].Name)); - messageLen = static_cast(messageLen - 34); - message += 34; - CHECK_MESSAGE_LENGTH(1); - data[i].FabricConnected = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].OffPremiseServicesReachableIPv4 = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].OffPremiseServicesReachableIPv6 = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_STATUS(ReadByteSpan(message, 10, &data[i].HardwareAddress)); - messageLen = static_cast(messageLen - 10); - message += 10; - CHECK_MESSAGE_LENGTH(1); - data[i].Type = emberAfGetInt8u(message, 0, 1); - message += 1; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0xF004: - switch (attributeId) - { - case 0x0000: // GroupState - { - _GroupState data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(2); - data[i].VendorId = emberAfGetInt16u(message, 0, 2); - message += 2; - CHECK_MESSAGE_LENGTH(2); - data[i].VendorGroupId = emberAfGetInt16u(message, 0, 2); - message += 2; - CHECK_MESSAGE_LENGTH(2); - data[i].GroupKeySetIndex = emberAfGetInt16u(message, 0, 2); - message += 2; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x0001: // GroupKey - { - _GroupKey data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(2); - data[i].VendorId = emberAfGetInt16u(message, 0, 2); - message += 2; - CHECK_MESSAGE_LENGTH(2); - data[i].GroupKeyIndex = emberAfGetInt16u(message, 0, 2); - message += 2; - CHECK_STATUS(ReadByteSpan(message, 18, &data[i].GroupKeyRoot)); - messageLen = static_cast(messageLen - 18); - message += 18; - CHECK_MESSAGE_LENGTH(8); - data[i].GroupKeyEpochStartTime = emberAfGetInt64u(message, 0, 8); - message += 8; - CHECK_MESSAGE_LENGTH(1); - data[i].GroupKeySecurityPolicy = emberAfGetInt8u(message, 0, 1); - message += 1; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x0507: - switch (attributeId) - { - case 0x0000: // MediaInputInfo - { - _MediaInputInfo data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(1); - data[i].index = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].inputType = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_STATUS(ReadByteSpan(message, 34, &data[i].name)); - messageLen = static_cast(messageLen - 34); - message += 34; - CHECK_STATUS(ReadByteSpan(message, 34, &data[i].description)); - messageLen = static_cast(messageLen - 34); - message += 34; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x003E: - switch (attributeId) - { - case 0x0001: // FabricDescriptor - { - _FabricDescriptor data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(8); - data[i].FabricId = emberAfGetInt64u(message, 0, 8); - message += 8; - CHECK_MESSAGE_LENGTH(2); - data[i].VendorId = emberAfGetInt16u(message, 0, 2); - message += 2; - CHECK_MESSAGE_LENGTH(8); - data[i].NodeId = emberAfGetInt64u(message, 0, 8); - message += 8; - CHECK_STATUS(ReadByteSpan(message, 34, &data[i].Label)); - messageLen = static_cast(messageLen - 34); - message += 34; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x0504: - switch (attributeId) - { - case 0x0000: // TvChannelInfo - { - _TvChannelInfo data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(2); - data[i].majorNumber = emberAfGetInt16u(message, 0, 2); - message += 2; - CHECK_MESSAGE_LENGTH(2); - data[i].minorNumber = emberAfGetInt16u(message, 0, 2); - message += 2; - CHECK_STATUS(ReadByteSpan(message, 34, &data[i].name)); - messageLen = static_cast(messageLen - 34); - message += 34; - CHECK_STATUS(ReadByteSpan(message, 34, &data[i].callSign)); - messageLen = static_cast(messageLen - 34); - message += 34; - CHECK_STATUS(ReadByteSpan(message, 34, &data[i].affiliateCallSign)); - messageLen = static_cast(messageLen - 34); - message += 34; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x0505: - switch (attributeId) - { - case 0x0000: // NavigateTargetTargetInfo - { - _NavigateTargetTargetInfo data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(1); - data[i].identifier = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_STATUS(ReadByteSpan(message, 34, &data[i].name)); - messageLen = static_cast(messageLen - 34); - message += 34; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x050F: - switch (attributeId) - { - case 0x001A: // INT8U - { - uint8_t data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(1); - data[i] = emberAfGetInt8u(message, 0, 1); - message += 1; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x001B: // OCTET_STRING - { - chip::ByteSpan data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_STATUS(ReadByteSpan(message, messageLen, &data[i])); - uint16_t entryLength = static_cast(data[i].size() + kByteSpanSizeLengthInBytes); - messageLen = static_cast(messageLen - entryLength); - message += entryLength; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x001C: // TestListStructOctet - { - _TestListStructOctet data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(8); - data[i].fabricIndex = emberAfGetInt64u(message, 0, 8); - message += 8; - CHECK_STATUS(ReadByteSpan(message, 34, &data[i].operationalCert)); - messageLen = static_cast(messageLen - 34); - message += 34; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - case 0x0035: - switch (attributeId) - { - case 0x0007: // NeighborTable - { - _NeighborTable data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(8); - data[i].ExtAddress = emberAfGetInt64u(message, 0, 8); - message += 8; - CHECK_MESSAGE_LENGTH(4); - data[i].Age = emberAfGetInt32u(message, 0, 4); - message += 4; - CHECK_MESSAGE_LENGTH(2); - data[i].Rloc16 = emberAfGetInt16u(message, 0, 2); - message += 2; - CHECK_MESSAGE_LENGTH(4); - data[i].LinkFrameCounter = emberAfGetInt32u(message, 0, 4); - message += 4; - CHECK_MESSAGE_LENGTH(4); - data[i].MleFrameCounter = emberAfGetInt32u(message, 0, 4); - message += 4; - CHECK_MESSAGE_LENGTH(1); - data[i].LQI = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].AverageRssi = emberAfGetInt8s(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].LastRssi = emberAfGetInt8s(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].FrameErrorRate = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].MessageErrorRate = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].RxOnWhenIdle = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].FullThreadDevice = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].FullNetworkData = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].IsChild = emberAfGetInt8u(message, 0, 1); - message += 1; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x0008: // RouteTable - { - _RouteTable data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(8); - data[i].ExtAddress = emberAfGetInt64u(message, 0, 8); - message += 8; - CHECK_MESSAGE_LENGTH(2); - data[i].Rloc16 = emberAfGetInt16u(message, 0, 2); - message += 2; - CHECK_MESSAGE_LENGTH(1); - data[i].RouterId = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].NextHop = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].PathCost = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].LQIIn = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].LQIOut = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].Age = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].Allocated = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].LinkEstablished = emberAfGetInt8u(message, 0, 1); - message += 1; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x003B: // SecurityPolicy - { - _SecurityPolicy data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(2); - data[i].RotationTime = emberAfGetInt16u(message, 0, 2); - message += 2; - CHECK_MESSAGE_LENGTH(1); - data[i].Flags = emberAfGetInt8u(message, 0, 1); - message += 1; - } - - Callback::Callback * cb = - Callback::Callback::FromCancelable( - onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x003D: // OperationalDatasetComponents - { - _OperationalDatasetComponents data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(1); - data[i].ActiveTimestampPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].PendingTimestampPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].MasterKeyPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].NetworkNamePresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].ExtendedPanIdPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].MeshLocalPrefixPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].DelayPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].PanIdPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].ChannelPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].PskcPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].SecurityPolicyPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - CHECK_MESSAGE_LENGTH(1); - data[i].ChannelMaskPresent = emberAfGetInt8u(message, 0, 1); - message += 1; - } - - Callback::Callback * cb = - Callback::Callback:: - FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - case 0x003E: // NetworkFault - { - uint8_t data[count]; - for (size_t i = 0; i < count; i++) - { - CHECK_MESSAGE_LENGTH(1); - data[i] = emberAfGetInt8u(message, 0, 1); - message += 1; - } - - Callback::Callback * cb = - Callback::Callback:: - FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, count, data); - break; - } - } - break; - } - break; - } - - case 0x08: // data8 / 8-bit data - case 0x18: // map8 / 8-bit bitmap - case 0x20: // uint8 / Unsigned 8-bit integer - case 0x30: // enum8 / 8-bit enumeration - { - CHECK_MESSAGE_LENGTH(1); - uint8_t value = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " value: 0x%02x", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x09: // data16 / 16-bit data - case 0x19: // map16 / 16-bit bitmap - case 0x21: // uint16 / Unsigned 16-bit integer - case 0x31: // enum16 / 16-bit enumeration - case 0xE8: // clusterId / Cluster ID - case 0xE9: // attribId / Attribute ID - case 0xEA: // bacOID / BACnet OID - case 0xF1: // key128 / 128-bit security key - case 0xFF: // unk / Unknown - { - CHECK_MESSAGE_LENGTH(2); - uint16_t value = chip::Encoding::LittleEndian::Read16(message); - ChipLogProgress(Zcl, " value: 0x%04x", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x0B: // data32 / 32-bit data - case 0x1B: // map32 / 32-bit bitmap - case 0x23: // uint32 / Unsigned 32-bit integer - case 0xE1: // date / Date - case 0xE2: // UTC / UTCTime - { - CHECK_MESSAGE_LENGTH(4); - uint32_t value = chip::Encoding::LittleEndian::Read32(message); - ChipLogProgress(Zcl, " value: 0x%08x", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x0F: // data64 / 64-bit data - case 0x1F: // map64 / 64-bit bitmap - case 0x27: // uint64 / Unsigned 64-bit integer - case 0xF0: // EUI64 / IEEE address - { - CHECK_MESSAGE_LENGTH(8); - uint64_t value = chip::Encoding::LittleEndian::Read64(message); - ChipLogProgress(Zcl, " value: 0x" ChipLogFormatX64, ChipLogValueX64(value)); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - - case 0x10: // bool / Boolean - { - CHECK_MESSAGE_LENGTH(1); - uint8_t value = chip::Encoding::Read8(message); - ChipLogProgress(Zcl, " value: %d", value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } + err = CHIP_ERROR_INVALID_ARGUMENT; + } + else + { + err = data->GetDataPtr(val); + len = data->GetLength(); + } - case 0x28: // int8 / Signed 8-bit integer - { - CHECK_MESSAGE_LENGTH(1); - int8_t value = chip::CastToSigned(chip::Encoding::Read8(message)); - ChipLogProgress(Zcl, " value: %" PRId8, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } + if (CHIP_NO_ERROR == err) + { + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onSuccess); + cb->mCall(cb->mContext, chip::ByteSpan(val, len)); + } + else + { + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onFailure); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } +} - case 0x29: // int16 / Signed 16-bit integer - { - CHECK_MESSAGE_LENGTH(2); - int16_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read16(message)); - ChipLogProgress(Zcl, " value: %" PRId16, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } +bool IMReadReportAttributesResponseCallback(const app::ReadClient * apReadClient, const app::ClusterInfo & aPath, + TLV::TLVReader * apData, Protocols::InteractionModel::ProtocolCode status) +{ + ChipLogProgress(Zcl, "ReadAttributesResponse:"); + ChipLogProgress(Zcl, " ClusterId: 0x%04x", aPath.mClusterId); - case 0x2B: // int32 / Signed 32-bit integer - { - CHECK_MESSAGE_LENGTH(4); - int32_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read32(message)); - ChipLogProgress(Zcl, " value: %" PRId32, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } + Callback::Cancelable * onSuccessCallback = nullptr; + Callback::Cancelable * onFailureCallback = nullptr; + app::TLVDataFilter tlvFilter = nullptr; + NodeId sourceId = aPath.mNodeId; + // In CHIPClusters.cpp, we are using sequenceNumber as application identifier. + uint8_t sequenceNumber = static_cast(apReadClient->GetAppIdentifier()); + CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback, &tlvFilter); - case 0x2F: // int64 / Signed 64-bit integer - { - CHECK_MESSAGE_LENGTH(8); - int64_t value = chip::CastToSigned(chip::Encoding::LittleEndian::Read64(message)); - ChipLogProgress(Zcl, " value: %" PRId64, value); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, value); - break; - } - } + if (CHIP_NO_ERROR != err) + { + if (onSuccessCallback == nullptr) + { + ChipLogDetail(Zcl, "%s: Missing success callback", __FUNCTION__); } - else + + if (onFailureCallback == nullptr) { - Callback::Callback * cb = - Callback::Callback::FromCancelable(onFailureCallback); - cb->mCall(cb->mContext, status); + ChipLogDetail(Zcl, "%s: Missing failure callback", __FUNCTION__); } - // The current code is written matching the current API where there is a single attribute read - // per read command. So if multiple attributes are read at the same time, something is wrong - // somewhere. - if (messageLen) + if (tlvFilter == nullptr) { - ChipLogError(Zcl, "Multiple attributes read at the same time. Something went wrong."); - break; + ChipLogDetail(Zcl, "%s: Missing TLV Data Filter", __FUNCTION__); } + return true; + } + + uint16_t attributeId = aPath.mFieldId; // attribId + ChipLogProgress(Zcl, " attributeId: 0x%04x", attributeId); + LogIMStatus(status); + + if (status == Protocols::InteractionModel::ProtocolCode::Success && apData != nullptr) + { + chip::TLV::TLVType attributeType = apData->GetType(); + ChipLogProgress(Zcl, " attribute TLV Type: 0x%02x", attributeType); + tlvFilter(apData, onSuccessCallback, onFailureCallback); + } + else + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + // TODO: Should change failure callbacks to accept uint16 status code. + cb->mCall(cb->mContext, static_cast(Protocols::InteractionModel::ToUint16(status))); } return true; @@ -1404,6 +749,922 @@ bool emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16 return true; } +static EmberAfStatus PrepareListFromTLV(TLV::TLVReader * tlvData, const uint8_t *& message, uint16_t & messageLen) +{ + CHIP_ERROR tlvError = CHIP_NO_ERROR; + TLV::TLVReader reader; + TLV::TLVType type; + reader.Init(*tlvData); + reader.EnterContainer(type); + tlvError = reader.Next(); + if (tlvError != CHIP_NO_ERROR && tlvError != CHIP_END_OF_TLV && chip::CanCastTo(reader.GetLength())) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + if (tlvError == CHIP_NO_ERROR) + { + tlvError = reader.GetDataPtr(message); + messageLen = static_cast(reader.GetLength()); + } + if (tlvError != CHIP_NO_ERROR) + { + return EMBER_ZCL_STATUS_INVALID_VALUE; + } + reader.ExitContainer(type); + return EMBER_ZCL_STATUS_SUCCESS; +} + +void ApplicationLauncherClusterApplicationLauncherListListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + uint16_t data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(2); + data[i] = emberAfGetInt16u(message, 0, 2); + message += 2; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void AudioOutputClusterAudioOutputListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _AudioOutputInfo data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].index = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].outputType = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_STATUS_VOID(ReadByteSpan(message, 34, &data[i].name)); + messageLen = static_cast(messageLen - 34); + message += 34; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void ContentLauncherClusterAcceptsHeaderListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + chip::ByteSpan data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_STATUS_VOID(ReadByteSpan(message, messageLen, &data[i])); + uint16_t entryLength = static_cast(data[i].size() + kByteSpanSizeLengthInBytes); + messageLen = static_cast(messageLen - entryLength); + message += entryLength; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void ContentLauncherClusterSupportedStreamingTypesListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + uint8_t data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(1); + data[i] = emberAfGetInt8u(message, 0, 1); + message += 1; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void DescriptorClusterDeviceListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _DeviceType data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(4); + data[i].type = emberAfGetInt32u(message, 0, 4); + message += 4; + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].revision = emberAfGetInt16u(message, 0, 2); + message += 2; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void DescriptorClusterServerListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + chip::ClusterId data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(2); + data[i] = emberAfGetInt16u(message, 0, 2); + message += 2; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void DescriptorClusterClientListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + chip::ClusterId data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(2); + data[i] = emberAfGetInt16u(message, 0, 2); + message += 2; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void DescriptorClusterPartsListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + chip::EndpointId data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(1); + data[i] = emberAfGetInt8u(message, 0, 1); + message += 1; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void FixedLabelClusterLabelListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _LabelStruct data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_STATUS_VOID(ReadByteSpan(message, 18, &data[i].label)); + messageLen = static_cast(messageLen - 18); + message += 18; + CHECK_STATUS_VOID(ReadByteSpan(message, 18, &data[i].value)); + messageLen = static_cast(messageLen - 18); + message += 18; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void GeneralDiagnosticsClusterNetworkInterfacesListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _NetworkInterfaceType data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_STATUS_VOID(ReadByteSpan(message, 34, &data[i].Name)); + messageLen = static_cast(messageLen - 34); + message += 34; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].FabricConnected = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].OffPremiseServicesReachableIPv4 = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].OffPremiseServicesReachableIPv6 = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_STATUS_VOID(ReadByteSpan(message, 10, &data[i].HardwareAddress)); + messageLen = static_cast(messageLen - 10); + message += 10; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].Type = emberAfGetInt8u(message, 0, 1); + message += 1; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void GroupKeyManagementClusterGroupsListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _GroupState data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].VendorId = emberAfGetInt16u(message, 0, 2); + message += 2; + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].VendorGroupId = emberAfGetInt16u(message, 0, 2); + message += 2; + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].GroupKeySetIndex = emberAfGetInt16u(message, 0, 2); + message += 2; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void GroupKeyManagementClusterGroupKeysListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _GroupKey data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].VendorId = emberAfGetInt16u(message, 0, 2); + message += 2; + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].GroupKeyIndex = emberAfGetInt16u(message, 0, 2); + message += 2; + CHECK_STATUS_VOID(ReadByteSpan(message, 18, &data[i].GroupKeyRoot)); + messageLen = static_cast(messageLen - 18); + message += 18; + CHECK_MESSAGE_LENGTH_VOID(8); + data[i].GroupKeyEpochStartTime = emberAfGetInt64u(message, 0, 8); + message += 8; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].GroupKeySecurityPolicy = emberAfGetInt8u(message, 0, 1); + message += 1; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void MediaInputClusterMediaInputListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _MediaInputInfo data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].index = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].inputType = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_STATUS_VOID(ReadByteSpan(message, 34, &data[i].name)); + messageLen = static_cast(messageLen - 34); + message += 34; + CHECK_STATUS_VOID(ReadByteSpan(message, 34, &data[i].description)); + messageLen = static_cast(messageLen - 34); + message += 34; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void OperationalCredentialsClusterFabricsListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _FabricDescriptor data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(8); + data[i].FabricId = emberAfGetInt64u(message, 0, 8); + message += 8; + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].VendorId = emberAfGetInt16u(message, 0, 2); + message += 2; + CHECK_MESSAGE_LENGTH_VOID(8); + data[i].NodeId = emberAfGetInt64u(message, 0, 8); + message += 8; + CHECK_STATUS_VOID(ReadByteSpan(message, 34, &data[i].Label)); + messageLen = static_cast(messageLen - 34); + message += 34; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void TvChannelClusterTvChannelListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _TvChannelInfo data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].majorNumber = emberAfGetInt16u(message, 0, 2); + message += 2; + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].minorNumber = emberAfGetInt16u(message, 0, 2); + message += 2; + CHECK_STATUS_VOID(ReadByteSpan(message, 34, &data[i].name)); + messageLen = static_cast(messageLen - 34); + message += 34; + CHECK_STATUS_VOID(ReadByteSpan(message, 34, &data[i].callSign)); + messageLen = static_cast(messageLen - 34); + message += 34; + CHECK_STATUS_VOID(ReadByteSpan(message, 34, &data[i].affiliateCallSign)); + messageLen = static_cast(messageLen - 34); + message += 34; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void TargetNavigatorClusterTargetNavigatorListListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _NavigateTargetTargetInfo data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].identifier = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_STATUS_VOID(ReadByteSpan(message, 34, &data[i].name)); + messageLen = static_cast(messageLen - 34); + message += 34; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void TestClusterClusterListInt8uListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + uint8_t data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(1); + data[i] = emberAfGetInt8u(message, 0, 1); + message += 1; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void TestClusterClusterListOctetStringListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + chip::ByteSpan data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_STATUS_VOID(ReadByteSpan(message, messageLen, &data[i])); + uint16_t entryLength = static_cast(data[i].size() + kByteSpanSizeLengthInBytes); + messageLen = static_cast(messageLen - entryLength); + message += entryLength; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void TestClusterClusterListStructOctetStringListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _TestListStructOctet data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(8); + data[i].fabricIndex = emberAfGetInt64u(message, 0, 8); + message += 8; + CHECK_STATUS_VOID(ReadByteSpan(message, 34, &data[i].operationalCert)); + messageLen = static_cast(messageLen - 34); + message += 34; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void ThreadNetworkDiagnosticsClusterNeighborTableListListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _NeighborTable data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(8); + data[i].ExtAddress = emberAfGetInt64u(message, 0, 8); + message += 8; + CHECK_MESSAGE_LENGTH_VOID(4); + data[i].Age = emberAfGetInt32u(message, 0, 4); + message += 4; + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].Rloc16 = emberAfGetInt16u(message, 0, 2); + message += 2; + CHECK_MESSAGE_LENGTH_VOID(4); + data[i].LinkFrameCounter = emberAfGetInt32u(message, 0, 4); + message += 4; + CHECK_MESSAGE_LENGTH_VOID(4); + data[i].MleFrameCounter = emberAfGetInt32u(message, 0, 4); + message += 4; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].LQI = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].AverageRssi = emberAfGetInt8s(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].LastRssi = emberAfGetInt8s(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].FrameErrorRate = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].MessageErrorRate = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].RxOnWhenIdle = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].FullThreadDevice = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].FullNetworkData = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].IsChild = emberAfGetInt8u(message, 0, 1); + message += 1; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void ThreadNetworkDiagnosticsClusterRouteTableListListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _RouteTable data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(8); + data[i].ExtAddress = emberAfGetInt64u(message, 0, 8); + message += 8; + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].Rloc16 = emberAfGetInt16u(message, 0, 2); + message += 2; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].RouterId = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].NextHop = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].PathCost = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].LQIIn = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].LQIOut = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].Age = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].Allocated = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].LinkEstablished = emberAfGetInt8u(message, 0, 1); + message += 1; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void ThreadNetworkDiagnosticsClusterSecurityPolicyListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _SecurityPolicy data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(2); + data[i].RotationTime = emberAfGetInt16u(message, 0, 2); + message += 2; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].Flags = emberAfGetInt8u(message, 0, 1); + message += 1; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void ThreadNetworkDiagnosticsClusterOperationalDatasetComponentsListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + _OperationalDatasetComponents data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].ActiveTimestampPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].PendingTimestampPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].MasterKeyPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].NetworkNamePresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].ExtendedPanIdPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].MeshLocalPrefixPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].DelayPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].PanIdPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].ChannelPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].PskcPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].SecurityPolicyPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + CHECK_MESSAGE_LENGTH_VOID(1); + data[i].ChannelMaskPresent = emberAfGetInt8u(message, 0, 1); + message += 1; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable( + onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + +void ThreadNetworkDiagnosticsClusterActiveNetworkFaultsListListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + // TODO: Add actual support for array and lists. + const uint8_t * message = nullptr; + uint16_t messageLen = 0; + EmberAfStatus res = PrepareListFromTLV(tlvData, message, messageLen); + if (res != EMBER_ZCL_STATUS_SUCCESS) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, res); + return; + } + + CHECK_MESSAGE_LENGTH_VOID(2); + uint16_t count = chip::Encoding::LittleEndian::Read16(message); + uint8_t data[count]; + for (size_t i = 0; i < count; i++) + { + CHECK_MESSAGE_LENGTH_VOID(1); + data[i] = emberAfGetInt8u(message, 0, 1); + message += 1; + } + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, count, data); +} + bool emberAfAccountLoginClusterGetSetupPINResponseCallback(chip::app::Command * commandObj, uint8_t * setupPIN) { ChipLogProgress(Zcl, "GetSetupPINResponse:"); diff --git a/src/controller/data_model/gen/CHIPClientCallbacks.h b/src/controller/data_model/gen/CHIPClientCallbacks.h index 963e578a8ededf..b810a0564e531c 100644 --- a/src/controller/data_model/gen/CHIPClientCallbacks.h +++ b/src/controller/data_model/gen/CHIPClientCallbacks.h @@ -20,15 +20,19 @@ #pragma once #include +#include #include #include #include +#include #include // Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus // instead of IM status code. // #6308 should handle IM error code on the application side, either modify this function or remove this. bool IMDefaultResponseCallback(const chip::app::Command * commandObj, EmberAfStatus status); +bool IMReadReportAttributesResponseCallback(const chip::app::ReadClient * apReadClient, const chip::app::ClusterInfo & aPath, + chip::TLV::TLVReader * apData, chip::Protocols::InteractionModel::ProtocolCode status); // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -43,6 +47,39 @@ typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); +typedef void (*AttributeResponseFilter)(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure); + +/** + * BasicAttributeFilter accepts the actual type of onSuccess callback as template parameter. + * It will check whether the type of the TLV data is expected by onSuccess callback. + * If a non expected value received, onFailure callback will be called with EMBER_ZCL_STATUS_INVALID_VALUE. + */ +template +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + typename chip::FunctionTraits::template ArgType<1> value; + + if ((err = data->Get(value)) == CHIP_NO_ERROR) + { + chip::Callback::Callback * cb = chip::Callback::Callback::FromCancelable(onSuccess); + cb->mCall(cb->mContext, value); + } + else + { + ChipLogError(Zcl, "Failed to get value from TLV data for attribute reading response: %d", err); + chip::Callback::Callback * cb = + chip::Callback::Callback::FromCancelable(onFailure); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } +} + +template <> +void BasicAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccess, + chip::Callback::Cancelable * onFailure); + typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); @@ -146,34 +183,97 @@ typedef void (*TargetNavigatorClusterNavigateTargetResponseCallback)(void * cont typedef void (*TestClusterClusterTestSpecificResponseCallback)(void * context, uint8_t returnValue); // List specific responses +void ApplicationLauncherClusterApplicationLauncherListListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*ApplicationLauncherApplicationLauncherListListAttributeCallback)(void * context, uint16_t count, uint16_t * entries); +void AudioOutputClusterAudioOutputListListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*AudioOutputAudioOutputListListAttributeCallback)(void * context, uint16_t count, _AudioOutputInfo * entries); +void ContentLauncherClusterAcceptsHeaderListListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*ContentLauncherAcceptsHeaderListListAttributeCallback)(void * context, uint16_t count, chip::ByteSpan * entries); +void ContentLauncherClusterSupportedStreamingTypesListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*ContentLauncherSupportedStreamingTypesListAttributeCallback)(void * context, uint16_t count, uint8_t * entries); +void DescriptorClusterDeviceListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*DescriptorDeviceListListAttributeCallback)(void * context, uint16_t count, _DeviceType * entries); +void DescriptorClusterServerListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*DescriptorServerListListAttributeCallback)(void * context, uint16_t count, chip::ClusterId * entries); +void DescriptorClusterClientListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*DescriptorClientListListAttributeCallback)(void * context, uint16_t count, chip::ClusterId * entries); +void DescriptorClusterPartsListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*DescriptorPartsListListAttributeCallback)(void * context, uint16_t count, chip::EndpointId * entries); +void FixedLabelClusterLabelListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*FixedLabelLabelListListAttributeCallback)(void * context, uint16_t count, _LabelStruct * entries); +void GeneralDiagnosticsClusterNetworkInterfacesListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*GeneralDiagnosticsNetworkInterfacesListAttributeCallback)(void * context, uint16_t count, _NetworkInterfaceType * entries); +void GroupKeyManagementClusterGroupsListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*GroupKeyManagementGroupsListAttributeCallback)(void * context, uint16_t count, _GroupState * entries); +void GroupKeyManagementClusterGroupKeysListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*GroupKeyManagementGroupKeysListAttributeCallback)(void * context, uint16_t count, _GroupKey * entries); +void MediaInputClusterMediaInputListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*MediaInputMediaInputListListAttributeCallback)(void * context, uint16_t count, _MediaInputInfo * entries); +void OperationalCredentialsClusterFabricsListListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*OperationalCredentialsFabricsListListAttributeCallback)(void * context, uint16_t count, _FabricDescriptor * entries); +void TvChannelClusterTvChannelListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*TvChannelTvChannelListListAttributeCallback)(void * context, uint16_t count, _TvChannelInfo * entries); +void TargetNavigatorClusterTargetNavigatorListListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*TargetNavigatorTargetNavigatorListListAttributeCallback)(void * context, uint16_t count, _NavigateTargetTargetInfo * entries); +void TestClusterClusterListInt8uListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*TestClusterListInt8uListAttributeCallback)(void * context, uint16_t count, uint8_t * entries); +void TestClusterClusterListOctetStringListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*TestClusterListOctetStringListAttributeCallback)(void * context, uint16_t count, chip::ByteSpan * entries); +void TestClusterClusterListStructOctetStringListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*TestClusterListStructOctetStringListAttributeCallback)(void * context, uint16_t count, _TestListStructOctet * entries); +void ThreadNetworkDiagnosticsClusterNeighborTableListListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*ThreadNetworkDiagnosticsNeighborTableListListAttributeCallback)(void * context, uint16_t count, _NeighborTable * entries); +void ThreadNetworkDiagnosticsClusterRouteTableListListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*ThreadNetworkDiagnosticsRouteTableListListAttributeCallback)(void * context, uint16_t count, _RouteTable * entries); +void ThreadNetworkDiagnosticsClusterSecurityPolicyListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*ThreadNetworkDiagnosticsSecurityPolicyListAttributeCallback)(void * context, uint16_t count, _SecurityPolicy * entries); +void ThreadNetworkDiagnosticsClusterOperationalDatasetComponentsListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*ThreadNetworkDiagnosticsOperationalDatasetComponentsListAttributeCallback)(void * context, uint16_t count, _OperationalDatasetComponents * entries); +void ThreadNetworkDiagnosticsClusterActiveNetworkFaultsListListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); typedef void (*ThreadNetworkDiagnosticsActiveNetworkFaultsListListAttributeCallback)(void * context, uint16_t count, uint8_t * entries); diff --git a/src/controller/data_model/gen/CHIPClusters.cpp b/src/controller/data_model/gen/CHIPClusters.cpp index 6e975fd442f433..b158abea356409 100644 --- a/src/controller/data_model/gen/CHIPClusters.cpp +++ b/src/controller/data_model/gen/CHIPClusters.cpp @@ -21,6 +21,7 @@ #include #include "chip-zcl-zpro-codec-api.h" +#include #include namespace chip { @@ -126,9 +127,13 @@ CHIP_ERROR AccountLoginCluster::DiscoverAttributes(Callback::Cancelable * onSucc CHIP_ERROR AccountLoginCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeAccountLoginClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // ApplicationBasic Cluster Commands @@ -184,65 +189,97 @@ CHIP_ERROR ApplicationBasicCluster::DiscoverAttributes(Callback::Cancelable * on CHIP_ERROR ApplicationBasicCluster::ReadAttributeVendorName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadVendorNameAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ApplicationBasicCluster::ReadAttributeVendorId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadVendorIdAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ApplicationBasicCluster::ReadAttributeApplicationName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadApplicationNameAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ApplicationBasicCluster::ReadAttributeProductId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadProductIdAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ApplicationBasicCluster::ReadAttributeApplicationId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadApplicationIdAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0005; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ApplicationBasicCluster::ReadAttributeCatalogVendorId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadCatalogVendorIdAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0006; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ApplicationBasicCluster::ReadAttributeApplicationSatus(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadApplicationSatusAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0007; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ApplicationBasicCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeApplicationBasicClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // ApplicationLauncher Cluster Commands @@ -302,18 +339,25 @@ CHIP_ERROR ApplicationLauncherCluster::DiscoverAttributes(Callback::Cancelable * CHIP_ERROR ApplicationLauncherCluster::ReadAttributeApplicationLauncherList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeApplicationLauncherClusterReadApplicationLauncherListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + ApplicationLauncherClusterApplicationLauncherListListAttributeFilter); } CHIP_ERROR ApplicationLauncherCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeApplicationLauncherClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // AudioOutput Cluster Commands @@ -412,17 +456,25 @@ CHIP_ERROR AudioOutputCluster::DiscoverAttributes(Callback::Cancelable * onSucce CHIP_ERROR AudioOutputCluster::ReadAttributeAudioOutputList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeAudioOutputClusterReadAudioOutputListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + AudioOutputClusterAudioOutputListListAttributeFilter); } CHIP_ERROR AudioOutputCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeAudioOutputClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // BarrierControl Cluster Commands @@ -517,41 +569,61 @@ CHIP_ERROR BarrierControlCluster::DiscoverAttributes(Callback::Cancelable * onSu CHIP_ERROR BarrierControlCluster::ReadAttributeBarrierMovingState(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterReadBarrierMovingStateAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BarrierControlCluster::ReadAttributeBarrierSafetyStatus(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterReadBarrierSafetyStatusAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BarrierControlCluster::ReadAttributeBarrierCapabilities(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterReadBarrierCapabilitiesAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BarrierControlCluster::ReadAttributeBarrierPosition(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterReadBarrierPositionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BarrierControlCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBarrierControlClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // Basic Cluster Commands @@ -603,45 +675,69 @@ CHIP_ERROR BasicCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCall CHIP_ERROR BasicCluster::ReadAttributeInteractionModelVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadInteractionModelVersionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeVendorName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadVendorNameAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeVendorID(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadVendorIDAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeProductName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadProductNameAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeProductID(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadProductIDAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0004; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeUserLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadUserLabelAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0005; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::WriteAttributeUserLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, @@ -654,9 +750,13 @@ CHIP_ERROR BasicCluster::WriteAttributeUserLabel(Callback::Cancelable * onSucces CHIP_ERROR BasicCluster::ReadAttributeLocation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadLocationAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0006; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::WriteAttributeLocation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, @@ -670,79 +770,119 @@ CHIP_ERROR BasicCluster::WriteAttributeLocation(Callback::Cancelable * onSuccess CHIP_ERROR BasicCluster::ReadAttributeHardwareVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadHardwareVersionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0007; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeHardwareVersionString(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadHardwareVersionStringAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0008; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeSoftwareVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadSoftwareVersionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0009; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeSoftwareVersionString(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadSoftwareVersionStringAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeManufacturingDate(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadManufacturingDateAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributePartNumber(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadPartNumberAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeProductURL(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadProductURLAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000D; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeProductLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadProductLabelAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000E; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeSerialNumber(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadSerialNumberAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000F; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeLocalConfigDisabled(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadLocalConfigDisabledAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0010; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::WriteAttributeLocalConfigDisabled(Callback::Cancelable * onSuccessCallback, @@ -755,17 +895,25 @@ CHIP_ERROR BasicCluster::WriteAttributeLocalConfigDisabled(Callback::Cancelable CHIP_ERROR BasicCluster::ReadAttributeReachable(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadReachableAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0011; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BasicCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // BinaryInputBasic Cluster Commands @@ -780,9 +928,13 @@ CHIP_ERROR BinaryInputBasicCluster::DiscoverAttributes(Callback::Cancelable * on CHIP_ERROR BinaryInputBasicCluster::ReadAttributeOutOfService(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBinaryInputBasicClusterReadOutOfServiceAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0051; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BinaryInputBasicCluster::WriteAttributeOutOfService(Callback::Cancelable * onSuccessCallback, @@ -796,9 +948,13 @@ CHIP_ERROR BinaryInputBasicCluster::WriteAttributeOutOfService(Callback::Cancela CHIP_ERROR BinaryInputBasicCluster::ReadAttributePresentValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBinaryInputBasicClusterReadPresentValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0055; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BinaryInputBasicCluster::WriteAttributePresentValue(Callback::Cancelable * onSuccessCallback, @@ -827,9 +983,13 @@ CHIP_ERROR BinaryInputBasicCluster::ReportAttributePresentValue(Callback::Cancel CHIP_ERROR BinaryInputBasicCluster::ReadAttributeStatusFlags(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBinaryInputBasicClusterReadStatusFlagsAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x006F; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BinaryInputBasicCluster::ConfigureAttributeStatusFlags(Callback::Cancelable * onSuccessCallback, @@ -850,9 +1010,13 @@ CHIP_ERROR BinaryInputBasicCluster::ReportAttributeStatusFlags(Callback::Cancela CHIP_ERROR BinaryInputBasicCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBinaryInputBasicClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // Binding Cluster Commands @@ -961,9 +1125,13 @@ CHIP_ERROR BindingCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCa CHIP_ERROR BindingCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBindingClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // BridgedDeviceBasic Cluster Commands @@ -978,33 +1146,49 @@ CHIP_ERROR BridgedDeviceBasicCluster::DiscoverAttributes(Callback::Cancelable * CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeVendorName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadVendorNameAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeVendorID(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadVendorIDAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeProductName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadProductNameAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeUserLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadUserLabelAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0005; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::WriteAttributeUserLabel(Callback::Cancelable * onSuccessCallback, @@ -1018,91 +1202,133 @@ CHIP_ERROR BridgedDeviceBasicCluster::WriteAttributeUserLabel(Callback::Cancelab CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeHardwareVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadHardwareVersionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0007; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeHardwareVersionString(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeBridgedDeviceBasicClusterReadHardwareVersionStringAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0008; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeSoftwareVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadSoftwareVersionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0009; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeSoftwareVersionString(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeBridgedDeviceBasicClusterReadSoftwareVersionStringAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeManufacturingDate(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadManufacturingDateAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributePartNumber(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadPartNumberAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeProductURL(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadProductURLAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000D; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeProductLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadProductLabelAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000E; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeSerialNumber(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadSerialNumberAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000F; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeReachable(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadReachableAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0011; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBridgedDeviceBasicClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // ColorControl Cluster Commands @@ -1805,9 +2031,13 @@ CHIP_ERROR ColorControlCluster::DiscoverAttributes(Callback::Cancelable * onSucc CHIP_ERROR ColorControlCluster::ReadAttributeCurrentHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadCurrentHueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ConfigureAttributeCurrentHue(Callback::Cancelable * onSuccessCallback, @@ -1828,9 +2058,13 @@ CHIP_ERROR ColorControlCluster::ReportAttributeCurrentHue(Callback::Cancelable * CHIP_ERROR ColorControlCluster::ReadAttributeCurrentSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadCurrentSaturationAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ConfigureAttributeCurrentSaturation(Callback::Cancelable * onSuccessCallback, @@ -1851,17 +2085,25 @@ CHIP_ERROR ColorControlCluster::ReportAttributeCurrentSaturation(Callback::Cance CHIP_ERROR ColorControlCluster::ReadAttributeRemainingTime(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadRemainingTimeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeCurrentX(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadCurrentXAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ConfigureAttributeCurrentX(Callback::Cancelable * onSuccessCallback, @@ -1882,9 +2124,13 @@ CHIP_ERROR ColorControlCluster::ReportAttributeCurrentX(Callback::Cancelable * o CHIP_ERROR ColorControlCluster::ReadAttributeCurrentY(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadCurrentYAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0004; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ConfigureAttributeCurrentY(Callback::Cancelable * onSuccessCallback, @@ -1905,25 +2151,37 @@ CHIP_ERROR ColorControlCluster::ReportAttributeCurrentY(Callback::Cancelable * o CHIP_ERROR ColorControlCluster::ReadAttributeDriftCompensation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadDriftCompensationAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0005; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeCompensationText(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadCompensationTextAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0006; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeColorTemperature(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorTemperatureAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0007; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ConfigureAttributeColorTemperature(Callback::Cancelable * onSuccessCallback, @@ -1944,17 +2202,25 @@ CHIP_ERROR ColorControlCluster::ReportAttributeColorTemperature(Callback::Cancel CHIP_ERROR ColorControlCluster::ReadAttributeColorMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorModeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0008; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeColorControlOptions(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorControlOptionsAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000F; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeColorControlOptions(Callback::Cancelable * onSuccessCallback, @@ -1969,161 +2235,241 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorControlOptions(Callback::Canc CHIP_ERROR ColorControlCluster::ReadAttributeNumberOfPrimaries(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadNumberOfPrimariesAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0010; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary1X(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary1XAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0011; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary1Y(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary1YAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0012; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary1Intensity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary1IntensityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0013; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary2X(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary2XAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0015; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary2Y(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary2YAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0016; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary2Intensity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary2IntensityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0017; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary3X(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary3XAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0019; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary3Y(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary3YAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary3Intensity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary3IntensityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary4X(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary4XAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0020; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary4Y(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary4YAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0021; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary4Intensity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary4IntensityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0022; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary5X(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary5XAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0024; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary5Y(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary5YAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0025; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary5Intensity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary5IntensityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0026; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary6X(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary6XAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0028; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary6Y(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary6YAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0029; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributePrimary6Intensity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadPrimary6IntensityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x002A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeWhitePointX(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadWhitePointXAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0030; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeWhitePointX(Callback::Cancelable * onSuccessCallback, @@ -2137,9 +2483,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeWhitePointX(Callback::Cancelable * CHIP_ERROR ColorControlCluster::ReadAttributeWhitePointY(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadWhitePointYAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0031; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeWhitePointY(Callback::Cancelable * onSuccessCallback, @@ -2153,9 +2503,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeWhitePointY(Callback::Cancelable * CHIP_ERROR ColorControlCluster::ReadAttributeColorPointRX(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointRXAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0032; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeColorPointRX(Callback::Cancelable * onSuccessCallback, @@ -2169,9 +2523,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorPointRX(Callback::Cancelable CHIP_ERROR ColorControlCluster::ReadAttributeColorPointRY(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointRYAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0033; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeColorPointRY(Callback::Cancelable * onSuccessCallback, @@ -2185,9 +2543,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorPointRY(Callback::Cancelable CHIP_ERROR ColorControlCluster::ReadAttributeColorPointRIntensity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointRIntensityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0034; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeColorPointRIntensity(Callback::Cancelable * onSuccessCallback, @@ -2202,9 +2564,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorPointRIntensity(Callback::Can CHIP_ERROR ColorControlCluster::ReadAttributeColorPointGX(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointGXAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0036; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeColorPointGX(Callback::Cancelable * onSuccessCallback, @@ -2218,9 +2584,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorPointGX(Callback::Cancelable CHIP_ERROR ColorControlCluster::ReadAttributeColorPointGY(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointGYAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0037; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeColorPointGY(Callback::Cancelable * onSuccessCallback, @@ -2234,9 +2604,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorPointGY(Callback::Cancelable CHIP_ERROR ColorControlCluster::ReadAttributeColorPointGIntensity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointGIntensityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0038; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeColorPointGIntensity(Callback::Cancelable * onSuccessCallback, @@ -2251,9 +2625,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorPointGIntensity(Callback::Can CHIP_ERROR ColorControlCluster::ReadAttributeColorPointBX(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointBXAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x003A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeColorPointBX(Callback::Cancelable * onSuccessCallback, @@ -2267,9 +2645,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorPointBX(Callback::Cancelable CHIP_ERROR ColorControlCluster::ReadAttributeColorPointBY(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointBYAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x003B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeColorPointBY(Callback::Cancelable * onSuccessCallback, @@ -2283,9 +2665,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorPointBY(Callback::Cancelable CHIP_ERROR ColorControlCluster::ReadAttributeColorPointBIntensity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorPointBIntensityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x003C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeColorPointBIntensity(Callback::Cancelable * onSuccessCallback, @@ -2300,83 +2686,121 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorPointBIntensity(Callback::Can CHIP_ERROR ColorControlCluster::ReadAttributeEnhancedCurrentHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadEnhancedCurrentHueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x4000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeEnhancedColorMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadEnhancedColorModeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x4001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeColorLoopActive(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorLoopActiveAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x4002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeColorLoopDirection(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorLoopDirectionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x4003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeColorLoopTime(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorLoopTimeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x4004; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeColorCapabilities(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorCapabilitiesAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x400A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeColorTempPhysicalMin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorTempPhysicalMinAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x400B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeColorTempPhysicalMax(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadColorTempPhysicalMaxAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x400C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeCoupleColorTempToLevelMinMireds(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeColorControlClusterReadCoupleColorTempToLevelMinMiredsAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x400D; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::ReadAttributeStartUpColorTemperatureMireds(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeColorControlClusterReadStartUpColorTemperatureMiredsAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x4010; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ColorControlCluster::WriteAttributeStartUpColorTemperatureMireds(Callback::Cancelable * onSuccessCallback, @@ -2392,9 +2816,13 @@ CHIP_ERROR ColorControlCluster::WriteAttributeStartUpColorTemperatureMireds(Call CHIP_ERROR ColorControlCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeColorControlClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // ContentLauncher Cluster Commands @@ -2495,25 +2923,37 @@ CHIP_ERROR ContentLauncherCluster::DiscoverAttributes(Callback::Cancelable * onS CHIP_ERROR ContentLauncherCluster::ReadAttributeAcceptsHeaderList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeContentLauncherClusterReadAcceptsHeaderListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + ContentLauncherClusterAcceptsHeaderListListAttributeFilter); } CHIP_ERROR ContentLauncherCluster::ReadAttributeSupportedStreamingTypes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeContentLauncherClusterReadSupportedStreamingTypesAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + ContentLauncherClusterSupportedStreamingTypesListAttributeFilter); } CHIP_ERROR ContentLauncherCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeContentLauncherClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // Descriptor Cluster Commands @@ -2527,41 +2967,61 @@ CHIP_ERROR DescriptorCluster::DiscoverAttributes(Callback::Cancelable * onSucces CHIP_ERROR DescriptorCluster::ReadAttributeDeviceList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeDescriptorClusterReadDeviceListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + DescriptorClusterDeviceListListAttributeFilter); } CHIP_ERROR DescriptorCluster::ReadAttributeServerList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeDescriptorClusterReadServerListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + DescriptorClusterServerListListAttributeFilter); } CHIP_ERROR DescriptorCluster::ReadAttributeClientList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeDescriptorClusterReadClientListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + DescriptorClusterClientListListAttributeFilter); } CHIP_ERROR DescriptorCluster::ReadAttributePartsList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeDescriptorClusterReadPartsListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + DescriptorClusterPartsListListAttributeFilter); } CHIP_ERROR DescriptorCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeDescriptorClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // DiagnosticLogs Cluster Commands @@ -3618,9 +4078,13 @@ CHIP_ERROR DoorLockCluster::DiscoverAttributes(Callback::Cancelable * onSuccessC CHIP_ERROR DoorLockCluster::ReadAttributeLockState(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeDoorLockClusterReadLockStateAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR DoorLockCluster::ConfigureAttributeLockState(Callback::Cancelable * onSuccessCallback, @@ -3641,25 +4105,37 @@ CHIP_ERROR DoorLockCluster::ReportAttributeLockState(Callback::Cancelable * onRe CHIP_ERROR DoorLockCluster::ReadAttributeLockType(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeDoorLockClusterReadLockTypeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR DoorLockCluster::ReadAttributeActuatorEnabled(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeDoorLockClusterReadActuatorEnabledAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR DoorLockCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeDoorLockClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // EthernetNetworkDiagnostics Cluster Commands @@ -3713,53 +4189,73 @@ CHIP_ERROR EthernetNetworkDiagnosticsCluster::DiscoverAttributes(Callback::Cance CHIP_ERROR EthernetNetworkDiagnosticsCluster::ReadAttributePacketRxCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeEthernetNetworkDiagnosticsClusterReadPacketRxCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR EthernetNetworkDiagnosticsCluster::ReadAttributePacketTxCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeEthernetNetworkDiagnosticsClusterReadPacketTxCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR EthernetNetworkDiagnosticsCluster::ReadAttributeTxErrCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeEthernetNetworkDiagnosticsClusterReadTxErrCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0004; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR EthernetNetworkDiagnosticsCluster::ReadAttributeCollisionCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeEthernetNetworkDiagnosticsClusterReadCollisionCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0005; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR EthernetNetworkDiagnosticsCluster::ReadAttributeOverrunCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeEthernetNetworkDiagnosticsClusterReadOverrunCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0006; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR EthernetNetworkDiagnosticsCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeEthernetNetworkDiagnosticsClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // FixedLabel Cluster Commands @@ -3773,17 +4269,25 @@ CHIP_ERROR FixedLabelCluster::DiscoverAttributes(Callback::Cancelable * onSucces CHIP_ERROR FixedLabelCluster::ReadAttributeLabelList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeFixedLabelClusterReadLabelListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + FixedLabelClusterLabelListListAttributeFilter); } CHIP_ERROR FixedLabelCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeFixedLabelClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // GeneralCommissioning Cluster Commands @@ -3931,17 +4435,25 @@ CHIP_ERROR GeneralCommissioningCluster::DiscoverAttributes(Callback::Cancelable CHIP_ERROR GeneralCommissioningCluster::ReadAttributeFabricId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGeneralCommissioningClusterReadFabricIdAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR GeneralCommissioningCluster::ReadAttributeBreadcrumb(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGeneralCommissioningClusterReadBreadcrumbAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR GeneralCommissioningCluster::WriteAttributeBreadcrumb(Callback::Cancelable * onSuccessCallback, @@ -3955,9 +4467,13 @@ CHIP_ERROR GeneralCommissioningCluster::WriteAttributeBreadcrumb(Callback::Cance CHIP_ERROR GeneralCommissioningCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGeneralCommissioningClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // GeneralDiagnostics Cluster Commands @@ -3972,25 +4488,37 @@ CHIP_ERROR GeneralDiagnosticsCluster::DiscoverAttributes(Callback::Cancelable * CHIP_ERROR GeneralDiagnosticsCluster::ReadAttributeNetworkInterfaces(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGeneralDiagnosticsClusterReadNetworkInterfacesAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + GeneralDiagnosticsClusterNetworkInterfacesListAttributeFilter); } CHIP_ERROR GeneralDiagnosticsCluster::ReadAttributeRebootCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGeneralDiagnosticsClusterReadRebootCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR GeneralDiagnosticsCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGeneralDiagnosticsClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // GroupKeyManagement Cluster Commands @@ -4005,25 +4533,37 @@ CHIP_ERROR GroupKeyManagementCluster::DiscoverAttributes(Callback::Cancelable * CHIP_ERROR GroupKeyManagementCluster::ReadAttributeGroups(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGroupKeyManagementClusterReadGroupsAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + GroupKeyManagementClusterGroupsListAttributeFilter); } CHIP_ERROR GroupKeyManagementCluster::ReadAttributeGroupKeys(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGroupKeyManagementClusterReadGroupKeysAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + GroupKeyManagementClusterGroupKeysListAttributeFilter); } CHIP_ERROR GroupKeyManagementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGroupKeyManagementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // Groups Cluster Commands @@ -4286,17 +4826,25 @@ CHIP_ERROR GroupsCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCal CHIP_ERROR GroupsCluster::ReadAttributeNameSupport(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGroupsClusterReadNameSupportAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR GroupsCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeGroupsClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // Identify Cluster Commands @@ -4389,9 +4937,13 @@ CHIP_ERROR IdentifyCluster::DiscoverAttributes(Callback::Cancelable * onSuccessC CHIP_ERROR IdentifyCluster::ReadAttributeIdentifyTime(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeIdentifyClusterReadIdentifyTimeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR IdentifyCluster::WriteAttributeIdentifyTime(Callback::Cancelable * onSuccessCallback, @@ -4405,9 +4957,13 @@ CHIP_ERROR IdentifyCluster::WriteAttributeIdentifyTime(Callback::Cancelable * on CHIP_ERROR IdentifyCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeIdentifyClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // KeypadInput Cluster Commands @@ -4463,9 +5019,13 @@ CHIP_ERROR KeypadInputCluster::DiscoverAttributes(Callback::Cancelable * onSucce CHIP_ERROR KeypadInputCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeKeypadInputClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // LevelControl Cluster Commands @@ -4837,9 +5397,13 @@ CHIP_ERROR LevelControlCluster::DiscoverAttributes(Callback::Cancelable * onSucc CHIP_ERROR LevelControlCluster::ReadAttributeCurrentLevel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeLevelControlClusterReadCurrentLevelAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR LevelControlCluster::ConfigureAttributeCurrentLevel(Callback::Cancelable * onSuccessCallback, @@ -4860,9 +5424,13 @@ CHIP_ERROR LevelControlCluster::ReportAttributeCurrentLevel(Callback::Cancelable CHIP_ERROR LevelControlCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeLevelControlClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // LowPower Cluster Commands @@ -4914,9 +5482,13 @@ CHIP_ERROR LowPowerCluster::DiscoverAttributes(Callback::Cancelable * onSuccessC CHIP_ERROR LowPowerCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeLowPowerClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // MediaInput Cluster Commands @@ -5090,17 +5662,25 @@ CHIP_ERROR MediaInputCluster::DiscoverAttributes(Callback::Cancelable * onSucces CHIP_ERROR MediaInputCluster::ReadAttributeMediaInputList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeMediaInputClusterReadMediaInputListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + MediaInputClusterMediaInputListListAttributeFilter); } CHIP_ERROR MediaInputCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeMediaInputClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // MediaPlayback Cluster Commands @@ -5543,9 +6123,13 @@ CHIP_ERROR MediaPlaybackCluster::DiscoverAttributes(Callback::Cancelable * onSuc CHIP_ERROR MediaPlaybackCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeMediaPlaybackClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // NetworkCommissioning Cluster Commands @@ -5975,9 +6559,13 @@ CHIP_ERROR NetworkCommissioningCluster::DiscoverAttributes(Callback::Cancelable CHIP_ERROR NetworkCommissioningCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeNetworkCommissioningClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // OtaSoftwareUpdateServer Cluster Commands @@ -6140,9 +6728,13 @@ CHIP_ERROR OtaSoftwareUpdateServerCluster::DiscoverAttributes(Callback::Cancelab CHIP_ERROR OtaSoftwareUpdateServerCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOtaSoftwareUpdateServerClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // OnOff Cluster Commands @@ -6269,9 +6861,13 @@ CHIP_ERROR OnOffCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCall } CHIP_ERROR OnOffCluster::ReadAttributeOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadOnOffAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR OnOffCluster::ConfigureAttributeOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, @@ -6291,16 +6887,24 @@ CHIP_ERROR OnOffCluster::ReportAttributeOnOff(Callback::Cancelable * onReportCal CHIP_ERROR OnOffCluster::ReadAttributeGlobalSceneControl(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadGlobalSceneControlAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x4000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR OnOffCluster::ReadAttributeOnTime(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadOnTimeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x4001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR OnOffCluster::WriteAttributeOnTime(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, @@ -6314,9 +6918,13 @@ CHIP_ERROR OnOffCluster::WriteAttributeOnTime(Callback::Cancelable * onSuccessCa CHIP_ERROR OnOffCluster::ReadAttributeOffWaitTime(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadOffWaitTimeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x4002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR OnOffCluster::WriteAttributeOffWaitTime(Callback::Cancelable * onSuccessCallback, @@ -6330,9 +6938,13 @@ CHIP_ERROR OnOffCluster::WriteAttributeOffWaitTime(Callback::Cancelable * onSucc CHIP_ERROR OnOffCluster::ReadAttributeStartUpOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadStartUpOnOffAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x4003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR OnOffCluster::WriteAttributeStartUpOnOff(Callback::Cancelable * onSuccessCallback, @@ -6345,17 +6957,25 @@ CHIP_ERROR OnOffCluster::WriteAttributeStartUpOnOff(Callback::Cancelable * onSuc CHIP_ERROR OnOffCluster::ReadAttributeFeatureMap(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadFeatureMapAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFC; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR OnOffCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOnOffClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // OperationalCredentials Cluster Commands @@ -6710,17 +7330,25 @@ CHIP_ERROR OperationalCredentialsCluster::DiscoverAttributes(Callback::Cancelabl CHIP_ERROR OperationalCredentialsCluster::ReadAttributeFabricsList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOperationalCredentialsClusterReadFabricsListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + OperationalCredentialsClusterFabricsListListAttributeFilter); } CHIP_ERROR OperationalCredentialsCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeOperationalCredentialsClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // PressureMeasurement Cluster Commands @@ -6735,9 +7363,13 @@ CHIP_ERROR PressureMeasurementCluster::DiscoverAttributes(Callback::Cancelable * CHIP_ERROR PressureMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PressureMeasurementCluster::ConfigureAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, @@ -6758,25 +7390,37 @@ CHIP_ERROR PressureMeasurementCluster::ReportAttributeMeasuredValue(Callback::Ca CHIP_ERROR PressureMeasurementCluster::ReadAttributeMinMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadMinMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PressureMeasurementCluster::ReadAttributeMaxMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadMaxMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PressureMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePressureMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // PumpConfigurationAndControl Cluster Commands @@ -6791,51 +7435,73 @@ CHIP_ERROR PumpConfigurationAndControlCluster::DiscoverAttributes(Callback::Canc CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeMaxPressure(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadMaxPressureAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeMaxSpeed(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadMaxSpeedAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeMaxFlow(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadMaxFlowAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeEffectiveOperationMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodePumpConfigurationAndControlClusterReadEffectiveOperationModeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0011; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeEffectiveControlMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodePumpConfigurationAndControlClusterReadEffectiveControlModeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0012; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeCapacity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodePumpConfigurationAndControlClusterReadCapacityAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0013; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::ConfigureAttributeCapacity(Callback::Cancelable * onSuccessCallback, @@ -6857,10 +7523,13 @@ CHIP_ERROR PumpConfigurationAndControlCluster::ReportAttributeCapacity(Callback: CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeOperationMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodePumpConfigurationAndControlClusterReadOperationModeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0020; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR PumpConfigurationAndControlCluster::WriteAttributeOperationMode(Callback::Cancelable * onSuccessCallback, @@ -6875,10 +7544,13 @@ CHIP_ERROR PumpConfigurationAndControlCluster::WriteAttributeOperationMode(Callb CHIP_ERROR PumpConfigurationAndControlCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodePumpConfigurationAndControlClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // RelativeHumidityMeasurement Cluster Commands @@ -6893,10 +7565,13 @@ CHIP_ERROR RelativeHumidityMeasurementCluster::DiscoverAttributes(Callback::Canc CHIP_ERROR RelativeHumidityMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeRelativeHumidityMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR RelativeHumidityMeasurementCluster::ConfigureAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, @@ -6918,28 +7593,37 @@ CHIP_ERROR RelativeHumidityMeasurementCluster::ReportAttributeMeasuredValue(Call CHIP_ERROR RelativeHumidityMeasurementCluster::ReadAttributeMinMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeRelativeHumidityMeasurementClusterReadMinMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR RelativeHumidityMeasurementCluster::ReadAttributeMaxMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeRelativeHumidityMeasurementClusterReadMaxMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR RelativeHumidityMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeRelativeHumidityMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // Scenes Cluster Commands @@ -7263,49 +7947,73 @@ CHIP_ERROR ScenesCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCal CHIP_ERROR ScenesCluster::ReadAttributeSceneCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeScenesClusterReadSceneCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ScenesCluster::ReadAttributeCurrentScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeScenesClusterReadCurrentSceneAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ScenesCluster::ReadAttributeCurrentGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeScenesClusterReadCurrentGroupAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ScenesCluster::ReadAttributeSceneValid(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeScenesClusterReadSceneValidAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ScenesCluster::ReadAttributeNameSupport(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeScenesClusterReadNameSupportAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0004; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ScenesCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeScenesClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // SoftwareDiagnostics Cluster Commands @@ -7359,18 +8067,25 @@ CHIP_ERROR SoftwareDiagnosticsCluster::DiscoverAttributes(Callback::Cancelable * CHIP_ERROR SoftwareDiagnosticsCluster::ReadAttributeCurrentHeapHighWatermark(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeSoftwareDiagnosticsClusterReadCurrentHeapHighWatermarkAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR SoftwareDiagnosticsCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeSoftwareDiagnosticsClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // Switch Cluster Commands @@ -7384,17 +8099,25 @@ CHIP_ERROR SwitchCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCal CHIP_ERROR SwitchCluster::ReadAttributeNumberOfPositions(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeSwitchClusterReadNumberOfPositionsAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR SwitchCluster::ReadAttributeCurrentPosition(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeSwitchClusterReadCurrentPositionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR SwitchCluster::ConfigureAttributeCurrentPosition(Callback::Cancelable * onSuccessCallback, @@ -7415,9 +8138,13 @@ CHIP_ERROR SwitchCluster::ReportAttributeCurrentPosition(Callback::Cancelable * CHIP_ERROR SwitchCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeSwitchClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // TvChannel Cluster Commands @@ -7557,33 +8284,49 @@ CHIP_ERROR TvChannelCluster::DiscoverAttributes(Callback::Cancelable * onSuccess CHIP_ERROR TvChannelCluster::ReadAttributeTvChannelList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTvChannelClusterReadTvChannelListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + TvChannelClusterTvChannelListListAttributeFilter); } CHIP_ERROR TvChannelCluster::ReadAttributeTvChannelLineup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTvChannelClusterReadTvChannelLineupAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TvChannelCluster::ReadAttributeCurrentTvChannel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTvChannelClusterReadCurrentTvChannelAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TvChannelCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTvChannelClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // TargetNavigator Cluster Commands @@ -7641,17 +8384,25 @@ CHIP_ERROR TargetNavigatorCluster::DiscoverAttributes(Callback::Cancelable * onS CHIP_ERROR TargetNavigatorCluster::ReadAttributeTargetNavigatorList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTargetNavigatorClusterReadTargetNavigatorListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + TargetNavigatorClusterTargetNavigatorListListAttributeFilter); } CHIP_ERROR TargetNavigatorCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTargetNavigatorClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // TemperatureMeasurement Cluster Commands @@ -7666,9 +8417,13 @@ CHIP_ERROR TemperatureMeasurementCluster::DiscoverAttributes(Callback::Cancelabl CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TemperatureMeasurementCluster::ConfigureAttributeMeasuredValue(Callback::Cancelable * onSuccessCallback, @@ -7690,25 +8445,37 @@ CHIP_ERROR TemperatureMeasurementCluster::ReportAttributeMeasuredValue(Callback: CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMinMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMinMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeMaxMeasuredValue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadMaxMeasuredValueAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TemperatureMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTemperatureMeasurementClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // TestCluster Cluster Commands @@ -7876,9 +8643,13 @@ CHIP_ERROR TestClusterCluster::DiscoverAttributes(Callback::Cancelable * onSucce CHIP_ERROR TestClusterCluster::ReadAttributeBoolean(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadBooleanAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeBoolean(Callback::Cancelable * onSuccessCallback, @@ -7892,9 +8663,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeBoolean(Callback::Cancelable * onSu CHIP_ERROR TestClusterCluster::ReadAttributeBitmap8(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadBitmap8Attribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeBitmap8(Callback::Cancelable * onSuccessCallback, @@ -7908,9 +8683,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeBitmap8(Callback::Cancelable * onSu CHIP_ERROR TestClusterCluster::ReadAttributeBitmap16(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadBitmap16Attribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeBitmap16(Callback::Cancelable * onSuccessCallback, @@ -7924,9 +8703,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeBitmap16(Callback::Cancelable * onS CHIP_ERROR TestClusterCluster::ReadAttributeBitmap32(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadBitmap32Attribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeBitmap32(Callback::Cancelable * onSuccessCallback, @@ -7940,9 +8723,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeBitmap32(Callback::Cancelable * onS CHIP_ERROR TestClusterCluster::ReadAttributeBitmap64(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadBitmap64Attribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0004; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeBitmap64(Callback::Cancelable * onSuccessCallback, @@ -7956,9 +8743,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeBitmap64(Callback::Cancelable * onS CHIP_ERROR TestClusterCluster::ReadAttributeInt8u(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt8uAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0005; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeInt8u(Callback::Cancelable * onSuccessCallback, @@ -7972,9 +8763,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeInt8u(Callback::Cancelable * onSucc CHIP_ERROR TestClusterCluster::ReadAttributeInt16u(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt16uAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0006; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeInt16u(Callback::Cancelable * onSuccessCallback, @@ -7988,9 +8783,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeInt16u(Callback::Cancelable * onSuc CHIP_ERROR TestClusterCluster::ReadAttributeInt32u(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt32uAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0008; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeInt32u(Callback::Cancelable * onSuccessCallback, @@ -8004,9 +8803,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeInt32u(Callback::Cancelable * onSuc CHIP_ERROR TestClusterCluster::ReadAttributeInt64u(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt64uAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeInt64u(Callback::Cancelable * onSuccessCallback, @@ -8020,9 +8823,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeInt64u(Callback::Cancelable * onSuc CHIP_ERROR TestClusterCluster::ReadAttributeInt8s(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt8sAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000D; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeInt8s(Callback::Cancelable * onSuccessCallback, @@ -8036,9 +8843,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeInt8s(Callback::Cancelable * onSucc CHIP_ERROR TestClusterCluster::ReadAttributeInt16s(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt16sAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000E; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeInt16s(Callback::Cancelable * onSuccessCallback, @@ -8052,9 +8863,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeInt16s(Callback::Cancelable * onSuc CHIP_ERROR TestClusterCluster::ReadAttributeInt32s(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt32sAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0010; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeInt32s(Callback::Cancelable * onSuccessCallback, @@ -8068,9 +8883,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeInt32s(Callback::Cancelable * onSuc CHIP_ERROR TestClusterCluster::ReadAttributeInt64s(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadInt64sAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0014; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeInt64s(Callback::Cancelable * onSuccessCallback, @@ -8084,9 +8903,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeInt64s(Callback::Cancelable * onSuc CHIP_ERROR TestClusterCluster::ReadAttributeEnum8(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadEnum8Attribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0015; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeEnum8(Callback::Cancelable * onSuccessCallback, @@ -8100,9 +8923,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeEnum8(Callback::Cancelable * onSucc CHIP_ERROR TestClusterCluster::ReadAttributeEnum16(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadEnum16Attribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0016; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeEnum16(Callback::Cancelable * onSuccessCallback, @@ -8116,9 +8943,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeEnum16(Callback::Cancelable * onSuc CHIP_ERROR TestClusterCluster::ReadAttributeOctetString(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadOctetStringAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0019; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeOctetString(Callback::Cancelable * onSuccessCallback, @@ -8132,33 +8963,49 @@ CHIP_ERROR TestClusterCluster::WriteAttributeOctetString(Callback::Cancelable * CHIP_ERROR TestClusterCluster::ReadAttributeListInt8u(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadListInt8uAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + TestClusterClusterListInt8uListAttributeFilter); } CHIP_ERROR TestClusterCluster::ReadAttributeListOctetString(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadListOctetStringAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + TestClusterClusterListOctetStringListAttributeFilter); } CHIP_ERROR TestClusterCluster::ReadAttributeListStructOctetString(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadListStructOctetStringAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + TestClusterClusterListStructOctetStringListAttributeFilter); } CHIP_ERROR TestClusterCluster::ReadAttributeLongOctetString(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadLongOctetStringAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001D; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeLongOctetString(Callback::Cancelable * onSuccessCallback, @@ -8172,9 +9019,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeLongOctetString(Callback::Cancelabl CHIP_ERROR TestClusterCluster::ReadAttributeUnsupported(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadUnsupportedAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x00FF; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR TestClusterCluster::WriteAttributeUnsupported(Callback::Cancelable * onSuccessCallback, @@ -8188,9 +9039,13 @@ CHIP_ERROR TestClusterCluster::WriteAttributeUnsupported(Callback::Cancelable * CHIP_ERROR TestClusterCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeTestClusterClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // Thermostat Cluster Commands @@ -8415,9 +9270,13 @@ CHIP_ERROR ThermostatCluster::DiscoverAttributes(Callback::Cancelable * onSucces CHIP_ERROR ThermostatCluster::ReadAttributeLocalTemperature(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadLocalTemperatureAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThermostatCluster::ConfigureAttributeLocalTemperature(Callback::Cancelable * onSuccessCallback, @@ -8438,9 +9297,13 @@ CHIP_ERROR ThermostatCluster::ReportAttributeLocalTemperature(Callback::Cancelab CHIP_ERROR ThermostatCluster::ReadAttributeOccupiedCoolingSetpoint(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadOccupiedCoolingSetpointAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0011; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThermostatCluster::WriteAttributeOccupiedCoolingSetpoint(Callback::Cancelable * onSuccessCallback, @@ -8455,9 +9318,13 @@ CHIP_ERROR ThermostatCluster::WriteAttributeOccupiedCoolingSetpoint(Callback::Ca CHIP_ERROR ThermostatCluster::ReadAttributeOccupiedHeatingSetpoint(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadOccupiedHeatingSetpointAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0012; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThermostatCluster::WriteAttributeOccupiedHeatingSetpoint(Callback::Cancelable * onSuccessCallback, @@ -8472,9 +9339,13 @@ CHIP_ERROR ThermostatCluster::WriteAttributeOccupiedHeatingSetpoint(Callback::Ca CHIP_ERROR ThermostatCluster::ReadAttributeControlSequenceOfOperation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadControlSequenceOfOperationAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThermostatCluster::WriteAttributeControlSequenceOfOperation(Callback::Cancelable * onSuccessCallback, @@ -8489,9 +9360,13 @@ CHIP_ERROR ThermostatCluster::WriteAttributeControlSequenceOfOperation(Callback: CHIP_ERROR ThermostatCluster::ReadAttributeSystemMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadSystemModeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThermostatCluster::WriteAttributeSystemMode(Callback::Cancelable * onSuccessCallback, @@ -8505,9 +9380,13 @@ CHIP_ERROR ThermostatCluster::WriteAttributeSystemMode(Callback::Cancelable * on CHIP_ERROR ThermostatCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThermostatClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // ThreadNetworkDiagnostics Cluster Commands @@ -8561,521 +9440,733 @@ CHIP_ERROR ThreadNetworkDiagnosticsCluster::DiscoverAttributes(Callback::Cancela CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeChannel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadChannelAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRoutingRole(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadRoutingRoleAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0001; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeNetworkName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadNetworkNameAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0002; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributePanId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadPanIdAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeExtendedPanId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadExtendedPanIdAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0004; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeMeshLocalPrefix(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadMeshLocalPrefixAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0005; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeOverrunCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadOverrunCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0006; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeNeighborTableList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadNeighborTableListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0007; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + ThreadNetworkDiagnosticsClusterNeighborTableListListAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRouteTableList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadRouteTableListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0008; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + ThreadNetworkDiagnosticsClusterRouteTableListListAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributePartitionId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadPartitionIdAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0009; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeWeighting(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadWeightingAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeDataVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadDataVersionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeStableDataVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadStableDataVersionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeLeaderRouterId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadLeaderRouterIdAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000D; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeDetachedRoleCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadDetachedRoleCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000E; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeChildRoleCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadChildRoleCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x000F; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRouterRoleCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRouterRoleCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0010; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeLeaderRoleCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadLeaderRoleCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0011; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeAttachAttemptCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadAttachAttemptCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0012; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributePartitionIdChangeCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadPartitionIdChangeCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0013; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeBetterPartitionAttachAttemptCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadBetterPartitionAttachAttemptCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0014; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeParentChangeCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadParentChangeCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0015; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxTotalCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadTxTotalCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0016; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxUnicastCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadTxUnicastCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0017; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxBroadcastCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadTxBroadcastCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0018; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxAckRequestedCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadTxAckRequestedCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0019; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxAckedCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadTxAckedCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxNoAckRequestedCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadTxNoAckRequestedCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxDataCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadTxDataCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxDataPollCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadTxDataPollCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001D; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxBeaconCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadTxBeaconCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001E; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxBeaconRequestCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadTxBeaconRequestCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x001F; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxOtherCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadTxOtherCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0020; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxRetryCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadTxRetryCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0021; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxDirectMaxRetryExpiryCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadTxDirectMaxRetryExpiryCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0022; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxIndirectMaxRetryExpiryCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadTxIndirectMaxRetryExpiryCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0023; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxErrCcaCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadTxErrCcaCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0024; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxErrAbortCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadTxErrAbortCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0025; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeTxErrBusyChannelCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadTxErrBusyChannelCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0026; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxTotalCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadRxTotalCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0027; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxUnicastCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadRxUnicastCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0028; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxBroadcastCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRxBroadcastCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0029; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxDataCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadRxDataCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x002A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxDataPollCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRxDataPollCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x002B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxBeaconCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadRxBeaconCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x002C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxBeaconRequestCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRxBeaconRequestCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x002D; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxOtherCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadRxOtherCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x002E; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxAddressFilteredCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRxAddressFilteredCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x002F; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxDestAddrFilteredCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRxDestAddrFilteredCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0030; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxDuplicatedCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRxDuplicatedCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0031; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxErrNoFrameCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRxErrNoFrameCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0032; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxErrUnknownNeighborCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRxErrUnknownNeighborCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0033; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxErrInvalidSrcAddrCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRxErrInvalidSrcAddrCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0034; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxErrSecCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadRxErrSecCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0035; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxErrFcsCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadRxErrFcsCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0036; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeRxErrOtherCount(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadRxErrOtherCountAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0037; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeSecurityPolicy(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadSecurityPolicyAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x003B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + ThreadNetworkDiagnosticsClusterSecurityPolicyListAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeChannelMask(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeThreadNetworkDiagnosticsClusterReadChannelMaskAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x003C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeOperationalDatasetComponents(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadOperationalDatasetComponentsAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x003D; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + ThreadNetworkDiagnosticsClusterOperationalDatasetComponentsListAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeActiveNetworkFaultsList(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadActiveNetworkFaultsListAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x003E; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + ThreadNetworkDiagnosticsClusterActiveNetworkFaultsListListAttributeFilter); } CHIP_ERROR ThreadNetworkDiagnosticsCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = - encodeThreadNetworkDiagnosticsClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // WakeOnLan Cluster Commands @@ -9089,17 +10180,25 @@ CHIP_ERROR WakeOnLanCluster::DiscoverAttributes(Callback::Cancelable * onSuccess CHIP_ERROR WakeOnLanCluster::ReadAttributeWakeOnLanMacAddress(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWakeOnLanClusterReadWakeOnLanMacAddressAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR WakeOnLanCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWakeOnLanClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } // WindowCovering Cluster Commands @@ -9398,9 +10497,13 @@ CHIP_ERROR WindowCoveringCluster::DiscoverAttributes(Callback::Cancelable * onSu CHIP_ERROR WindowCoveringCluster::ReadAttributeType(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWindowCoveringClusterReadTypeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR WindowCoveringCluster::ConfigureAttributeType(Callback::Cancelable * onSuccessCallback, @@ -9421,9 +10524,13 @@ CHIP_ERROR WindowCoveringCluster::ReportAttributeType(Callback::Cancelable * onR CHIP_ERROR WindowCoveringCluster::ReadAttributeCurrentPositionLift(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWindowCoveringClusterReadCurrentPositionLiftAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0003; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR WindowCoveringCluster::ConfigureAttributeCurrentPositionLift(Callback::Cancelable * onSuccessCallback, @@ -9444,9 +10551,13 @@ CHIP_ERROR WindowCoveringCluster::ReportAttributeCurrentPositionLift(Callback::C CHIP_ERROR WindowCoveringCluster::ReadAttributeCurrentPositionTilt(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWindowCoveringClusterReadCurrentPositionTiltAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0004; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR WindowCoveringCluster::ConfigureAttributeCurrentPositionTilt(Callback::Cancelable * onSuccessCallback, @@ -9467,9 +10578,13 @@ CHIP_ERROR WindowCoveringCluster::ReportAttributeCurrentPositionTilt(Callback::C CHIP_ERROR WindowCoveringCluster::ReadAttributeConfigStatus(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWindowCoveringClusterReadConfigStatusAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0007; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR WindowCoveringCluster::ConfigureAttributeConfigStatus(Callback::Cancelable * onSuccessCallback, @@ -9490,41 +10605,61 @@ CHIP_ERROR WindowCoveringCluster::ReportAttributeConfigStatus(Callback::Cancelab CHIP_ERROR WindowCoveringCluster::ReadAttributeInstalledOpenLimitLift(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWindowCoveringClusterReadInstalledOpenLimitLiftAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0010; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR WindowCoveringCluster::ReadAttributeInstalledClosedLimitLift(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWindowCoveringClusterReadInstalledClosedLimitLiftAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0011; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR WindowCoveringCluster::ReadAttributeInstalledOpenLimitTilt(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWindowCoveringClusterReadInstalledOpenLimitTiltAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0012; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR WindowCoveringCluster::ReadAttributeInstalledClosedLimitTilt(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWindowCoveringClusterReadInstalledClosedLimitTiltAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0013; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR WindowCoveringCluster::ReadAttributeMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWindowCoveringClusterReadModeAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0017; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } CHIP_ERROR WindowCoveringCluster::WriteAttributeMode(Callback::Cancelable * onSuccessCallback, @@ -9538,9 +10673,13 @@ CHIP_ERROR WindowCoveringCluster::WriteAttributeMode(Callback::Cancelable * onSu CHIP_ERROR WindowCoveringCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { - uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeWindowCoveringClusterReadClusterRevisionAttribute(seqNum, mEndpoint); - return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); } } // namespace Controller diff --git a/src/controller/data_model/gen/callback-stub.cpp b/src/controller/data_model/gen/callback-stub.cpp index 8c996fead7c2af..70949137eb933f 100644 --- a/src/controller/data_model/gen/callback-stub.cpp +++ b/src/controller/data_model/gen/callback-stub.cpp @@ -720,22 +720,6 @@ emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, Att uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) {} -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/src/controller/data_model/gen/callback.h b/src/controller/data_model/gen/callback.h index ead6b8a597e530..7e7ebc5b2d0c10 100644 --- a/src/controller/data_model/gen/callback.h +++ b/src/controller/data_model/gen/callback.h @@ -4224,19 +4224,6 @@ EmberAfStatus emberAfPreAttributeChangeCallback(chip::EndpointId endpoint, chip: void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -/** @brief Read Attributes Response - * - * This function is called by the application framework when a Read Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of read attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadAttributesResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief External Attribute Read * * Like emberAfExternalAttributeWriteCallback above, this function is called diff --git a/src/controller/python/chip/clusters/CHIPClusters.cpp b/src/controller/python/chip/clusters/CHIPClusters.cpp index 891a35e59ce4e2..ddb6d77f3294a4 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.cpp +++ b/src/controller/python/chip/clusters/CHIPClusters.cpp @@ -55,14 +55,39 @@ void OnDefaultFailureResponse(void * /* context */, uint8_t status) } template -void OnAttributeResponse(void * /* context */, AttributeType) +void OnAttributeResponse(void * /* context */, AttributeType value) { + std::string strValue = std::to_string(value); + ChipLogProgress(Zcl, " attributeValue: %s", strValue.c_str()); + if (gSuccessResponseDelegate != nullptr) + gSuccessResponseDelegate(); +} + +template <> +void OnAttributeResponse(void * /* context */, chip::ByteSpan value) +{ + std::string strValue = ""; + for (size_t i = 0; i < value.size(); i++) + { + strValue += ' '; + strValue += std::to_string(value.data()[i]); + } + ChipLogProgress(Zcl, " attributeValue: (span of length %zd) %s", value.size(), strValue.c_str()); + if (gSuccessResponseDelegate != nullptr) + gSuccessResponseDelegate(); +} + +template <> +void OnAttributeResponse(void * /* context */, bool value) +{ + ChipLogProgress(Zcl, " attributeValue: %s", value ? "true" : "false"); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } static void OnApplicationLauncherApplicationLauncherListListAttributeResponse(void * context, uint16_t count, uint16_t * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -72,6 +97,7 @@ chip::Callback::Callback gAudio }; static void OnContentLauncherAcceptsHeaderListListAttributeResponse(void * context, uint16_t count, chip::ByteSpan * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -87,6 +114,7 @@ chip::Callback::Callback gContentLauncherAcceptsHeaderListListAttributeCallback{ OnContentLauncherAcceptsHeaderListListAttributeResponse, nullptr }; static void OnContentLauncherSupportedStreamingTypesListAttributeResponse(void * context, uint16_t count, uint8_t * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -95,6 +123,7 @@ chip::Callback::Callback gDescriptorD }; static void OnDescriptorServerListListAttributeResponse(void * context, uint16_t count, chip::ClusterId * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -111,6 +141,7 @@ chip::Callback::Callback gDescriptorS }; static void OnDescriptorClientListListAttributeResponse(void * context, uint16_t count, chip::ClusterId * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -119,6 +150,7 @@ chip::Callback::Callback gDescriptorC }; static void OnDescriptorPartsListListAttributeResponse(void * context, uint16_t count, chip::EndpointId * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -127,6 +159,7 @@ chip::Callback::Callback gDescriptorPa }; static void OnFixedLabelLabelListListAttributeResponse(void * context, uint16_t count, _LabelStruct * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -136,6 +169,7 @@ chip::Callback::Callback gFixedLabelLa static void OnGeneralDiagnosticsNetworkInterfacesListAttributeResponse(void * context, uint16_t count, _NetworkInterfaceType * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -144,6 +178,7 @@ chip::Callback::Callback gGroupKe }; static void OnGroupKeyManagementGroupKeysListAttributeResponse(void * context, uint16_t count, _GroupKey * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -160,6 +196,7 @@ chip::Callback::Callback gGrou }; static void OnMediaInputMediaInputListListAttributeResponse(void * context, uint16_t count, _MediaInputInfo * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -168,6 +205,7 @@ chip::Callback::Callback gMediaIn }; static void OnOperationalCredentialsFabricsListListAttributeResponse(void * context, uint16_t count, _FabricDescriptor * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -175,6 +213,7 @@ chip::Callback::Callback gOperationalCredentialsFabricsListListAttributeCallback{ OnOperationalCredentialsFabricsListListAttributeResponse, nullptr }; static void OnTvChannelTvChannelListListAttributeResponse(void * context, uint16_t count, _TvChannelInfo * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -184,6 +223,7 @@ chip::Callback::Callback gTvChannel static void OnTargetNavigatorTargetNavigatorListListAttributeResponse(void * context, uint16_t count, _NavigateTargetTargetInfo * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -191,6 +231,7 @@ chip::Callback::Callback gTestCluster }; static void OnTestClusterListOctetStringListAttributeResponse(void * context, uint16_t count, chip::ByteSpan * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -207,6 +249,7 @@ chip::Callback::Callback gTestC }; static void OnTestClusterListStructOctetStringListAttributeResponse(void * context, uint16_t count, _TestListStructOctet * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -215,6 +258,7 @@ chip::Callback::Callback static void OnThreadNetworkDiagnosticsNeighborTableListListAttributeResponse(void * context, uint16_t count, _NeighborTable * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -224,6 +268,7 @@ chip::Callback::Callback -void OnAttributeResponse(void * /* context */, AttributeType) + +template +void OnAttributeResponse(void * /* context */, AttributeType value) +{ + std::string strValue = std::to_string(value); + ChipLogProgress(Zcl, " attributeValue: %s", strValue.c_str()); + if (gSuccessResponseDelegate != nullptr) + gSuccessResponseDelegate(); +} + +template <> +void OnAttributeResponse(void * /* context */, chip::ByteSpan value) +{ + std::string strValue = ""; + for (size_t i = 0; i < value.size(); i++) + { + strValue += ' '; + strValue += std::to_string(value.data()[i]); + } + ChipLogProgress(Zcl, " attributeValue: (span of length %zd) %s", value.size(), strValue.c_str()); + if (gSuccessResponseDelegate != nullptr) + gSuccessResponseDelegate(); +} + +template <> +void OnAttributeResponse(void * /* context */, bool value) { + ChipLogProgress(Zcl, " attributeValue: %s", value ? "true" : "false"); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } @@ -49,6 +74,7 @@ void OnAttributeResponse(void * /* context */, AttributeType) {{#if isList}} static void On{{asCamelCased parent.name false}}{{asCamelCased name false}}ListAttributeResponse(void * context, uint16_t count, {{chipType}} * entries) { + ChipLogProgress(Zcl, " attributeValue: List of length %" PRIu16, count); if (gSuccessResponseDelegate != nullptr) gSuccessResponseDelegate(); } diff --git a/src/controller/python/templates/python-CHIPClusters-py.zapt b/src/controller/python/templates/python-CHIPClusters-py.zapt index c47a08dac9cda4..e25d693a1f1eb3 100644 --- a/src/controller/python/templates/python-CHIPClusters-py.zapt +++ b/src/controller/python/templates/python-CHIPClusters-py.zapt @@ -156,8 +156,12 @@ class ChipClusters: def HandleSuccess(): self._ChipStack.callbackRes = 0 self._ChipStack.completeEvent.set() + def HandleFailure(status): self._ChipStack.callbackRes = status self._ChipStack.completeEvent.set() - self._chipLib.chip_ime_SetSuccessResponseDelegate(ChipClusters.SUCCESS_DELEGATE(HandleSuccess)) - self._chipLib.chip_ime_SetFailureResponseDelegate(ChipClusters.FAILURE_DELEGATE(HandleFailure)) + + self._HandleSuccess = ChipClusters.SUCCESS_DELEGATE(HandleSuccess) + self._HandleFailure = ChipClusters.FAILURE_DELEGATE(HandleFailure) + self._chipLib.chip_ime_SetSuccessResponseDelegate(self._HandleSuccess) + self._chipLib.chip_ime_SetFailureResponseDelegate(self._HandleFailure) diff --git a/src/lib/support/FunctionTraits.h b/src/lib/support/FunctionTraits.h new file mode 100644 index 00000000000000..17853a50af8c28 --- /dev/null +++ b/src/lib/support/FunctionTraits.h @@ -0,0 +1,40 @@ +/* + * + * 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 + +namespace chip { + +template +struct FunctionTraits +{ +}; + +/** + * Template struct for getting function return type and argument types. + */ +template +struct FunctionTraits +{ + using ReturnType = ReturnT; + template + using ArgType = std::tuple_element_t>; +}; + +} // namespace chip