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
Changes from all 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
@@ -224,6 +224,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()
54 changes: 54 additions & 0 deletions config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
@@ -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"
@@ -1289,4 +1295,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 && ENABLE_CHIP_DATA_MODEL
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) && ENABLE_CHIP_DATA_MODEL
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 && ENABLE_CHIP_DATA_MODEL
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
@@ -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.

---

3 changes: 3 additions & 0 deletions examples/persistent-storage/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -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
18 changes: 1 addition & 17 deletions examples/platform/esp32/common/Esp32AppServer.cpp
Original file line number Diff line number Diff line change
@@ -51,19 +51,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,
@@ -150,14 +137,11 @@ void Esp32AppServer::Init(AppDelegate * sAppDelegate)
chip::Server::GetInstance().Init(initParams);

#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();
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
if (chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() &&
(chip::Server::GetInstance().GetFabricTable().FabricCount() != 0))
3 changes: 3 additions & 0 deletions examples/shell/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions src/platform/ESP32/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
@@ -50,6 +50,9 @@

#ifdef CONFIG_ENABLE_MATTER_OVER_THREAD
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_ENABLE_MATTER_OVER_THREAD
#ifndef CONFIG_THREAD_NETWORK_COMMISSIONING_DRIVER
#define _NO_NETWORK_COMMISSIONING_DRIVER_ 1
#endif
#else
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0
#endif // CONFIG_ENABLE_MATTER_OVER_THREAD
@@ -164,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
34 changes: 34 additions & 0 deletions src/platform/ESP32/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
@@ -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 && 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 && CHIP_DEVICE_CONFIG_ETHERNET_NETWORK_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,30 @@ CHIP_ERROR ConnectivityManagerImpl::_Init()
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
InitWiFi();
#if CHIP_DEVICE_CONFIG_WIFI_NETWORK_DRIVER
sWiFiNetworkCommissioningInstance.Init();
#endif // CHIP_DEVICE_CONFIG_WIFI_NETWORK_DRIVER
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
InitEthernet();
#if CHIP_DEVICE_CONFIG_ETHERNET_NETWORK_DRIVER
sEthernetNetworkCommissioningInstance.Init();
#endif // CHIP_DEVICE_CONFIG_ETHERNET_NETWORK_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;
}

Loading