@@ -217,33 +217,38 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
217
217
{
218
218
NetworkInterface * ifp = new NetworkInterface ();
219
219
esp_netif_ip_info_t ipv4_info;
220
+ uint8_t addressSize = 0 ;
220
221
Platform::CopyString (ifp->Name , esp_netif_get_ifkey (ifa));
221
222
ifp->name = CharSpan::fromCharString (ifp->Name );
222
223
ifp->isOperational = true ;
223
224
ifp->type = GetInterfaceType (esp_netif_get_desc (ifa));
224
225
ifp->offPremiseServicesReachableIPv4 .SetNull ();
225
226
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 )
228
229
{
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
+ }
230
235
}
231
236
else
237
+ #endif
238
+ if (esp_netif_get_mac (ifa, ifp->MacAddress ) == ESP_OK)
232
239
{
233
- ifp->hardwareAddress = ByteSpan (ifp->MacAddress , 6 );
240
+ // For Wi-Fi or Ethernet interface, the MAC address size should be 6
241
+ addressSize = 6 ;
234
242
}
235
- #else
236
- if (esp_read_mac (ifp->MacAddress , ESP_MAC_IEEE802154) != ESP_OK)
243
+ if (addressSize != 0 )
237
244
{
238
- ChipLogError (DeviceLayer, " Failed to get network hardware address " );
245
+ ifp-> hardwareAddress = ByteSpan (ifp-> MacAddress , addressSize );
239
246
}
240
247
else
241
248
{
242
- ifp-> hardwareAddress = ByteSpan (ifp-> MacAddress , 8 );
249
+ ChipLogError (DeviceLayer, " Failed to get network hardware address " );
243
250
}
244
- #endif
245
-
246
- #if !CONFIG_DISABLE_IPV4
251
+ #ifndef CONFIG_DISABLE_IPV4
247
252
if (esp_netif_get_ip_info (ifa, &ipv4_info) == ESP_OK)
248
253
{
249
254
memcpy (ifp->Ipv4AddressesBuffer [0 ], &(ipv4_info.ip .addr ), kMaxIPv4AddrSize );
0 commit comments