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 IEEE802154 MAC address in diagnostic provider(v1.3) #36709

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
27 changes: 16 additions & 11 deletions src/platform/ESP32/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,33 +217,38 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
{
NetworkInterface * ifp = new NetworkInterface();
esp_netif_ip_info_t ipv4_info;
uint8_t addressSize = 0;
Platform::CopyString(ifp->Name, esp_netif_get_ifkey(ifa));
ifp->name = CharSpan::fromCharString(ifp->Name);
ifp->isOperational = true;
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)
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
if (ifp->type == InterfaceTypeEnum::kThread)
{
ChipLogError(DeviceLayer, "Failed to get network hardware address");
static_assert(OT_EXT_ADDRESS_SIZE <= sizeof(ifp->MacAddress), "Unexpected extended address size");
if (ThreadStackMgr().GetPrimary802154MACAddress(ifp->MacAddress) == CHIP_NO_ERROR)
{
addressSize = OT_EXT_ADDRESS_SIZE;
}
}
else
#endif
if (esp_netif_get_mac(ifa, ifp->MacAddress) == ESP_OK)
{
ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6);
// For Wi-Fi or Ethernet interface, the MAC address size should be 6
addressSize = 6;
}
#else
if (esp_read_mac(ifp->MacAddress, ESP_MAC_IEEE802154) != ESP_OK)
if (addressSize != 0)
{
ChipLogError(DeviceLayer, "Failed to get network hardware address");
ifp->hardwareAddress = ByteSpan(ifp->MacAddress, addressSize);
}
else
{
ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 8);
ChipLogError(DeviceLayer, "Failed to get network hardware address");
}
#endif

#if !CONFIG_DISABLE_IPV4
#ifndef CONFIG_DISABLE_IPV4
if (esp_netif_get_ip_info(ifa, &ipv4_info) == ESP_OK)
{
memcpy(ifp->Ipv4AddressesBuffer[0], &(ipv4_info.ip.addr), kMaxIPv4AddrSize);
Expand Down
Loading