|
31 | 31 | #include "AppConfig.h"
|
32 | 32 | #include "FreeRTOS.h"
|
33 | 33 | #include "heap_4_silabs.h"
|
| 34 | +#include <inet/InetInterface.h> |
34 | 35 | #include <lib/support/CHIPMemString.h>
|
35 | 36 |
|
36 | 37 | using namespace ::chip::app::Clusters::GeneralDiagnostics;
|
@@ -249,13 +250,32 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
|
249 | 250 | #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
|
250 | 251 | const char * threadNetworkName = otThreadGetNetworkName(ThreadStackMgrImpl().OTInstance());
|
251 | 252 | ifp->name = Span<const char>(threadNetworkName, strlen(threadNetworkName));
|
252 |
| - ifp->isOperational = true; |
| 253 | + ifp->type = InterfaceTypeEnum::kThread; |
| 254 | + ifp->isOperational = ThreadStackMgrImpl().IsThreadAttached(); |
253 | 255 | ifp->offPremiseServicesReachableIPv4.SetNull();
|
254 | 256 | ifp->offPremiseServicesReachableIPv6.SetNull();
|
255 |
| - ifp->type = InterfaceTypeEnum::kThread; |
256 |
| - uint8_t macBuffer[ConfigurationManager::kPrimaryMACAddressLength]; |
257 |
| - ConfigurationMgr().GetPrimary802154MACAddress(macBuffer); |
258 |
| - ifp->hardwareAddress = ByteSpan(macBuffer, ConfigurationManager::kPrimaryMACAddressLength); |
| 257 | + |
| 258 | + ThreadStackMgrImpl().GetPrimary802154MACAddress(ifp->MacAddress); |
| 259 | + ifp->hardwareAddress = ByteSpan(ifp->MacAddress, kMaxHardwareAddrSize); |
| 260 | + |
| 261 | + // The Thread implementation has only 1 interface and is IPv6-only |
| 262 | + Inet::InterfaceAddressIterator interfaceAddressIterator; |
| 263 | + uint8_t ipv6AddressesCount = 0; |
| 264 | + while (interfaceAddressIterator.HasCurrent() && ipv6AddressesCount < kMaxIPv6AddrCount) |
| 265 | + { |
| 266 | + Inet::IPAddress ipv6Address; |
| 267 | + if (interfaceAddressIterator.GetAddress(ipv6Address) == CHIP_NO_ERROR) |
| 268 | + { |
| 269 | + memcpy(ifp->Ipv6AddressesBuffer[ipv6AddressesCount], ipv6Address.Addr, kMaxIPv6AddrSize); |
| 270 | + ifp->Ipv6AddressSpans[ipv6AddressesCount] = ByteSpan(ifp->Ipv6AddressesBuffer[ipv6AddressesCount]); |
| 271 | + ipv6AddressesCount++; |
| 272 | + } |
| 273 | + interfaceAddressIterator.Next(); |
| 274 | + } |
| 275 | + |
| 276 | + ifp->IPv6Addresses = app::DataModel::List<ByteSpan>(ifp->Ipv6AddressSpans, ipv6AddressesCount); |
| 277 | + |
| 278 | + *netifpp = ifp; |
259 | 279 | #else
|
260 | 280 | NetworkInterface * head = NULL;
|
261 | 281 | for (Inet::InterfaceIterator interfaceIterator; interfaceIterator.HasCurrent(); interfaceIterator.Next())
|
@@ -331,7 +351,6 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
|
331 | 351 | *netifpp = head;
|
332 | 352 | #endif
|
333 | 353 |
|
334 |
| - *netifpp = ifp; |
335 | 354 | return CHIP_NO_ERROR;
|
336 | 355 | }
|
337 | 356 |
|
|
0 commit comments