Skip to content

Commit

Permalink
update the mac address get api
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry-ESP committed Dec 12, 2023
1 parent bc746ae commit 81864ad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/platform/ESP32/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@
#else
#include "esp_spi_flash.h"
#endif
#include <esp_mac.h>
#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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 81864ad

Please sign in to comment.