diff --git a/examples/all-clusters-app/esp32/README.md b/examples/all-clusters-app/esp32/README.md index d7817027369adf..51f5b7b42ebc03 100644 --- a/examples/all-clusters-app/esp32/README.md +++ b/examples/all-clusters-app/esp32/README.md @@ -1,4 +1,3 @@ -# Matter ESP32 All Clusters Example A prototype application that demonstrates device commissioning and cluster control. diff --git a/src/platform/ESP32/ConfigurationManagerImpl.cpp b/src/platform/ESP32/ConfigurationManagerImpl.cpp index 188fb75a43e86b..d0e392723a5c8f 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.cpp +++ b/src/platform/ESP32/ConfigurationManagerImpl.cpp @@ -31,6 +31,9 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET +#include "esp_mac.h" +#endif #include "esp_ota_ops.h" #include "esp_phy_init.h" #include "esp_wifi.h" @@ -262,19 +265,30 @@ CHIP_ERROR ConfigurationManagerImpl::StoreCountryCode(const char * code, size_t return GenericConfigurationManagerImpl::StoreCountryCode(code, codeLen); } +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET +CHIP_ERROR ConfigurationManagerImpl::GetPrimaryMACAddress(MutableByteSpan buf) +{ + if (buf.size() != ConfigurationManager::kPrimaryMACAddressLength) + return CHIP_ERROR_INVALID_ARGUMENT; + + return MapConfigError(esp_read_mac(buf.data(), ESP_MAC_ETH)); +} +#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) { -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI wifi_mode_t mode; esp_wifi_get_mode(&mode); if ((mode == WIFI_MODE_AP) || (mode == WIFI_MODE_APSTA)) return MapConfigError(esp_wifi_get_mac(WIFI_IF_AP, buf)); else return MapConfigError(esp_wifi_get_mac(WIFI_IF_STA, buf)); +} #else +CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) +{ return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -#endif } +#endif CHIP_ERROR ConfigurationManagerImpl::MapConfigError(esp_err_t error) { diff --git a/src/platform/ESP32/ConfigurationManagerImpl.h b/src/platform/ESP32/ConfigurationManagerImpl.h index fce74d9307b823..5d2dacf4f3ed70 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.h +++ b/src/platform/ESP32/ConfigurationManagerImpl.h @@ -66,7 +66,11 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp // ===== Members that implement the ConfigurationManager public interface. CHIP_ERROR Init(void) override; +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override; +#else CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override; +#endif bool CanFactoryReset(void) override; void InitiateFactoryReset(void) override; CHIP_ERROR MapConfigError(esp_err_t error);