Skip to content

Commit

Permalink
[EFR32] Added functionality for scan-network, network interfaces and …
Browse files Browse the repository at this point in the history
…increased the heap size for multiadmin (#20106)

* Fixes for wifi:scan-networks,networkinterfaces,heapsize

* fixed restyle issue

* Moving the hardware address in thread case so that it doesn't modifies for wifi
  • Loading branch information
chirag-silabs authored Jun 30, 2022
1 parent c8bfba9 commit 1f20e2b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/platform/efr32/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */

#ifndef configTOTAL_HEAP_SIZE
#ifdef SL_WIFI
#define configTOTAL_HEAP_SIZE ((size_t)(28 * 1024))
#define configTOTAL_HEAP_SIZE ((size_t)(30 * 1024))
#else
#define configTOTAL_HEAP_SIZE ((size_t)(20 * 1024))
#endif
Expand Down
73 changes: 70 additions & 3 deletions src/platform/EFR32/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,79 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
ifp->offPremiseServicesReachableIPv4.SetNull();
ifp->offPremiseServicesReachableIPv6.SetNull();
ifp->type = InterfaceType::EMBER_ZCL_INTERFACE_TYPE_THREAD;
#else
/* TODO */
#endif
uint8_t macBuffer[ConfigurationManager::kPrimaryMACAddressLength];
ConfigurationMgr().GetPrimary802154MACAddress(macBuffer);
ifp->hardwareAddress = ByteSpan(macBuffer, ConfigurationManager::kPrimaryMACAddressLength);
#else
NetworkInterface * head = NULL;
for (Inet::InterfaceIterator interfaceIterator; interfaceIterator.HasCurrent(); interfaceIterator.Next())
{
interfaceIterator.GetInterfaceName(ifp->Name, Inet::InterfaceId::kMaxIfNameLength);
ifp->name = CharSpan::fromCharString(ifp->Name);
ifp->isOperational = true;
Inet::InterfaceType interfaceType;
if (interfaceIterator.GetInterfaceType(interfaceType) == CHIP_NO_ERROR)
{
switch (interfaceType)
{
case Inet::InterfaceType::Unknown:
ifp->type = EMBER_ZCL_INTERFACE_TYPE_UNSPECIFIED;
break;
case Inet::InterfaceType::WiFi:
ifp->type = EMBER_ZCL_INTERFACE_TYPE_WI_FI;
break;
case Inet::InterfaceType::Ethernet:
ifp->type = EMBER_ZCL_INTERFACE_TYPE_ETHERNET;
break;
case Inet::InterfaceType::Thread:
ifp->type = EMBER_ZCL_INTERFACE_TYPE_THREAD;
break;
case Inet::InterfaceType::Cellular:
ifp->type = EMBER_ZCL_INTERFACE_TYPE_CELLULAR;
break;
}
}
else
{
ChipLogError(DeviceLayer, "Failed to get interface type");
}

ifp->offPremiseServicesReachableIPv4.SetNull();
ifp->offPremiseServicesReachableIPv6.SetNull();

uint8_t addressSize;
if (interfaceIterator.GetHardwareAddress(ifp->MacAddress, addressSize, sizeof(ifp->MacAddress)) != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Failed to get network hardware address");
}
else
{
ifp->hardwareAddress = ByteSpan(ifp->MacAddress, addressSize);
}

// Assuming IPv6-only support
Inet::InterfaceAddressIterator interfaceAddressIterator;
uint8_t ipv6AddressesCount = 0;
while (interfaceAddressIterator.HasCurrent() && ipv6AddressesCount < kMaxIPv6AddrCount)
{
if (interfaceAddressIterator.GetInterfaceId() == interfaceIterator.GetInterfaceId())
{
chip::Inet::IPAddress ipv6Address;
if (interfaceAddressIterator.GetAddress(ipv6Address) == CHIP_NO_ERROR)
{
memcpy(ifp->Ipv6AddressesBuffer[ipv6AddressesCount], ipv6Address.Addr, kMaxIPv6AddrSize);
ifp->Ipv6AddressSpans[ipv6AddressesCount] = ByteSpan(ifp->Ipv6AddressesBuffer[ipv6AddressesCount]);
ipv6AddressesCount++;
}
}
interfaceAddressIterator.Next();
}

ifp->IPv6Addresses = chip::app::DataModel::List<chip::ByteSpan>(ifp->Ipv6AddressSpans, ipv6AddressesCount);
head = ifp;
}
*netifpp = head;
#endif

*netifpp = ifp;
return CHIP_NO_ERROR;
Expand Down
2 changes: 1 addition & 1 deletion third_party/silabs/matter_support

0 comments on commit 1f20e2b

Please sign in to comment.