From 81864ad12401c16527adde8c6b0533425ae93166 Mon Sep 17 00:00:00 2001 From: liyashuai Date: Fri, 1 Dec 2023 19:22:25 +0800 Subject: [PATCH] update the mac address get api --- src/platform/ESP32/DiagnosticDataProviderImpl.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp index ff36ca21662152..28a5152a173d3b 100644 --- a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp @@ -38,9 +38,16 @@ #else #include "esp_spi_flash.h" #endif +#include #include "esp_system.h" #include "esp_wifi.h" +#if CONFIG_IEEE802154_ENABLED +#define MAC_ADDRESS_LEN 8 +#else +#define MAC_ADDRESS_LEN 6 +#endif + using namespace ::chip; using namespace ::chip::TLV; using namespace ::chip::DeviceLayer; @@ -222,13 +229,13 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** ifp->type = GetInterfaceType(esp_netif_get_desc(ifa)); ifp->offPremiseServicesReachableIPv4.SetNull(); ifp->offPremiseServicesReachableIPv6.SetNull(); - if (esp_netif_get_mac(ifa, ifp->MacAddress) != ESP_OK) + if (esp_efuse_mac_get_default(ifp->MacAddress) != ESP_OK) { ChipLogError(DeviceLayer, "Failed to get network hardware address"); } else { - ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6); + ifp->hardwareAddress = ByteSpan(ifp->MacAddress, MAC_ADDRESS_LEN); } #if !CONFIG_DISABLE_IPV4 if (esp_netif_get_ip_info(ifa, &ipv4_info) == ESP_OK)