From 3412b8af0a5f748014c91225f05bf2ca89b88673 Mon Sep 17 00:00:00 2001
From: Shubham Patil <shubham.patil@espressif.com>
Date: Fri, 24 Jan 2025 14:59:08 +0800
Subject: [PATCH] Merge branch 'fix-network-commissioning-attributes' into
 'main'

components/esp_matter: create network commissioning attributes as per feature map

See merge request app-frameworks/esp-matter!1023

(cherry picked from commit 23a9466cd34ce8eafd0ebc56f16bdb0e27d7058e)

770b246f components/esp_matter: create network commissioning attributes as per

Co-authored-by: Hrishikesh Dhayagude <hrishi@espressif.com>
---
 components/esp_matter/esp_matter_cluster.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp
index 9215e72b4..7120910e8 100644
--- a/components/esp_matter/esp_matter_cluster.cpp
+++ b/components/esp_matter/esp_matter_cluster.cpp
@@ -403,12 +403,16 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
         /* Attributes managed internally */
         attribute::create_max_networks(cluster, 0);
         attribute::create_networks(cluster, NULL, 0, 0);
-        attribute::create_scan_max_time_seconds(cluster, 0);
-        attribute::create_connect_max_time_seconds(cluster, 0);
         attribute::create_interface_enabled(cluster, 0);
         attribute::create_last_networking_status(cluster, nullable<uint8_t>());
         attribute::create_last_network_id(cluster, NULL, 0);
         attribute::create_last_connect_error_value(cluster, nullable<int32_t>());
+
+        if (config->feature_map & chip::to_underlying(NetworkCommissioning::Feature::kWiFiNetworkInterface) ||
+            config->feature_map & chip::to_underlying(NetworkCommissioning::Feature::kThreadNetworkInterface)) {
+            attribute::create_scan_max_time_seconds(cluster, 0);
+            attribute::create_connect_max_time_seconds(cluster, 0);
+        }
         if (config->feature_map & chip::to_underlying(NetworkCommissioning::Feature::kWiFiNetworkInterface)) {
             attribute::create_supported_wifi_bands(cluster, NULL, 0, 0);
         }