ESP32: Fix to connect to wifi using shell command (#34080)
- Fix an issue that 'matter wifi connect' doesn't work on ESP32
by calling chip::Shell::SetWiFiDriver
diff --git a/examples/platform/esp32/common/Esp32AppServer.cpp b/examples/platform/esp32/common/Esp32AppServer.cpp
index 4f854c5..1c30098 100644
--- a/examples/platform/esp32/common/Esp32AppServer.cpp
+++ b/examples/platform/esp32/common/Esp32AppServer.cpp
@@ -38,6 +38,10 @@
#endif // CONFIG_BT_ENABLED
#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
+#ifdef CONFIG_ENABLE_CHIP_SHELL
+#include <lib/shell/commands/WiFi.h>
+#endif
+
#include <string.h>
using namespace chip;
@@ -147,6 +151,9 @@
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
sWiFiNetworkCommissioningInstance.Init();
+#ifdef CONFIG_ENABLE_CHIP_SHELL
+ chip::Shell::SetWiFiDriver(&(chip::DeviceLayer::NetworkCommissioning::ESPWiFiDriver::GetInstance()));
+#endif
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
sEthernetNetworkCommissioningInstance.Init();