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] Fix the hardware mac address isssue for thread network. #34081

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
13 changes: 13 additions & 0 deletions src/platform/ESP32/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#else
#include "esp_spi_flash.h"
#endif
#include "esp_mac.h"
#include "esp_system.h"
#include "esp_wifi.h"

Expand Down Expand Up @@ -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");
Expand All @@ -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

#ifndef CONFIG_DISABLE_IPV4
if (esp_netif_get_ip_info(ifa, &ipv4_info) == ESP_OK)
{
Expand Down
Loading