Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32: added config for Wi-Fi, Thread, and Ethernet network drivers. #34052

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/esp32/components/chip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
48 changes: 48 additions & 0 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 12 additions & 6 deletions examples/all-clusters-app/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,20 @@ 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.

---

Expand Down
19 changes: 0 additions & 19 deletions examples/platform/esp32/common/Esp32AppServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down
3 changes: 3 additions & 0 deletions src/platform/ESP32/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions src/platform/ESP32/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand All @@ -62,10 +76,30 @@ 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;
}

Expand Down
Loading