Skip to content

Commit edf1118

Browse files
authoredJun 26, 2024
Fix the hardware mac address isssue for thread network (#34081)
1 parent 2829a87 commit edf1118

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎src/platform/ESP32/DiagnosticDataProviderImpl.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#else
3939
#include "esp_spi_flash.h"
4040
#endif
41+
#include "esp_mac.h"
4142
#include "esp_system.h"
4243
#include "esp_wifi.h"
4344

@@ -222,6 +223,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
222223
ifp->type = GetInterfaceType(esp_netif_get_desc(ifa));
223224
ifp->offPremiseServicesReachableIPv4.SetNull();
224225
ifp->offPremiseServicesReachableIPv6.SetNull();
226+
#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD
225227
if (esp_netif_get_mac(ifa, ifp->MacAddress) != ESP_OK)
226228
{
227229
ChipLogError(DeviceLayer, "Failed to get network hardware address");
@@ -230,6 +232,17 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
230232
{
231233
ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6);
232234
}
235+
#else
236+
if (esp_read_mac(ifp->MacAddress, ESP_MAC_IEEE802154) != ESP_OK)
237+
{
238+
ChipLogError(DeviceLayer, "Failed to get network hardware address");
239+
}
240+
else
241+
{
242+
ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 8);
243+
}
244+
#endif
245+
233246
#ifndef CONFIG_DISABLE_IPV4
234247
if (esp_netif_get_ip_info(ifa, &ipv4_info) == ESP_OK)
235248
{

0 commit comments

Comments
 (0)