Skip to content

Commit

Permalink
[EFR32] Adds fixes for IPv4/6 address resolution on RS911x and WF200 (#…
Browse files Browse the repository at this point in the history
…19770)

* EFR32 : Enable IPv6 and disable IPv4 for RS911

* Enable IPv4 and IPv6 by default

* Restyle comments

* Removes unused code and add proper preprocessor logic

* Reuse LWIP_IPV4, instead of CHIP_DEVICE_CONFIG_ENABLE_IPV4

* Removes use of CHIP_DEVICE_CONFIG_ENABLE_IPV6 as IPV6 is part of default configuration

* Imported clang-format

* * Adds proper IPV6 and IPV4 patch for RS9116.

* Adds clang-formatted code.

* Ignores log files

* Reintroduces CHIP_DEVICE_CONFIG_ENABLE_IPV4 instead of LWIP_IPV4 preprocessor

* Adds tickcount to log messages

* Adds fix for IPv6 and IPv4

* Adds updated EFR32 repo with IPV6 fix for RS911x

* Increase PBUF_POOL_SIZE to resolve out of memory errors

* Adds comment to understand the values used for BUFSIZE

* Adds updated module

* Adds CHIP_DEVICE_CONFIG_ENABLE_IPV4 flag for WF200

* Update EFR32 sdk_support

* Removes CHIP_DEVICE_CONFIG_ENABLE_IPV6 and refactors logic to support WF200_WIFI

* Increases PBUF_POOL_SIZE

* Increased pool size for lwip

* Changed RS911X_WIFI || WF200_WIFI to SL_WIFI

* Revert "Adds tickcount to log messages"

This reverts commit 47b2532.

Co-authored-by: Sharad Patil <sharad.patil@silabs.com>
Co-authored-by: Chirag Bansal <chirag.bansal@silabs.com>
Co-authored-by: Wang Qixiang <43193572+wqx6@users.noreply.github.com>
Co-authored-by: Shrinivas <shgutte@silabs.com>
  • Loading branch information
5 people authored and pull[bot] committed Aug 23, 2023
1 parent fec5456 commit c4594f6
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 65 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ compile_commands.json

# backup files, usually created by the ZAP tool
*~

# log files
*.log
2 changes: 1 addition & 1 deletion examples/platform/efr32/matter_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#ifdef SL_WIFI
#include "wfx_host_events.h"
#endif /* RS911X_WIFI */
#endif /* SL_WIFI */

#if PW_RPC_ENABLED
#include "Rpc.h"
Expand Down
4 changes: 2 additions & 2 deletions src/lwip/efr32/lwipopts-rs911x.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@
#define MEMP_SEPARATE_POOLS (1)
#define LWIP_PBUF_FROM_CUSTOM_POOLS (0)
#define MEMP_USE_CUSTOM_POOLS (0)
#define PBUF_POOL_SIZE (8)
#define PBUF_POOL_BUFSIZE (1280)
#define PBUF_POOL_SIZE (16)
#define PBUF_POOL_BUFSIZE (1280) // IPv6 path MTU
#define PBUF_CUSTOM_POOL_IDX_START (MEMP_PBUF_POOL_SMALL)
#define PBUF_CUSTOM_POOL_IDX_END (MEMP_PBUF_POOL_LARGE)
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/lwip/efr32/lwipopts-wf200.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
#define MEMP_SEPARATE_POOLS (1)
#define LWIP_PBUF_FROM_CUSTOM_POOLS (0)
#define MEMP_USE_CUSTOM_POOLS (0)
#define PBUF_POOL_SIZE (8)
#define PBUF_POOL_SIZE (16)
#define PBUF_POOL_BUFSIZE (1280)
#define PBUF_CUSTOM_POOL_IDX_START (MEMP_PBUF_POOL_SMALL)
#define PBUF_CUSTOM_POOL_IDX_END (MEMP_PBUF_POOL_LARGE)
Expand Down
10 changes: 4 additions & 6 deletions src/platform/EFR32/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,15 @@

#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0

#if defined(RS911X_WIFI)
#if defined(SL_WIFI)

#if defined(WIFI_IPV4_DISABLED)
#define CHIP_DEVICE_CONFIG_ENABLE_IPV4 0
#define CHIP_DEVICE_CONFIG_ENABLE_IPV6 1
#else
#else /* !WIFI_IPV4_DISABLED */
#define CHIP_DEVICE_CONFIG_ENABLE_IPV4 1
#define CHIP_DEVICE_CONFIG_ENABLE_IPV6 1
#endif
#endif /* WIFI_IPV4_DISABLED */

#endif
#endif /* SL_WIFI */

// ========== Platform-specific Configuration =========

Expand Down
60 changes: 6 additions & 54 deletions src/platform/EFR32/ConnectivityManagerImpl_WIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
}
}
}

ConnectivityManager::WiFiStationMode ConnectivityManagerImpl::_GetWiFiStationMode(void)
{
if (mWiFiStationMode != kWiFiStationMode_ApplicationControlled)
Expand Down Expand Up @@ -236,7 +237,7 @@ void ConnectivityManagerImpl::DriveStationState()
// Ensure that the WFX is started.
if ((serr = wfx_wifi_start()) != SL_STATUS_OK)
{
ChipLogError(DeviceLayer, "WFX_wifi_start: FAIL: %s", chip::ErrorStr(err));
ChipLogError(DeviceLayer, "wfx_wifi_start() failed: %s", chip::ErrorStr(err));
return;
}
// Ensure that station mode is enabled in the WFX WiFi layer.
Expand Down Expand Up @@ -314,7 +315,7 @@ void ConnectivityManagerImpl::DriveStationState()
ChipLogProgress(DeviceLayer, "Attempting to connect WiFi");
if ((serr = wfx_connect_to_ap()) != SL_STATUS_OK)
{
ChipLogError(DeviceLayer, "wfx_connect_to_ap failed");
ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
}
SuccessOrExit(serr);

Expand Down Expand Up @@ -368,6 +369,7 @@ void ConnectivityManagerImpl::OnStationDisconnected()

UpdateInternetConnectivityState();
}

void ConnectivityManagerImpl::DriveStationState(::chip::System::Layer * aLayer, void * aAppState)
{
sInstance.DriveStationState();
Expand All @@ -394,60 +396,10 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void)
// If the WiFi station is currently in the connected state...
if (mWiFiStationState == kWiFiStationState_Connected)
{
#if 1 //! defined (SL_WF200) || (SL_WF200 == 0)
#if CHIP_DEVICE_CONFIG_ENABLE_IPV4
haveIPv4Conn = wfx_have_ipv4_addr(SL_WFX_STA_INTERFACE);
#if (CHIP_DEVICE_CONFIG_ENABLE_IPV6)
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
haveIPv6Conn = wfx_have_ipv6_addr(SL_WFX_STA_INTERFACE);
#endif
/* TODO - haveIPv6Conn */
#else /* Old code that needed LWIP and its internals */
// Get the LwIP netif for the WiFi station interface.
struct netif * netif = Internal::WFXUtils::GetStationNetif();
// If the WiFi station interface is up...
if (netif != NULL && netif_is_up(netif) && netif_is_link_up(netif))
{
// // Check if a DNS server is currently configured. If so...
// TODO
// ip_addr_t dnsServerAddr = *dns_getserver(0);
// if (!ip_addr_isany_val(dnsServerAddr))
if (1)
{
// If the station interface has been assigned an IPv4 address, and has
// an IPv4 gateway, then presume that the device has IPv4 Internet
// connectivity.
if (!ip4_addr_isany_val(*netif_ip4_addr(netif)) && !ip4_addr_isany_val(*netif_ip4_gw(netif)))
{
haveIPv4Conn = true;
char addrStr[INET_ADDRSTRLEN];
// TODO: change the code to using IPv6 address
sprintf(addrStr, "%d.%d.%d.%d", (int) (netif->ip_addr.u_addr.ip4.addr & 0xff),
(int) ((netif->ip_addr.u_addr.ip4.addr >> 8) & 0xff),
(int) ((netif->ip_addr.u_addr.ip4.addr >> 16) & 0xff),
(int) ((netif->ip_addr.u_addr.ip4.addr >> 24) & 0xff));
IPAddress::FromString(addrStr, addr);
}
// TODO
// Search among the IPv6 addresses assigned to the interface for a Global Unicast
// address (2000::/3) that is in the valid state. If such an address is found...
// for (uint8_t i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++)
// {
// if (ip6_addr_isglobal(netif_ip6_addr(netif, i)) && ip6_addr_isvalid(netif_ip6_addr_state(netif, i)))
// {
// // Determine if there is a default IPv6 router that is currently reachable
// // via the station interface. If so, presume for now that the device has
// // IPv6 connectivity.
// struct netif * found_if = nd6_find_route(IP6_ADDR_ANY6);
// if (found_if && netif->num == found_if->num)
// {
// haveIPv6Conn = true;
// }
// }
// }
}
}
#endif /* OLD-Code */
}

// If the internet connectivity state has changed...
Expand Down
72 changes: 72 additions & 0 deletions third_party/efr32_sdk/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: None
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: true
AfterNamespace: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakStringLiterals: true
ColumnLimit: 120
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: false
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
Language: Cpp
MaxEmptyLinesToKeep: 1
PenaltyBreakAssignment: 10
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyReturnTypeOnItsOwnLine: 1000000
PointerAlignment: Right
ReflowComments: false
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: false
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 2
UseCRLF: true
UseTab: Never
2 changes: 1 addition & 1 deletion third_party/efr32_sdk/repo

0 comments on commit c4594f6

Please sign in to comment.