@@ -217,32 +217,37 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
217217 {
218218 NetworkInterface * ifp = new NetworkInterface ();
219219 esp_netif_ip_info_t ipv4_info;
220+ uint8_t addressSize = 0 ;
220221 Platform::CopyString (ifp->Name , esp_netif_get_ifkey (ifa));
221222 ifp->name = CharSpan::fromCharString (ifp->Name );
222223 ifp->isOperational = true ;
223224 ifp->type = GetInterfaceType (esp_netif_get_desc (ifa));
224225 ifp->offPremiseServicesReachableIPv4 .SetNull ();
225226 ifp->offPremiseServicesReachableIPv6 .SetNull ();
226- #if ! CHIP_DEVICE_CONFIG_ENABLE_THREAD
227- if (esp_netif_get_mac (ifa, ifp->MacAddress ) != ESP_OK )
227+ #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
228+ if (ifp->type == InterfaceTypeEnum:: kThread )
228229 {
229- ChipLogError (DeviceLayer, " Failed to get network hardware address" );
230+ static_assert (OT_EXT_ADDRESS_SIZE <= sizeof (ifp->MacAddress ), " Unexpected extended address size" );
231+ if (ThreadStackMgr ().GetPrimary802154MACAddress (ifp->MacAddress ) == CHIP_NO_ERROR)
232+ {
233+ addressSize = OT_EXT_ADDRESS_SIZE;
234+ }
230235 }
231236 else
237+ #endif
238+ if (esp_netif_get_mac (ifa, ifp->MacAddress ) == ESP_OK)
232239 {
233- ifp->hardwareAddress = ByteSpan (ifp->MacAddress , 6 );
240+ // For Wi-Fi or Ethernet interface, the MAC address size should be 6
241+ addressSize = 6 ;
234242 }
235- #else
236- if (esp_read_mac (ifp->MacAddress , ESP_MAC_IEEE802154) != ESP_OK)
243+ if (addressSize != 0 )
237244 {
238- ChipLogError (DeviceLayer, " Failed to get network hardware address " );
245+ ifp-> hardwareAddress = ByteSpan (ifp-> MacAddress , addressSize );
239246 }
240247 else
241248 {
242- ifp-> hardwareAddress = ByteSpan (ifp-> MacAddress , 8 );
249+ ChipLogError (DeviceLayer, " Failed to get network hardware address " );
243250 }
244- #endif
245-
246251#ifndef CONFIG_DISABLE_IPV4
247252 if (esp_netif_get_ip_info (ifa, &ipv4_info) == ESP_OK)
248253 {
0 commit comments