From f4363a016e3001638abeeb9048ad943c4953f905 Mon Sep 17 00:00:00 2001 From: shripad621git <79364691+shripad621git@users.noreply.github.com> Date: Thu, 27 Jun 2024 16:56:27 +0530 Subject: [PATCH] Fix the hardware mac address isssue for thread network (#34081) (#34106) --- src/platform/ESP32/DiagnosticDataProviderImpl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp index ff36ca21662152..0efc5e8c74ce33 100644 --- a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp @@ -38,6 +38,7 @@ #else #include "esp_spi_flash.h" #endif +#include "esp_mac.h" #include "esp_system.h" #include "esp_wifi.h" @@ -222,6 +223,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** ifp->type = GetInterfaceType(esp_netif_get_desc(ifa)); ifp->offPremiseServicesReachableIPv4.SetNull(); ifp->offPremiseServicesReachableIPv6.SetNull(); +#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD if (esp_netif_get_mac(ifa, ifp->MacAddress) != ESP_OK) { ChipLogError(DeviceLayer, "Failed to get network hardware address"); @@ -230,6 +232,17 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** { ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6); } +#else + if (esp_read_mac(ifp->MacAddress, ESP_MAC_IEEE802154) != ESP_OK) + { + ChipLogError(DeviceLayer, "Failed to get network hardware address"); + } + else + { + ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 8); + } +#endif + #if !CONFIG_DISABLE_IPV4 if (esp_netif_get_ip_info(ifa, &ipv4_info) == ESP_OK) {