diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/ZCLCallbacks.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/ZCLCallbacks.cpp index 9a0467be4e27e8..26e727901abf0e 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/ZCLCallbacks.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/ZCLCallbacks.cpp @@ -26,6 +26,7 @@ using namespace ::chip; using namespace ::chip::app::Clusters; #define ZCL_DESCRIPTOR_CLUSTER_REVISION (1u) +#define ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_REVISION (1u) #define ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION (2u) #define ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_FEATURE_MAP (0u) @@ -37,9 +38,14 @@ Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(Endpoin AttributeId attributeId = attributeMetadata->attributeId; BridgedDevice * dev = BridgeDeviceMgr().GetDevice(endpoint); - if (dev != nullptr && clusterId == app::Clusters::BridgedDeviceBasicInformation::Id) + if (dev == nullptr) { - using namespace app::Clusters::BridgedDeviceBasicInformation::Attributes; + return Protocols::InteractionModel::Status::Failure; + } + + if (clusterId == BridgedDeviceBasicInformation::Id) + { + using namespace BridgedDeviceBasicInformation::Attributes; ChipLogProgress(NotSpecified, "HandleReadBridgedDeviceBasicAttribute: attrId=%d, maxReadLength=%d", attributeId, maxReadLength); @@ -69,6 +75,21 @@ Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(Endpoin return Protocols::InteractionModel::Status::Success; } + if (clusterId == AdministratorCommissioning::Id) + { + // TODO(#34791) This is a workaround to prevent crash. CADMIN is still reading incorrect + // Attribute values on dynamic endpoint as it only reads the root node and not the actual bridge + // device we are representing here, when addressing the issue over there we can more easily + // resolve this workaround. + if ((attributeId == AdministratorCommissioning::Attributes::ClusterRevision::Id) && (maxReadLength == 2)) + { + uint16_t rev = ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_REVISION; + memcpy(buffer, &rev, sizeof(rev)); + return Protocols::InteractionModel::Status::Success; + } + return Protocols::InteractionModel::Status::Failure; + } + return Protocols::InteractionModel::Status::Failure; }