From 0d4d0413acf9a45607eb77357ae9d03b44062eda Mon Sep 17 00:00:00 2001 From: sharad-patil24 <100128124+sharad-patil24@users.noreply.github.com> Date: Fri, 3 Jun 2022 20:13:11 +0530 Subject: [PATCH] Enable IPv6 for WiFi (rs911x) (#19070) Added build flag for Enabling and disabling IPv4/IPv6 Signed-off-by: Sharad Patil --- examples/light-switch-app/efr32/BUILD.gn | 7 +++++++ examples/lighting-app/efr32/BUILD.gn | 7 +++++++ examples/lock-app/efr32/BUILD.gn | 7 +++++++ examples/window-app/efr32/BUILD.gn | 7 +++++++ scripts/examples/gn_efr32_example.sh | 4 ++++ src/platform/EFR32/CHIPDevicePlatformConfig.h | 12 ++++++++++++ src/platform/EFR32/ConnectivityManagerImpl_WIFI.cpp | 5 ++++- 7 files changed, 48 insertions(+), 1 deletion(-) diff --git a/examples/light-switch-app/efr32/BUILD.gn b/examples/light-switch-app/efr32/BUILD.gn index 0a1e68b0874082..402faaeca9a70c 100644 --- a/examples/light-switch-app/efr32/BUILD.gn +++ b/examples/light-switch-app/efr32/BUILD.gn @@ -60,6 +60,9 @@ declare_args() { # Disable LCD on supported devices disable_lcd = false + + # Argument to Disable IPv4 for wifi(rs911) + chip_disable_wifi_ipv4 = false } declare_args() { @@ -215,6 +218,10 @@ efr32_executable("light_switch_app") { sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] } + if (chip_disable_wifi_ipv4) { + defines += [ "WIFI_IPV4_DISABLED" ] + } + # WiFi Settings if (chip_enable_wifi) { if (use_rs911x) { diff --git a/examples/lighting-app/efr32/BUILD.gn b/examples/lighting-app/efr32/BUILD.gn index e82be7a6cb5a03..341582d0287321 100644 --- a/examples/lighting-app/efr32/BUILD.gn +++ b/examples/lighting-app/efr32/BUILD.gn @@ -60,6 +60,9 @@ declare_args() { # Disable LCD on supported devices disable_lcd = false + + # Argument to Disable IPv4 for wifi(rs911) + chip_disable_wifi_ipv4 = false } declare_args() { @@ -214,6 +217,10 @@ efr32_executable("lighting_app") { sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] } + if (chip_disable_wifi_ipv4) { + defines += [ "WIFI_IPV4_DISABLED" ] + } + # WiFi Settings if (chip_enable_wifi) { if (use_rs911x) { diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index b4f746235f262f..50ebd01f436152 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -60,6 +60,9 @@ declare_args() { # Disable LCD on supported devices disable_lcd = false + + # Argument to Disable IPv4 for wifi(rs911) + chip_disable_wifi_ipv4 = false } declare_args() { @@ -216,6 +219,10 @@ efr32_executable("lock_app") { sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] } + if (chip_disable_wifi_ipv4) { + defines += [ "WIFI_IPV4_DISABLED" ] + } + # WiFi Settings if (chip_enable_wifi) { if (use_rs911x) { diff --git a/examples/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn index 221838c0a14ffc..33ea182d5316a7 100644 --- a/examples/window-app/efr32/BUILD.gn +++ b/examples/window-app/efr32/BUILD.gn @@ -53,6 +53,9 @@ declare_args() { # Disable LCD on supported devices disable_lcd = false + + # Argument to Disable IPv4 for wifi(rs911) + chip_disable_wifi_ipv4 = false } declare_args() { @@ -203,6 +206,10 @@ efr32_executable("window_app") { sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] } + if (chip_disable_wifi_ipv4) { + defines += [ "WIFI_IPV4_DISABLED" ] + } + # WiFi Settings if (chip_enable_wifi) { if (use_rs911x) { diff --git a/scripts/examples/gn_efr32_example.sh b/scripts/examples/gn_efr32_example.sh index eab03e03dabac6..1c5d3567f9d097 100755 --- a/scripts/examples/gn_efr32_example.sh +++ b/scripts/examples/gn_efr32_example.sh @@ -137,6 +137,10 @@ else optArgs+="enable_sleepy_device=true chip_openthread_ftd=false " shift ;; + --chip_disable_wifi_ipv4) + optArgs+="chip_disable_wifi_ipv4=true " + shift + ;; *) if [ "$1" =~ *"use_rs911x=true"* ] || [ "$1" =~ *"use_wf200=true"* ]; then USE_WIFI=true diff --git a/src/platform/EFR32/CHIPDevicePlatformConfig.h b/src/platform/EFR32/CHIPDevicePlatformConfig.h index 42d6e6f65d7b92..38a264727588a2 100644 --- a/src/platform/EFR32/CHIPDevicePlatformConfig.h +++ b/src/platform/EFR32/CHIPDevicePlatformConfig.h @@ -48,6 +48,18 @@ #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0 +#if defined(RS911X_WIFI) + +#if defined(WIFI_IPV4_DISABLED) +#define CHIP_DEVICE_CONFIG_ENABLE_IPV4 0 +#define CHIP_DEVICE_CONFIG_ENABLE_IPV6 1 +#else +#define CHIP_DEVICE_CONFIG_ENABLE_IPV4 1 +#define CHIP_DEVICE_CONFIG_ENABLE_IPV6 1 +#endif + +#endif + // ========== Platform-specific Configuration ========= // These are configuration options that are unique to the EFR32 platform. diff --git a/src/platform/EFR32/ConnectivityManagerImpl_WIFI.cpp b/src/platform/EFR32/ConnectivityManagerImpl_WIFI.cpp index a279c808c4ccb5..5d0085d6569af5 100644 --- a/src/platform/EFR32/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/EFR32/ConnectivityManagerImpl_WIFI.cpp @@ -33,6 +33,7 @@ #include #endif +#include "CHIPDevicePlatformConfig.h" #include "wfx_host_events.h" using namespace ::chip; @@ -388,8 +389,10 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) if (mWiFiStationState == kWiFiStationState_Connected) { #if 1 //! defined (SL_WF200) || (SL_WF200 == 0) - haveIPv4Conn = wfx_have_ipv4_addr(SL_WFX_STA_INTERFACE); +#if (CHIP_DEVICE_CONFIG_ENABLE_IPV6) + 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.