Skip to content

Commit

Permalink
Fixed the hardware macaddress isssue for thread interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
shripad621git committed Jun 24, 2024
1 parent 07ac2f1 commit 820d1a4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 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,18 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
{
ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6);
}
#else
uint8_t macAddress[8] = { 0 };
if (esp_read_mac(macAddress, ESP_MAC_IEEE802154) != ESP_OK)
{
ChipLogError(DeviceLayer, "Failed to get network hardware address");
}
else
{
ifp->hardwareAddress = ByteSpan(macAddress, 8);
}
#endif

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

0 comments on commit 820d1a4

Please sign in to comment.