diff --git a/examples/dynamic-bridge-app/linux/DynamicDevice.cpp b/examples/dynamic-bridge-app/linux/DynamicDevice.cpp index 98b411a6e631f1..9f0ca3951e8ce0 100644 --- a/examples/dynamic-bridge-app/linux/DynamicDevice.cpp +++ b/examples/dynamic-bridge-app/linux/DynamicDevice.cpp @@ -17,12 +17,27 @@ * limitations under the License. */ +#include +#include +#include + #include "DynamicDevice.h" #define DEVICE_TYPE_BRIDGED_NODE 0x0013 // Device Version for dynamic endpoints: #define DEVICE_VERSION_DEFAULT 1 +namespace { +static const int kDescriptorAttributeArraySize = 254; + +DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs) +DECLARE_DYNAMIC_ATTRIBUTE(ZCL_DEVICE_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* device list */ + DECLARE_DYNAMIC_ATTRIBUTE(ZCL_SERVER_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* server list */ + DECLARE_DYNAMIC_ATTRIBUTE(ZCL_CLIENT_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* client list */ + DECLARE_DYNAMIC_ATTRIBUTE(ZCL_PARTS_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* parts list */ + DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); +} // namespace + DynamicDevice::DynamicDevice() {} void DynamicDevice::AddDeviceType(EmberAfDeviceType type) @@ -34,10 +49,14 @@ Device DynamicDevice::CreateDevice() { // All nodes are bridged devices. mDeviceTypes.push_back(EmberAfDeviceType{ DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT }); - mVersions.resize(mClusterRawPtrs.size()); + mVersions.resize(mClusterRawPtrs.size() + 1); // +1 for the descriptor cluster for (auto * c : mClusterRawPtrs) mClusterBaseRawPtrs.push_back(c); + // Force a default descriptor cluster to be present. + mClusterDecls.emplace_back( + EmberAfCluster DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs, nullptr, nullptr)); + return Device(chip::Span(mVersions.data(), mVersions.size()), chip::Span(mClusterDecls.data(), mClusterDecls.size()), chip::Span(mClusterBaseRawPtrs.data(), mClusterBaseRawPtrs.size()), diff --git a/examples/dynamic-bridge-app/linux/main.cpp b/examples/dynamic-bridge-app/linux/main.cpp index 652637a48bc8e3..d106b9c379b0a7 100644 --- a/examples/dynamic-bridge-app/linux/main.cpp +++ b/examples/dynamic-bridge-app/linux/main.cpp @@ -294,8 +294,12 @@ int main(int argc, char * argv[]) clusterAccess.reserve(std::extent::value); for (auto & entry : clusters::kKnownClusters) { - clusterAccess.emplace_back(chip::Optional(), entry.id); - registerAttributeAccessOverride(&clusterAccess.back()); + // Desciptor clusters should not be overridden. + if (entry.id != chip::app::Clusters::Descriptor::Id) + { + clusterAccess.emplace_back(chip::Optional(), entry.id); + registerAttributeAccessOverride(&clusterAccess.back()); + } } ChipLinuxAppMainLoop();