From 59ec008b696a2d5a08bb986b2796b01648a3f0ba Mon Sep 17 00:00:00 2001
From: chendejin <chendejin@espressif.com>
Date: Mon, 24 Jun 2024 19:35:19 +0800
Subject: [PATCH 1/5] ESP32: added config for Wi-Fi, Thread, and Ethernet
 network commissioning drivers

---
 config/esp32/components/chip/CMakeLists.txt   |  3 ++
 config/esp32/components/chip/Kconfig          | 48 +++++++++++++++++++
 examples/all-clusters-app/esp32/README.md     | 25 ++++++----
 .../platform/esp32/common/Esp32AppServer.cpp  | 19 --------
 src/platform/ESP32/CHIPDevicePlatformConfig.h |  3 ++
 .../ESP32/ConnectivityManagerImpl.cpp         | 31 ++++++++++++
 6 files changed, 100 insertions(+), 29 deletions(-)

diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt
index 672cf849af1244..06b977b2bb1c69 100644
--- a/config/esp32/components/chip/CMakeLists.txt
+++ b/config/esp32/components/chip/CMakeLists.txt
@@ -220,6 +220,9 @@ endif()
 
 if (CONFIG_ENABLE_MATTER_OVER_THREAD)
     chip_gn_arg_append("chip_enable_openthread"                 "true")
+    if (CONFIG_THREAD_NETWORK_COMMISSIONING_DRIVER)
+        chip_gn_arg_append("chip_device_config_thread_network_endpoint_id" ${CONFIG_THREAD_NETWORK_ENDPOINT_ID})
+    endif()
 else()
     chip_gn_arg_append("chip_enable_openthread"                 "false")
 endif()
diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig
index e2f9dcc099eba6..1018adca4dfa2e 100644
--- a/config/esp32/components/chip/Kconfig
+++ b/config/esp32/components/chip/Kconfig
@@ -1287,4 +1287,52 @@ menu "CHIP Device Layer"
 
     endmenu
 
+    menu "Network Commissioning Driver Endpoint Id"
+        config THREAD_NETWORK_COMMISSIONING_DRIVER
+            bool "Use the generic Thread network commissioning driver"
+            depends on ENABLE_MATTER_OVER_THREAD
+            default y
+            help
+                Option to enable/disable the use of generic Thread network commissioning driver.
+
+        config THREAD_NETWORK_ENDPOINT_ID
+            int "Endpoint Id for Thread network"
+            depends on THREAD_NETWORK_COMMISSIONING_DRIVER
+            range 0 65534
+            default 0
+            help
+                The endpoint id for the generic Thread network commissioning driver.
+
+        config WIFI_NETWORK_COMMISSIONING_DRIVER
+            bool "Use ESP Wi-Fi network commissioning driver"
+            depends on ENABLE_WIFI_STATION || ENABLE_WIFI_AP
+            default y
+            help
+                Option to enable/disable the use of ESP Wi-Fi network commissioning driver.
+
+        config WIFI_NETWORK_ENDPOINT_ID
+            int "Endpoint Id for Wi-Fi network"
+            depends on WIFI_NETWORK_COMMISSIONING_DRIVER
+            range 0 65534
+            default 0
+            help
+                The endpoint id for the ESP Wi-Fi network commissioning driver.
+
+        config ETHERNET_NETWORK_COMMISSIONING_DRIVER
+            bool "Use ESP Ethernet network commissioning driver"
+            depends on ENABLE_ETHERNET_TELEMETRY
+            default y
+            help
+                Option to enable/disable the use of ESP Ethernet network commissioning driver.
+
+        config ETHERNET_NETWORK_ENDPOINT_ID
+            int "Endpoint Id for Ethernet network"
+            depends on ETHERNET_NETWORK_COMMISSIONING_DRIVER
+            range 0 65534
+            default 0
+            help
+                The endpoint id for the ESP Ethernet network commissioning driver.
+
+    endmenu
+
 endmenu
diff --git a/examples/all-clusters-app/esp32/README.md b/examples/all-clusters-app/esp32/README.md
index 60ee180c1337fd..bf2116763d129a 100644
--- a/examples/all-clusters-app/esp32/README.md
+++ b/examples/all-clusters-app/esp32/README.md
@@ -11,10 +11,11 @@ guides to get started.
 
 ---
 
--   [Cluster control](#cluster-control)
--   [Matter OTA guide](../../../docs/guides/esp32/ota.md)
--   [RPC console and Device Tracing](../../../docs/guides/esp32/rpc_console.md)
--   [Multiple Network Interfaces](#multiple-network-interfaces)
+- [Matter ESP32 All Clusters Example](#matter-esp32-all-clusters-example)
+    - [Cluster control](#cluster-control)
+      - [onoff](#onoff)
+      - [levelcontrol](#levelcontrol)
+    - [Multiple Network Interfaces](#multiple-network-interfaces)
 
 ---
 
@@ -47,14 +48,18 @@ NetworkCommissioning Endpoint can be used to manage the driver of extra network
 interface.
 
 For ESP32-C6 DevKits, if `CHIP_DEVICE_CONFIG_ENABLE_WIFI` and
-`CHIP_DEVICE_CONFIG_ENABLE_THREAD` are both enabled, the NetworkCommissioning
-cluster in Endpoint 0 will be used for Thread network driver and the same
-cluster on Endpoint 65534 will be used for Wi-Fi network driver.
+`CHIP_DEVICE_CONFIG_ENABLE_THREAD` are both enabled, please set
+`CONFIG_THREAD_NETWORK_ENDPOINT_ID` to 0 and set `CONFIG_WIFI_NETWORK_ENDPOINT_ID`
+to 65534, which presents that the NetworkCommissioning cluster in Endpoint 0 will
+be used for Thread network driver and the same cluster on Endpoint 65534 will be
+used for Wi-Fi network driver. Or vice versa.
 
 For ESP32-Ethernet-Kits, if `CHIP_DEVICE_CONFIG_ENABLE_WIFI` and
-`CHIP_DEVICE_CONFIG_ENABLE_ETHERNET` are both enabled, the NetworkCommissioning
-cluster in Endpoint 0 will be used for Ethernet network driver and the same
-cluster on Endpoint 65534 will be used for Wi-Fi network driver.
+`CHIP_DEVICE_CONFIG_ENABLE_ETHERNET` are both enabled, please set
+`CONFIG_ETHERNET_NETWORK_ENDPOINT_ID` to 0 and set `CONFIG_WIFI_NETWORK_ENDPOINT_ID`
+to 65534, which presents that the NetworkCommissioning cluster in Endpoint 0 will be
+used for Ethernet network driver and the same cluster on Endpoint 65534 will be used
+for Wi-Fi network driver. Or vice versa.
 
 ---
 
diff --git a/examples/platform/esp32/common/Esp32AppServer.cpp b/examples/platform/esp32/common/Esp32AppServer.cpp
index 4f854c518bd01f..789c6f44f81d18 100644
--- a/examples/platform/esp32/common/Esp32AppServer.cpp
+++ b/examples/platform/esp32/common/Esp32AppServer.cpp
@@ -47,19 +47,6 @@ using namespace chip::DeviceLayer;
 static constexpr char TAG[] = "ESP32Appserver";
 
 namespace {
-#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD || CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
-constexpr chip::EndpointId kNetworkCommissioningEndpointWiFi = 0xFFFE;
-#else
-constexpr chip::EndpointId kNetworkCommissioningEndpointWiFi = 0;
-#endif
-app::Clusters::NetworkCommissioning::Instance
-    sWiFiNetworkCommissioningInstance(kNetworkCommissioningEndpointWiFi, &(NetworkCommissioning::ESPWiFiDriver::GetInstance()));
-#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI
-#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
-static app::Clusters::NetworkCommissioning::Instance
-    sEthernetNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::ESPEthernetDriver::GetInstance()));
-#endif
 
 #if CONFIG_TEST_EVENT_TRIGGER_ENABLED
 static uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
@@ -145,12 +132,6 @@ void Esp32AppServer::Init(AppDelegate * sAppDelegate)
     }
     chip::Server::GetInstance().Init(initParams);
 
-#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
-    sWiFiNetworkCommissioningInstance.Init();
-#endif
-#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
-    sEthernetNetworkCommissioningInstance.Init();
-#endif
 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
     if (chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() &&
         (chip::Server::GetInstance().GetFabricTable().FabricCount() != 0))
diff --git a/src/platform/ESP32/CHIPDevicePlatformConfig.h b/src/platform/ESP32/CHIPDevicePlatformConfig.h
index e347df109d1e3a..c3bfe874dc8cb2 100644
--- a/src/platform/ESP32/CHIPDevicePlatformConfig.h
+++ b/src/platform/ESP32/CHIPDevicePlatformConfig.h
@@ -50,6 +50,9 @@
 
 #ifdef CONFIG_ENABLE_MATTER_OVER_THREAD
 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_ENABLE_MATTER_OVER_THREAD
+#if !CONFIG_THREAD_NETWORK_COMMISSIONING_DRIVER
+#define _NO_NETWORK_COMMISSIONING_DRIVER_ 1
+#endif // !CONFIG_THREAD_NETWORK_COMMISSIONING_DRIVER
 #else
 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0
 #endif // CONFIG_ENABLE_MATTER_OVER_THREAD
diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp
index 85146257ebe985..7bccf06de95d2e 100644
--- a/src/platform/ESP32/ConnectivityManagerImpl.cpp
+++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp
@@ -39,9 +39,11 @@
 #include <platform/internal/GenericConnectivityManagerImpl_WiFi.ipp>
 #endif
 
+#include <app/clusters/network-commissioning/network-commissioning.h>
 #include <esp_wifi.h>
 #include <lib/support/CodeUtils.h>
 #include <lib/support/logging/CHIPLogging.h>
+#include <platform/ESP32/NetworkCommissioningDriver.h>
 #include <platform/internal/BLEManager.h>
 
 using namespace ::chip;
@@ -53,6 +55,18 @@ namespace chip {
 namespace DeviceLayer {
 
 ConnectivityManagerImpl ConnectivityManagerImpl::sInstance;
+
+#if CHIP_DEVICE_CONFIG_ENABLE_WIFI && CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
+app::Clusters::NetworkCommissioning::Instance
+    sWiFiNetworkCommissioningInstance(CONFIG_WIFI_NETWORK_ENDPOINT_ID /* Endpoint Id */,
+                                      &(NetworkCommissioning::ESPWiFiDriver::GetInstance()));
+#endif
+
+#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET && CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
+app::Clusters::NetworkCommissioning::Instance
+    sEthernetNetworkCommissioningInstance(CONFIG_ETHERNET_NETWORK_ENDPOINT_ID /* Endpoint Id */,
+                                          &(NetworkCommissioning::ESPEthernetDriver::GetInstance()));
+#endif
 // ==================== ConnectivityManager Platform Internal Methods ====================
 
 CHIP_ERROR ConnectivityManagerImpl::_Init()
@@ -62,10 +76,27 @@ CHIP_ERROR ConnectivityManagerImpl::_Init()
 #endif
 #if CHIP_DEVICE_CONFIG_ENABLE_WIFI
     InitWiFi();
+#if CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
+    sWiFiNetworkCommissioningInstance.Init();
+#endif // CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
 #endif
 #if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
     InitEthernet();
+#if CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
+    sEthernetNetworkCommissioningInstance.Init();
+#endif // CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
 #endif
+
+#if defined(CONFIG_WIFI_NETWORK_ENDPOINT_ID) && defined(CONFIG_THREAD_NETWORK_ENDPOINT_ID)
+    static_assert(CONFIG_WIFI_NETWORK_ENDPOINT_ID != CONFIG_THREAD_NETWORK_ENDPOINT_ID, "Wi-Fi network endpoint id and Thread network endpoint id should not be the same.");
+#endif
+#if defined(CONFIG_WIFI_NETWORK_ENDPOINT_ID) && defined(CONFIG_ETHERNET_NETWORK_ENDPOINT_ID)
+    static_assert(CONFIG_WIFI_NETWORK_ENDPOINT_ID != CONFIG_ETHERNET_NETWORK_ENDPOINT_ID, "Wi-Fi network endpoint id and Ethernet network endpoint id should not be the same.");
+#endif
+#if defined(CONFIG_THREAD_NETWORK_ENDPOINT_ID) && defined(CONFIG_ETHERNET_NETWORK_ENDPOINT_ID)
+    static_assert(CONFIG_THREAD_NETWORK_ENDPOINT_ID != CONFIG_ETHERNET_NETWORK_ENDPOINT_ID, "Thread network endpoint id and Ethernet network endpoint id should not be the same.");
+#endif
+
     return CHIP_NO_ERROR;
 }
 

From bcab9bed8eaa5059aaa6da5c97baeb722713eff5 Mon Sep 17 00:00:00 2001
From: cdj <45139296+DejinChen@users.noreply.github.com>
Date: Mon, 24 Jun 2024 19:44:27 +0800
Subject: [PATCH 2/5] Update README.md

---
 examples/all-clusters-app/esp32/README.md | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/examples/all-clusters-app/esp32/README.md b/examples/all-clusters-app/esp32/README.md
index bf2116763d129a..0e95fc52392e10 100644
--- a/examples/all-clusters-app/esp32/README.md
+++ b/examples/all-clusters-app/esp32/README.md
@@ -11,11 +11,10 @@ guides to get started.
 
 ---
 
-- [Matter ESP32 All Clusters Example](#matter-esp32-all-clusters-example)
-    - [Cluster control](#cluster-control)
-      - [onoff](#onoff)
-      - [levelcontrol](#levelcontrol)
-    - [Multiple Network Interfaces](#multiple-network-interfaces)
+-   [Cluster control](#cluster-control)
+-   [Matter OTA guide](../../../docs/guides/esp32/ota.md)
+-   [RPC console and Device Tracing](../../../docs/guides/esp32/rpc_console.md)
+-   [Multiple Network Interfaces](#multiple-network-interfaces)
 
 ---
 

From 45ffefcbf238e43cedd32db0c7d48ce609a22b25 Mon Sep 17 00:00:00 2001
From: chendejin <chendejin@espressif.com>
Date: Mon, 24 Jun 2024 19:50:37 +0800
Subject: [PATCH 3/5] Restyled

---
 src/platform/ESP32/ConnectivityManagerImpl.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp
index 7bccf06de95d2e..972705e662a9d6 100644
--- a/src/platform/ESP32/ConnectivityManagerImpl.cpp
+++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp
@@ -88,13 +88,16 @@ CHIP_ERROR ConnectivityManagerImpl::_Init()
 #endif
 
 #if defined(CONFIG_WIFI_NETWORK_ENDPOINT_ID) && defined(CONFIG_THREAD_NETWORK_ENDPOINT_ID)
-    static_assert(CONFIG_WIFI_NETWORK_ENDPOINT_ID != CONFIG_THREAD_NETWORK_ENDPOINT_ID, "Wi-Fi network endpoint id and Thread network endpoint id should not be the same.");
+    static_assert(CONFIG_WIFI_NETWORK_ENDPOINT_ID != CONFIG_THREAD_NETWORK_ENDPOINT_ID,
+                  "Wi-Fi network endpoint id and Thread network endpoint id should not be the same.");
 #endif
 #if defined(CONFIG_WIFI_NETWORK_ENDPOINT_ID) && defined(CONFIG_ETHERNET_NETWORK_ENDPOINT_ID)
-    static_assert(CONFIG_WIFI_NETWORK_ENDPOINT_ID != CONFIG_ETHERNET_NETWORK_ENDPOINT_ID, "Wi-Fi network endpoint id and Ethernet network endpoint id should not be the same.");
+    static_assert(CONFIG_WIFI_NETWORK_ENDPOINT_ID != CONFIG_ETHERNET_NETWORK_ENDPOINT_ID,
+                  "Wi-Fi network endpoint id and Ethernet network endpoint id should not be the same.");
 #endif
 #if defined(CONFIG_THREAD_NETWORK_ENDPOINT_ID) && defined(CONFIG_ETHERNET_NETWORK_ENDPOINT_ID)
-    static_assert(CONFIG_THREAD_NETWORK_ENDPOINT_ID != CONFIG_ETHERNET_NETWORK_ENDPOINT_ID, "Thread network endpoint id and Ethernet network endpoint id should not be the same.");
+    static_assert(CONFIG_THREAD_NETWORK_ENDPOINT_ID != CONFIG_ETHERNET_NETWORK_ENDPOINT_ID,
+                  "Thread network endpoint id and Ethernet network endpoint id should not be the same.");
 #endif
 
     return CHIP_NO_ERROR;

From 017143720b85c252158cfec9400c867986054d3a Mon Sep 17 00:00:00 2001
From: "Restyled.io" <commits@restyled.io>
Date: Mon, 24 Jun 2024 11:51:05 +0000
Subject: [PATCH 4/5] Restyled by prettier-markdown

---
 examples/all-clusters-app/esp32/README.md | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/examples/all-clusters-app/esp32/README.md b/examples/all-clusters-app/esp32/README.md
index 0e95fc52392e10..0a3145dbc24da2 100644
--- a/examples/all-clusters-app/esp32/README.md
+++ b/examples/all-clusters-app/esp32/README.md
@@ -48,17 +48,19 @@ interface.
 
 For ESP32-C6 DevKits, if `CHIP_DEVICE_CONFIG_ENABLE_WIFI` and
 `CHIP_DEVICE_CONFIG_ENABLE_THREAD` are both enabled, please set
-`CONFIG_THREAD_NETWORK_ENDPOINT_ID` to 0 and set `CONFIG_WIFI_NETWORK_ENDPOINT_ID`
-to 65534, which presents that the NetworkCommissioning cluster in Endpoint 0 will
-be used for Thread network driver and the same cluster on Endpoint 65534 will be
-used for Wi-Fi network driver. Or vice versa.
+`CONFIG_THREAD_NETWORK_ENDPOINT_ID` to 0 and set
+`CONFIG_WIFI_NETWORK_ENDPOINT_ID` to 65534, which presents that the
+NetworkCommissioning cluster in Endpoint 0 will be used for Thread network
+driver and the same cluster on Endpoint 65534 will be used for Wi-Fi network
+driver. Or vice versa.
 
 For ESP32-Ethernet-Kits, if `CHIP_DEVICE_CONFIG_ENABLE_WIFI` and
 `CHIP_DEVICE_CONFIG_ENABLE_ETHERNET` are both enabled, please set
-`CONFIG_ETHERNET_NETWORK_ENDPOINT_ID` to 0 and set `CONFIG_WIFI_NETWORK_ENDPOINT_ID`
-to 65534, which presents that the NetworkCommissioning cluster in Endpoint 0 will be
-used for Ethernet network driver and the same cluster on Endpoint 65534 will be used
-for Wi-Fi network driver. Or vice versa.
+`CONFIG_ETHERNET_NETWORK_ENDPOINT_ID` to 0 and set
+`CONFIG_WIFI_NETWORK_ENDPOINT_ID` to 65534, which presents that the
+NetworkCommissioning cluster in Endpoint 0 will be used for Ethernet network
+driver and the same cluster on Endpoint 65534 will be used for Wi-Fi network
+driver. Or vice versa.
 
 ---
 

From d5c4e0c19660acea6f3b9d242f037a13574851ca Mon Sep 17 00:00:00 2001
From: chendejin <chendejin@espressif.com>
Date: Tue, 25 Jun 2024 12:28:43 +0800
Subject: [PATCH 5/5] Fix CI

---
 config/esp32/components/chip/Kconfig             | 12 +++++++++---
 .../persistent-storage/esp32/sdkconfig.defaults  |  3 +++
 examples/shell/esp32/sdkconfig.defaults          |  3 +++
 src/platform/ESP32/CHIPDevicePlatformConfig.h    | 16 ++++++++++++++--
 src/platform/ESP32/ConnectivityManagerImpl.cpp   | 12 ++++++------
 5 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig
index 1018adca4dfa2e..44f9a34d2ff8b5 100644
--- a/config/esp32/components/chip/Kconfig
+++ b/config/esp32/components/chip/Kconfig
@@ -157,6 +157,12 @@ menu "CHIP Core"
             help
                 Option to enable/disable CHIP log level filtering APIs.
 
+        config ENABLE_CHIP_DATA_MODEL
+            bool "Enable CHIP data model"
+            default y
+            help
+                Option to enable/disable CHIP data model.
+
     endmenu # "General Options"
 
     menu "Networking Options"
@@ -1290,7 +1296,7 @@ menu "CHIP Device Layer"
     menu "Network Commissioning Driver Endpoint Id"
         config THREAD_NETWORK_COMMISSIONING_DRIVER
             bool "Use the generic Thread network commissioning driver"
-            depends on ENABLE_MATTER_OVER_THREAD
+            depends on ENABLE_MATTER_OVER_THREAD && ENABLE_CHIP_DATA_MODEL
             default y
             help
                 Option to enable/disable the use of generic Thread network commissioning driver.
@@ -1305,7 +1311,7 @@ menu "CHIP Device Layer"
 
         config WIFI_NETWORK_COMMISSIONING_DRIVER
             bool "Use ESP Wi-Fi network commissioning driver"
-            depends on ENABLE_WIFI_STATION || ENABLE_WIFI_AP
+            depends on (ENABLE_WIFI_STATION || ENABLE_WIFI_AP) && ENABLE_CHIP_DATA_MODEL
             default y
             help
                 Option to enable/disable the use of ESP Wi-Fi network commissioning driver.
@@ -1320,7 +1326,7 @@ menu "CHIP Device Layer"
 
         config ETHERNET_NETWORK_COMMISSIONING_DRIVER
             bool "Use ESP Ethernet network commissioning driver"
-            depends on ENABLE_ETHERNET_TELEMETRY
+            depends on ENABLE_ETHERNET_TELEMETRY && ENABLE_CHIP_DATA_MODEL
             default y
             help
                 Option to enable/disable the use of ESP Ethernet network commissioning driver.
diff --git a/examples/persistent-storage/esp32/sdkconfig.defaults b/examples/persistent-storage/esp32/sdkconfig.defaults
index f9a4c4bbcb05da..45488e615dece7 100644
--- a/examples/persistent-storage/esp32/sdkconfig.defaults
+++ b/examples/persistent-storage/esp32/sdkconfig.defaults
@@ -32,3 +32,6 @@ CONFIG_DEVICE_PRODUCT_ID=0x8009
 
 # Enable HKDF in mbedtls
 CONFIG_MBEDTLS_HKDF_C=y
+
+# Disable CHIP data model
+CONFIG_ENABLE_CHIP_DATA_MODEL=n
diff --git a/examples/shell/esp32/sdkconfig.defaults b/examples/shell/esp32/sdkconfig.defaults
index a77fbf41167c0c..efd5d235a1cf54 100644
--- a/examples/shell/esp32/sdkconfig.defaults
+++ b/examples/shell/esp32/sdkconfig.defaults
@@ -41,3 +41,6 @@ CONFIG_ENABLE_CHIP_SHELL=y
 
 # Enable HKDF in mbedtls
 CONFIG_MBEDTLS_HKDF_C=y
+
+# Disable CHIP data model
+CONFIG_ENABLE_CHIP_DATA_MODEL=n
diff --git a/src/platform/ESP32/CHIPDevicePlatformConfig.h b/src/platform/ESP32/CHIPDevicePlatformConfig.h
index c3bfe874dc8cb2..dc4f380c262fb5 100644
--- a/src/platform/ESP32/CHIPDevicePlatformConfig.h
+++ b/src/platform/ESP32/CHIPDevicePlatformConfig.h
@@ -50,9 +50,9 @@
 
 #ifdef CONFIG_ENABLE_MATTER_OVER_THREAD
 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_ENABLE_MATTER_OVER_THREAD
-#if !CONFIG_THREAD_NETWORK_COMMISSIONING_DRIVER
+#ifndef CONFIG_THREAD_NETWORK_COMMISSIONING_DRIVER
 #define _NO_NETWORK_COMMISSIONING_DRIVER_ 1
-#endif // !CONFIG_THREAD_NETWORK_COMMISSIONING_DRIVER
+#endif
 #else
 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0
 #endif // CONFIG_ENABLE_MATTER_OVER_THREAD
@@ -167,3 +167,15 @@
 #define CHIP_DEVICE_CONFIG_BG_TASK_PRIORITY CONFIG_BG_CHIP_TASK_PRIORITY
 #define CHIP_DEVICE_CONFIG_BG_MAX_EVENT_QUEUE_SIZE CONFIG_BG_MAX_EVENT_QUEUE_SIZE
 #define CHIP_DEVICE_CONFIG_BG_TASK_STACK_SIZE CONFIG_BG_CHIP_TASK_STACK_SIZE
+
+#ifdef CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
+#define CHIP_DEVICE_CONFIG_WIFI_NETWORK_DRIVER CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
+#else
+#define CHIP_DEVICE_CONFIG_WIFI_NETWORK_DRIVER 0
+#endif // CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
+
+#ifdef CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
+#define CHIP_DEVICE_CONFIG_ETHERNET_NETWORK_DRIVER CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
+#else
+#define CHIP_DEVICE_CONFIG_ETHERNET_NETWORK_DRIVER 0
+#endif // CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp
index 972705e662a9d6..2b042a5d5c2fcb 100644
--- a/src/platform/ESP32/ConnectivityManagerImpl.cpp
+++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp
@@ -56,13 +56,13 @@ namespace DeviceLayer {
 
 ConnectivityManagerImpl ConnectivityManagerImpl::sInstance;
 
-#if CHIP_DEVICE_CONFIG_ENABLE_WIFI && CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
+#if CHIP_DEVICE_CONFIG_ENABLE_WIFI && CHIP_DEVICE_CONFIG_WIFI_NETWORK_DRIVER
 app::Clusters::NetworkCommissioning::Instance
     sWiFiNetworkCommissioningInstance(CONFIG_WIFI_NETWORK_ENDPOINT_ID /* Endpoint Id */,
                                       &(NetworkCommissioning::ESPWiFiDriver::GetInstance()));
 #endif
 
-#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET && CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
+#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET && CHIP_DEVICE_CONFIG_ETHERNET_NETWORK_DRIVER
 app::Clusters::NetworkCommissioning::Instance
     sEthernetNetworkCommissioningInstance(CONFIG_ETHERNET_NETWORK_ENDPOINT_ID /* Endpoint Id */,
                                           &(NetworkCommissioning::ESPEthernetDriver::GetInstance()));
@@ -76,15 +76,15 @@ CHIP_ERROR ConnectivityManagerImpl::_Init()
 #endif
 #if CHIP_DEVICE_CONFIG_ENABLE_WIFI
     InitWiFi();
-#if CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
+#if CHIP_DEVICE_CONFIG_WIFI_NETWORK_DRIVER
     sWiFiNetworkCommissioningInstance.Init();
-#endif // CONFIG_WIFI_NETWORK_COMMISSIONING_DRIVER
+#endif // CHIP_DEVICE_CONFIG_WIFI_NETWORK_DRIVER
 #endif
 #if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
     InitEthernet();
-#if CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
+#if CHIP_DEVICE_CONFIG_ETHERNET_NETWORK_DRIVER
     sEthernetNetworkCommissioningInstance.Init();
-#endif // CONFIG_ETHERNET_NETWORK_COMMISSIONING_DRIVER
+#endif // CHIP_DEVICE_CONFIG_ETHERNET_NETWORK_DRIVER
 #endif
 
 #if defined(CONFIG_WIFI_NETWORK_ENDPOINT_ID) && defined(CONFIG_THREAD_NETWORK_ENDPOINT_ID)