From e8a15afbe346127229eedae54691dbf2e43042b3 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous <84793247+mkardous-silabs@users.noreply.github.com> Date: Wed, 13 Nov 2024 15:26:37 -0500 Subject: [PATCH] [Silabs] Move Wi-Fi interface to src/platform from examples/platform (#36477) * Restructure platform files * Move all files to src/platform * Build the wf200 in the new wifi structure * rename directory * Build the rs9116 in the new wifi structure * Build the SiWx917 NCP in the new wifi structure * Build the SiWx917 SoC in the new wifi structure * Delete wfx_host_events header in favor of the new abstraction structure * remove unnecessary includes in gn files and the cflag changes * restyle * add todo comment * remove cflag inclusion * add missing incllude * Add missing includes * Restyled by clang-format * Move wifi_args.gni file to the wifi directory * Rename Wf200WifiInterface to WifiInterface * Rename SiWxWifiInterface to WifiInterface * Rename Rsi91xWifiInterface.cpp to WifiInterface.cpp --------- Co-authored-by: Restyled.io --- .../silabs/build_for_wifi_args.gni | 2 +- examples/chef/silabs/build_for_wifi_args.gni | 2 +- .../silabs/build_for_wifi_args.gni | 2 +- .../silabs/build_for_wifi_args.gni | 2 +- .../silabs/build_for_wifi_args.gni | 2 +- .../silabs/build_for_wifi_args.gni | 2 +- .../lock-app/silabs/build_for_wifi_args.gni | 2 +- examples/platform/silabs/BaseApplication.cpp | 3 +- examples/platform/silabs/MatterConfig.cpp | 6 +- examples/platform/silabs/SiWx917/BUILD.gn | 92 +--------- examples/platform/silabs/display/demo-ui.c | 3 +- examples/platform/silabs/efr32/BUILD.gn | 87 ---------- .../silabs/efr32/wf200/sl_wfx_configuration.h | 30 ---- .../silabs/wifi/WifiInterfaceAbstraction.h | 106 ------------ .../pump-app/silabs/build_for_wifi_args.gni | 2 +- .../silabs/build_for_wifi_args.gni | 2 +- .../silabs/build_for_wifi_args.gni | 2 +- .../thermostat/silabs/build_for_wifi_args.gni | 2 +- .../window-app/silabs/build_for_wifi_args.gni | 2 +- .../window-app/silabs/src/WindowManager.cpp | 2 +- src/platform/silabs/CHIPDevicePlatformEvent.h | 2 +- .../silabs/ConfigurationManagerImpl.cpp | 2 +- .../silabs/ConnectivityManagerImpl_WIFI.cpp | 2 +- .../silabs/NetworkCommissioningWiFiDriver.h | 2 +- src/platform/silabs/PlatformManagerImpl.cpp | 16 +- src/platform/silabs/PlatformManagerImpl.h | 9 +- src/platform/silabs/SiWx917/BUILD.gn | 34 ++-- .../silabs/SiWx917/OTAImageProcessorImpl.cpp | 2 +- .../silabs/SiWx917/SiWxPlatformInterface.h | 42 ++++- src/platform/silabs/SiWx917/wifi/wfx_msgs.h | 162 ------------------ src/platform/silabs/efr32/BUILD.gn | 32 +--- .../silabs/efr32/OTAImageProcessorImpl.cpp | 10 +- src/platform/silabs/wifi/BUILD.gn | 150 ++++++++++++++++ .../silabs/wifi/SiWx/WifiInterface.cpp | 53 +----- .../silabs/wifi/WifiInterfaceAbstraction.cpp | 18 +- ...st_events.h => WifiInterfaceAbstraction.h} | 93 +++++++++- .../silabs/{wifi_args.gni => wifi/args.gni} | 0 .../wifi/{ => lwip-support}/dhcp_client.cpp | 5 +- .../wifi/{ => lwip-support}/dhcp_client.h | 0 .../wifi => wifi/lwip-support}/ethernetif.cpp | 8 +- .../wifi => wifi/lwip-support}/ethernetif.h | 0 .../wifi => wifi/lwip-support}/lwip_netif.cpp | 14 +- .../silabs/wifi/rs911x/WifiInterface.cpp | 38 ++-- .../wifi/rs911x/platform}/efx32_ncp_host.c | 5 +- .../silabs/wifi/rs911x/platform}/efx_spi.c | 31 +--- .../platform}/rsi_board_configuration.h | 0 .../silabs/wifi/rs911x/platform}/rsi_hal.h | 0 .../rs911x/platform}/rsi_hal_mcu_interrupt.c | 0 .../rs911x/platform}/rsi_hal_mcu_ioports.c | 0 .../wifi/rs911x/platform}/rsi_hal_mcu_rtc.c | 0 .../wifi/rs911x/platform}/rsi_hal_mcu_timer.c | 0 .../rs911x/platform}/sl_board_configuration.h | 0 .../sl_board_configuration_SiWx917.h | 0 .../rs911x/platform}/sl_si91x_ncp_utility.c | 0 .../rs911x/platform}/sl_si91x_ncp_utility.h | 6 +- .../platform/silabs/wifi}/rs911x/rs9117.gni | 26 +-- .../platform/silabs/wifi}/rs911x/rs911x.gni | 24 +-- .../silabs/wifi}/rs911x/rsi_wlan_config.h | 0 .../silabs/wifi/wf200/WifiInterface.cpp | 20 ++- .../silabs/wifi/wf200/platform}/efr_spi.c | 16 +- .../wifi/wf200/platform}/sl_custom_board.h | 0 .../wifi/wf200/platform}/sl_wfx_board.h | 0 .../silabs/wifi/wf200/platform}/sl_wfx_host.h | 0 .../silabs/wifi/wf200/platform}/sl_wfx_task.c | 0 .../silabs/wifi/wf200/platform}/sl_wfx_task.h | 0 .../wifi/wf200/platform}/spi_multiplex.h | 0 .../silabs/wifi/wf200/platform}/wf200_init.c | 0 .../platform/silabs/wifi}/wf200/wf200.gni | 20 +-- .../silabs/{efr32 => }/wifi/wfx_msgs.h | 0 .../WiseconnectInterfaceAbstraction.cpp | 3 +- .../WiseconnectInterfaceAbstraction.h | 3 +- third_party/silabs/SiWx917_sdk.gni | 2 +- third_party/silabs/efr32_sdk.gni | 15 +- 73 files changed, 454 insertions(+), 764 deletions(-) delete mode 100644 examples/platform/silabs/efr32/wf200/sl_wfx_configuration.h delete mode 100644 examples/platform/silabs/wifi/WifiInterfaceAbstraction.h rename {examples => src}/platform/silabs/SiWx917/SiWxPlatformInterface.h (59%) delete mode 100644 src/platform/silabs/SiWx917/wifi/wfx_msgs.h create mode 100644 src/platform/silabs/wifi/BUILD.gn rename examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp => src/platform/silabs/wifi/SiWx/WifiInterface.cpp (94%) rename {examples => src}/platform/silabs/wifi/WifiInterfaceAbstraction.cpp (92%) rename src/platform/silabs/wifi/{wfx_host_events.h => WifiInterfaceAbstraction.h} (69%) rename src/platform/silabs/{wifi_args.gni => wifi/args.gni} (100%) rename src/platform/silabs/wifi/{ => lwip-support}/dhcp_client.cpp (98%) rename src/platform/silabs/wifi/{ => lwip-support}/dhcp_client.h (100%) rename src/platform/silabs/{efr32/wifi => wifi/lwip-support}/ethernetif.cpp (99%) rename src/platform/silabs/{efr32/wifi => wifi/lwip-support}/ethernetif.h (100%) rename src/platform/silabs/{efr32/wifi => wifi/lwip-support}/lwip_netif.cpp (94%) rename examples/platform/silabs/efr32/rs911x/Rsi91xWifiInterface.cpp => src/platform/silabs/wifi/rs911x/WifiInterface.cpp (98%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/efx32_ncp_host.c (96%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/efx_spi.c (98%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/rsi_board_configuration.h (100%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/rsi_hal.h (100%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/rsi_hal_mcu_interrupt.c (100%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/rsi_hal_mcu_ioports.c (100%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/rsi_hal_mcu_rtc.c (100%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/rsi_hal_mcu_timer.c (100%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/sl_board_configuration.h (100%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/sl_board_configuration_SiWx917.h (100%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/sl_si91x_ncp_utility.c (100%) rename {examples/platform/silabs/efr32/rs911x/hal => src/platform/silabs/wifi/rs911x/platform}/sl_si91x_ncp_utility.h (84%) rename {examples/platform/silabs/efr32 => src/platform/silabs/wifi}/rs911x/rs9117.gni (74%) rename {examples/platform/silabs/efr32 => src/platform/silabs/wifi}/rs911x/rs911x.gni (80%) rename {examples/platform/silabs/efr32 => src/platform/silabs/wifi}/rs911x/rsi_wlan_config.h (100%) rename examples/platform/silabs/efr32/wf200/Wf200WifiInterface.cpp => src/platform/silabs/wifi/wf200/WifiInterface.cpp (98%) rename {examples/platform/silabs/efr32/wf200 => src/platform/silabs/wifi/wf200/platform}/efr_spi.c (99%) rename {examples/platform/silabs/efr32 => src/platform/silabs/wifi/wf200/platform}/sl_custom_board.h (100%) rename {examples/platform/silabs/efr32/wf200 => src/platform/silabs/wifi/wf200/platform}/sl_wfx_board.h (100%) rename {examples/platform/silabs/efr32/wf200 => src/platform/silabs/wifi/wf200/platform}/sl_wfx_host.h (100%) rename {examples/platform/silabs/efr32/wf200 => src/platform/silabs/wifi/wf200/platform}/sl_wfx_task.c (100%) rename {examples/platform/silabs/efr32/wf200 => src/platform/silabs/wifi/wf200/platform}/sl_wfx_task.h (100%) rename {examples/platform/silabs/efr32 => src/platform/silabs/wifi/wf200/platform}/spi_multiplex.h (100%) rename {examples/platform/silabs/efr32/wf200 => src/platform/silabs/wifi/wf200/platform}/wf200_init.c (100%) rename {examples/platform/silabs/efr32 => src/platform/silabs/wifi}/wf200/wf200.gni (50%) rename src/platform/silabs/{efr32 => }/wifi/wfx_msgs.h (100%) rename {examples/platform/silabs/wifi => src/platform/silabs/wifi/wiseconnect-abstraction}/WiseconnectInterfaceAbstraction.cpp (99%) rename {examples/platform/silabs/wifi => src/platform/silabs/wifi/wiseconnect-abstraction}/WiseconnectInterfaceAbstraction.h (95%) diff --git a/examples/air-quality-sensor-app/silabs/build_for_wifi_args.gni b/examples/air-quality-sensor-app/silabs/build_for_wifi_args.gni index 718600a811..8b5ccad9eb 100644 --- a/examples/air-quality-sensor-app/silabs/build_for_wifi_args.gni +++ b/examples/air-quality-sensor-app/silabs/build_for_wifi_args.gni @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/config/standalone/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") chip_enable_wifi = true chip_enable_ota_requestor = true app_data_model = diff --git a/examples/chef/silabs/build_for_wifi_args.gni b/examples/chef/silabs/build_for_wifi_args.gni index 9394037ba0..97180fa504 100644 --- a/examples/chef/silabs/build_for_wifi_args.gni +++ b/examples/chef/silabs/build_for_wifi_args.gni @@ -15,6 +15,6 @@ import("//build_overrides/chip.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") chip_enable_ota_requestor = true diff --git a/examples/energy-management-app/silabs/build_for_wifi_args.gni b/examples/energy-management-app/silabs/build_for_wifi_args.gni index 1b1c0ecd6a..feeffecd6f 100644 --- a/examples/energy-management-app/silabs/build_for_wifi_args.gni +++ b/examples/energy-management-app/silabs/build_for_wifi_args.gni @@ -16,7 +16,7 @@ import("${chip_root}/config/standalone/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") sl_enable_test_event_trigger = true chip_enable_ota_requestor = false diff --git a/examples/light-switch-app/silabs/build_for_wifi_args.gni b/examples/light-switch-app/silabs/build_for_wifi_args.gni index ac70e16a8b..ed368c0248 100644 --- a/examples/light-switch-app/silabs/build_for_wifi_args.gni +++ b/examples/light-switch-app/silabs/build_for_wifi_args.gni @@ -16,7 +16,7 @@ import("${chip_root}/config/standalone/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") chip_enable_ota_requestor = true app_data_model = "${chip_root}/examples/light-switch-app/light-switch-common" diff --git a/examples/lighting-app/silabs/build_for_wifi_args.gni b/examples/lighting-app/silabs/build_for_wifi_args.gni index 7e33551c30..f8cc0089c8 100644 --- a/examples/lighting-app/silabs/build_for_wifi_args.gni +++ b/examples/lighting-app/silabs/build_for_wifi_args.gni @@ -16,7 +16,7 @@ import("${chip_root}/config/standalone/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") # Not needed for the Lighting-app chip_enable_read_client = false diff --git a/examples/lit-icd-app/silabs/build_for_wifi_args.gni b/examples/lit-icd-app/silabs/build_for_wifi_args.gni index c8048dc71e..57843c9b54 100644 --- a/examples/lit-icd-app/silabs/build_for_wifi_args.gni +++ b/examples/lit-icd-app/silabs/build_for_wifi_args.gni @@ -18,7 +18,7 @@ import("${chip_root}/config/standalone/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") chip_enable_ota_requestor = true app_data_model = "${chip_root}/examples/lit-icd-app/lit-icd-common" diff --git a/examples/lock-app/silabs/build_for_wifi_args.gni b/examples/lock-app/silabs/build_for_wifi_args.gni index cbc84b30bb..bb6da0b535 100644 --- a/examples/lock-app/silabs/build_for_wifi_args.gni +++ b/examples/lock-app/silabs/build_for_wifi_args.gni @@ -16,7 +16,7 @@ import("${chip_root}/config/standalone/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") chip_enable_ota_requestor = true app_data_model = "${chip_root}/examples/lock-app/silabs/data_model:silabs-lock" diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp index 8dc7374592..57e082e551 100644 --- a/examples/platform/silabs/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -64,10 +64,9 @@ #include #ifdef SL_WIFI -#include "WifiInterfaceAbstraction.h" -#include "wfx_host_events.h" #include #include +#include #endif // SL_WIFI #ifdef DIC_ENABLE diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index b2c0d31596..6c6429d23b 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -25,7 +25,7 @@ #include #ifdef SL_WIFI -#include "wfx_host_events.h" +#include #endif /* SL_WIFI */ #if PW_RPC_ENABLED @@ -41,8 +41,8 @@ #endif #if defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 -#include "SiWxPlatformInterface.h" -#include "WiseconnectInterfaceAbstraction.h" +#include +#include #endif // SLI_SI91X_MCU_INTERFACE #include diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 5045989389..2d6d3574ea 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -18,7 +18,7 @@ import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/examples/platform/silabs/args.gni") import("${chip_root}/src/lib/lib.gni") import("${chip_root}/src/platform/device.gni") -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") import("${chip_root}/third_party/silabs/silabs_board.gni") import("${silabs_sdk_build_root}/SiWx917_sdk.gni") @@ -28,19 +28,6 @@ declare_args() { # OTA timeout in seconds ota_periodic_query_timeout_sec = 86400 - # Wifi related stuff - they are overridden by gn -args="use_wf200=true" - sl_wfx_config_softap = false - sl_wfx_config_scan = true - - # Argument to force enable WPA3 security on rs91x - rs91x_wpa3_transition = true - - #default WiFi SSID - chip_default_wifi_ssid = "" - - #default Wifi Password - chip_default_wifi_psk = "" - # The EnableKey in hex string format used by TestEventTrigger command in # GeneralDiagnostics cluster. The length of the string should be 16 bytes. sl_test_event_trigger_enable_key = "00112233445566778899AABBCCDDEEFF" @@ -105,41 +92,6 @@ source_set("matter-shell") { ] } -config("wifi-interface-config") { - include_dirs = [ - "${silabs_plat_dir}/wifi", - "${silabs_common_plat_dir}/wifi", - ] -} - -source_set("wifi-interface") { - sources = [ - "${silabs_common_plat_dir}/wifi/WifiInterfaceAbstraction.cpp", - "${silabs_common_plat_dir}/wifi/WiseconnectInterfaceAbstraction.cpp", - "SiWxWifiInterface.cpp", - - # Wi-Fi Config - Using the file sdk support until the wiseconnect file is fixed - "${sdk_support_root}/components/service/network_manager/src/sl_net_for_lwip.c", - ] - - public_deps = [ - "${chip_root}/src/app/icd/server:icd-server-config", - "${chip_root}/src/lib/core", - "${chip_root}/src/lib/support", - "${chip_root}/src/platform:platform", - "${chip_root}/src/platform/silabs/SiWx917:SiWx917", - "${lwip_root}:lwip", - ] - - public_configs = [ - ":siwx917-common-config", - "${silabs_sdk_build_root}:silabs_config", - ":chip_examples_project_config", - ":wifi-interface-config", - ":silabs-wifi-config", - ] -} - config("siwx917-common-config") { defines = [ "OTA_PERIODIC_TIMEOUT=${ota_periodic_query_timeout_sec}" ] @@ -164,46 +116,10 @@ config("siwx917-common-config") { ldflags = [ "-Wl,--no-warn-rwx-segment" ] } -config("silabs-wifi-config") { - defines = [] - include_dirs = [] - - if (chip_default_wifi_ssid != "") { - defines += [ - "SL_ONNETWORK_PAIRING=1", - "SL_WIFI_SSID=\"${chip_default_wifi_ssid}\"", - ] - } - if (chip_default_wifi_psk != "") { - assert(chip_default_wifi_ssid != "", - "ssid can't be null if psk is provided") - defines += [ "SL_WIFI_PSK=\"${chip_default_wifi_psk}\"" ] - } - - if (sl_wfx_config_softap) { - defines += [ "SL_WFX_CONFIG_SOFTAP" ] - } - - if (sl_wfx_config_scan) { - defines += [ "SL_WFX_CONFIG_SCAN" ] - } - - if (chip_enable_wifi_ipv4) { - defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] - } - - if (rs91x_wpa3_transition) { - defines += [ "WIFI_ENABLE_SECURITY_WPA3_TRANSITION=1" ] - } -} - source_set("siwx917-common") { deps = [ "${silabs_common_plat_dir}/provision:storage" ] defines = [] - public_deps = [ - ":wifi-interface", - "${lwip_root}:lwip", - ] + public_deps = [] public_configs = [ ":siwx917-common-config", @@ -250,10 +166,6 @@ source_set("siwx917-common") { sources += [ "${silabs_common_plat_dir}/MemMonitoring.cpp" ] } - if (chip_enable_wifi) { - public_configs += [ ":silabs-wifi-config" ] - } - if (chip_build_libshell) { deps += [ ":matter-shell" ] diff --git a/examples/platform/silabs/display/demo-ui.c b/examples/platform/silabs/display/demo-ui.c index d909cb1f88..fb41a5b309 100644 --- a/examples/platform/silabs/display/demo-ui.c +++ b/examples/platform/silabs/display/demo-ui.c @@ -27,9 +27,8 @@ #include "sl_memlcd.h" #include #if SL_WIFI && !SLI_SI91X_MCU_INTERFACE -#include "spi_multiplex.h" +#include #endif // SL_WIFI && !SLI_SI91X_MCU_INTERFACE -#include #include // Main Logo and App image diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index 9e6b700cfd..e0e7b45070 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -27,19 +27,6 @@ declare_args() { # OTA timeout in seconds ota_periodic_query_timeout_sec = 86400 - # Wifi related stuff - they are overridden by gn -args="use_wf200=true" - sl_wfx_config_softap = false - sl_wfx_config_scan = true - - # Argument to force enable WPA3 security on rs91x - rs91x_wpa3_transition = true - - #default WiFi SSID - chip_default_wifi_ssid = "" - - #default Wifi Password - chip_default_wifi_psk = "" - # The EnableKey in hex string format used by TestEventTrigger command in # GeneralDiagnostics cluster. The length of the string should be 16 bytes. sl_test_event_trigger_enable_key = "00112233445566778899AABBCCDDEEFF" @@ -53,20 +40,6 @@ assert(!(use_rs9116 && chip_enable_openthread)) assert(!(use_SiWx917 && chip_enable_openthread)) assert(!(use_wf200 && chip_enable_openthread)) -if (chip_enable_wifi) { - assert(use_rs9116 || use_wf200 || use_SiWx917) - import("${chip_root}/src/platform/silabs/wifi_args.gni") - - if (use_rs9116) { - import("rs911x/rs911x.gni") - } else if (use_SiWx917) { - import("rs911x/rs9117.gni") - } - if (use_wf200) { - import("wf200/wf200.gni") - } -} - config("chip_examples_project_config") { include_dirs = [ "project_include" ] @@ -167,40 +140,6 @@ config("efr32-common-config") { ldflags = [ "-Wl,--no-warn-rwx-segment" ] } -config("silabs-wifi-config") { - defines = [] - include_dirs = [] - - if (chip_default_wifi_ssid != "") { - defines += [ - "SL_ONNETWORK_PAIRING=1", - "SL_WIFI_SSID=\"${chip_default_wifi_ssid}\"", - ] - } - if (chip_default_wifi_psk != "") { - assert(chip_default_wifi_ssid != "", - "ssid can't be null if psk is provided") - defines += [ "SL_WIFI_PSK=\"${chip_default_wifi_psk}\"" ] - } - - if (sl_wfx_config_softap) { - defines += [ "SL_WFX_CONFIG_SOFTAP" ] - } - - if (sl_wfx_config_scan) { - defines += [ "SL_WFX_CONFIG_SCAN" ] - } - - if (chip_enable_wifi_ipv4) { - defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] - } - - if (rs91x_wpa3_transition) { - # TODO: Change this macro once WF200 support is provided - defines += [ "WIFI_ENABLE_SECURITY_WPA3_TRANSITION=1" ] - } -} - source_set("efr32-common") { deps = [ "${silabs_common_plat_dir}/provision:storage" ] defines = [] @@ -265,32 +204,6 @@ source_set("efr32-common") { ] } - if (chip_enable_wifi) { - if (use_rs9116) { - sources += rs911x_src_plat - - # All the stuff from wiseconnect - sources += rs911x_src_sapi - include_dirs += rs911x_inc_plat - - #add compilation flags for rs991x build. This will be addressed directly in wiseconnect sdk in the next version release of that sdk - cflags = rs911x_cflags - } else if (use_SiWx917) { - sources += rs911x_src_plat - - # All the stuff from wiseconnect - sources += rs9117_src_sapi - include_dirs += rs9117_inc_plat - - #add compilation flags for rs991x build. This will be addressed directly in wiseconnect sdk in the next version release of that sdk - } else if (use_wf200) { - sources += wf200_plat_src - include_dirs += wf200_plat_incs - } - - public_configs += [ ":silabs-wifi-config" ] - } - if (chip_build_libshell) { deps += [ ":matter-shell" ] diff --git a/examples/platform/silabs/efr32/wf200/sl_wfx_configuration.h b/examples/platform/silabs/efr32/wf200/sl_wfx_configuration.h deleted file mode 100644 index deb468d1a6..0000000000 --- a/examples/platform/silabs/efr32/wf200/sl_wfx_configuration.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -// SL_WFX_DEFAULT_REQUEST_TIMEOUT_MS> Timeout period in milliseconds<250-10000> -// Default: 5000 -// Timeout period in milliseconds for requests. -#define SL_WFX_DEFAULT_REQUEST_TIMEOUT_MS (5000) - -// WFx Secure Link configuration - -// SL_WFX_SLK_CURVE25519> Use crypto curves -// Default: 1 -// If this option is enabled ECDH crypto is used, KDF otherwise. -#define SL_WFX_SLK_CURVE25519 (1) diff --git a/examples/platform/silabs/wifi/WifiInterfaceAbstraction.h b/examples/platform/silabs/wifi/WifiInterfaceAbstraction.h deleted file mode 100644 index 1d4b2163c7..0000000000 --- a/examples/platform/silabs/wifi/WifiInterfaceAbstraction.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include -#include -#include -#include -#include - -/* - * Interface to RSI Sapis - */ - -#define WFX_RSI_DHCP_POLL_INTERVAL (250) /* Poll interval in ms for DHCP */ -#define MAX_JOIN_RETRIES_COUNT (5) - -enum class WifiState : uint16_t -{ - kStationInit = (1 << 0), - kAPReady = (1 << 1), - kStationProvisioned = (1 << 2), - kStationConnecting = (1 << 3), - kStationConnected = (1 << 4), - kStationDhcpDone = (1 << 6), /* Requested to do DHCP after conn */ - kStationMode = (1 << 7), /* Enable Station Mode */ - kAPMode = (1 << 8), /* Enable AP Mode */ - kStationReady = (kStationConnected | kStationDhcpDone), - kStationStarted = (1 << 9), /* RSI task started */ - kScanStarted = (1 << 10), /* Scan Started */ -}; - -enum class WifiEvent : uint8_t -{ - kStationConnect = 0, - kStationDisconnect = 1, - kAPStart = 2, - kAPStop = 3, - kScan = 4, /* This is used as scan result and start */ - kStationStartJoin = 5, - kStationDoDhcp = 6, - kStationDhcpDone = 7, - kStationDhcpPoll = 8 -}; - -typedef struct wfx_rsi_s -{ - chip::BitFlags dev_state; - uint16_t ap_chan; /* The chan our STA is using */ - wfx_wifi_provision_t sec; -#ifdef SL_WFX_CONFIG_SCAN - void (*scan_cb)(wfx_wifi_scan_result_t *); - char * scan_ssid; /* Which one are we scanning for */ - size_t scan_ssid_length; -#endif -#ifdef SL_WFX_CONFIG_SOFTAP - sl_wfx_mac_address_t softap_mac; -#endif - sl_wfx_mac_address_t sta_mac; - sl_wfx_mac_address_t ap_mac; /* To which our STA is connected */ - sl_wfx_mac_address_t ap_bssid; /* To which our STA is connected */ - uint16_t join_retries; - uint8_t ip4_addr[4]; /* Not sure if this is enough */ -} WfxRsi_t; - -extern WfxRsi_t wfx_rsi; - -void sl_matter_wifi_task(void * arg); - -#if CHIP_DEVICE_CONFIG_ENABLE_IPV4 -void wfx_ip_changed_notify(int got_ip); -#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ - -int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap); -int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); -int32_t wfx_rsi_reset_count(); -int32_t sl_wifi_platform_disconnect(); - -#if CHIP_CONFIG_ENABLE_ICD_SERVER -#if SLI_SI917 -int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state); -#else -int32_t wfx_rsi_power_save(); -#endif /* SLI_SI917 */ -#endif /* SL_ICD_ENABLED */ - -/** - * @brief Posts an event to the Wi-Fi task - * - * @param[in] event Event to process. - */ -void sl_matter_wifi_post_event(WifiEvent event); diff --git a/examples/pump-app/silabs/build_for_wifi_args.gni b/examples/pump-app/silabs/build_for_wifi_args.gni index c954446921..9e6aeced58 100644 --- a/examples/pump-app/silabs/build_for_wifi_args.gni +++ b/examples/pump-app/silabs/build_for_wifi_args.gni @@ -16,7 +16,7 @@ import("${chip_root}/config/standalone/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") chip_enable_ota_requestor = true app_data_model = "${chip_root}/examples/pump-app/silabs/data_model:silabs-pump" diff --git a/examples/refrigerator-app/silabs/build_for_wifi_args.gni b/examples/refrigerator-app/silabs/build_for_wifi_args.gni index e82cf8be12..a12daf827a 100644 --- a/examples/refrigerator-app/silabs/build_for_wifi_args.gni +++ b/examples/refrigerator-app/silabs/build_for_wifi_args.gni @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/config/standalone/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") chip_enable_wifi = true chip_enable_ota_requestor = true app_data_model = "${chip_root}/examples/refrigerator-app/silabs/data_model:silabs-refrigerator" diff --git a/examples/smoke-co-alarm-app/silabs/build_for_wifi_args.gni b/examples/smoke-co-alarm-app/silabs/build_for_wifi_args.gni index e5097f8a1d..bdebe11b97 100644 --- a/examples/smoke-co-alarm-app/silabs/build_for_wifi_args.gni +++ b/examples/smoke-co-alarm-app/silabs/build_for_wifi_args.gni @@ -16,7 +16,7 @@ import("${chip_root}/config/standalone/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") chip_enable_ota_requestor = true app_data_model = diff --git a/examples/thermostat/silabs/build_for_wifi_args.gni b/examples/thermostat/silabs/build_for_wifi_args.gni index db1e280b0b..76a77c24cd 100644 --- a/examples/thermostat/silabs/build_for_wifi_args.gni +++ b/examples/thermostat/silabs/build_for_wifi_args.gni @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/config/standalone/args.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") chip_enable_wifi = true chip_enable_ota_requestor = true app_data_model = "${chip_root}/examples/thermostat/thermostat-common" diff --git a/examples/window-app/silabs/build_for_wifi_args.gni b/examples/window-app/silabs/build_for_wifi_args.gni index d6a8a54afb..6f445aeb79 100644 --- a/examples/window-app/silabs/build_for_wifi_args.gni +++ b/examples/window-app/silabs/build_for_wifi_args.gni @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") chip_enable_openthread = false -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") chip_enable_ota_requestor = true app_data_model = "${chip_root}/examples/window-app/common:window-common" diff --git a/examples/window-app/silabs/src/WindowManager.cpp b/examples/window-app/silabs/src/WindowManager.cpp index 8ae78b3d2e..62e96802c3 100644 --- a/examples/window-app/silabs/src/WindowManager.cpp +++ b/examples/window-app/silabs/src/WindowManager.cpp @@ -35,9 +35,9 @@ #include #ifdef SL_WIFI -#include "wfx_host_events.h" #include #include +#include #endif #ifdef DISPLAY_ENABLED diff --git a/src/platform/silabs/CHIPDevicePlatformEvent.h b/src/platform/silabs/CHIPDevicePlatformEvent.h index 8ab1e21b45..090ada6403 100644 --- a/src/platform/silabs/CHIPDevicePlatformEvent.h +++ b/src/platform/silabs/CHIPDevicePlatformEvent.h @@ -26,7 +26,7 @@ #include #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION -#include "wfx_host_events.h" +#include #endif namespace chip { diff --git a/src/platform/silabs/ConfigurationManagerImpl.cpp b/src/platform/silabs/ConfigurationManagerImpl.cpp index 89fc4b60ab..668b150ccc 100644 --- a/src/platform/silabs/ConfigurationManagerImpl.cpp +++ b/src/platform/silabs/ConfigurationManagerImpl.cpp @@ -30,7 +30,7 @@ #include #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION -#include "wfx_host_events.h" +#include #endif namespace chip { diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index 2dd946feb1..0d9d63317e 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -40,7 +40,7 @@ #endif #include "CHIPDevicePlatformConfig.h" -#include "wfx_host_events.h" +#include using namespace ::chip; using namespace ::chip::Inet; diff --git a/src/platform/silabs/NetworkCommissioningWiFiDriver.h b/src/platform/silabs/NetworkCommissioningWiFiDriver.h index f152edb343..12986b9987 100644 --- a/src/platform/silabs/NetworkCommissioningWiFiDriver.h +++ b/src/platform/silabs/NetworkCommissioningWiFiDriver.h @@ -18,7 +18,7 @@ #pragma once #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION #include -#include +#include namespace chip { namespace DeviceLayer { diff --git a/src/platform/silabs/PlatformManagerImpl.cpp b/src/platform/silabs/PlatformManagerImpl.cpp index cab0abf115..9ffb217103 100644 --- a/src/platform/silabs/PlatformManagerImpl.cpp +++ b/src/platform/silabs/PlatformManagerImpl.cpp @@ -134,9 +134,17 @@ void PlatformManagerImpl::_Shutdown() Internal::GenericPlatformManagerImpl_FreeRTOS::_Shutdown(); } +} // namespace DeviceLayer +} // namespace chip + #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION -void PlatformManagerImpl::HandleWFXSystemEvent(wfx_event_base_t eventBase, sl_wfx_generic_message_t * eventData) +// This function needs to be global so it can be used from the platform implementation without depending on the platfrom itself. +// This is a workaround to avoid a circular dependency. +void HandleWFXSystemEvent(wfx_event_base_t eventBase, sl_wfx_generic_message_t * eventData) { + using namespace chip; + using namespace chip::DeviceLayer; + ChipDeviceEvent event; memset(&event, 0, sizeof(event)); event.Type = DeviceEventType::kWFXSystemEvent; @@ -199,9 +207,7 @@ void PlatformManagerImpl::HandleWFXSystemEvent(wfx_event_base_t eventBase, sl_wf } } - (void) sInstance.PostEvent(&event); + // TODO: We should add error processing here + (void) PlatformMgr().PostEvent(&event); } #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/silabs/PlatformManagerImpl.h b/src/platform/silabs/PlatformManagerImpl.h index 25813afb48..dd5344d909 100644 --- a/src/platform/silabs/PlatformManagerImpl.h +++ b/src/platform/silabs/PlatformManagerImpl.h @@ -26,10 +26,14 @@ #include #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION -#include "wfx_host_events.h" +#include #endif #include +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION +void HandleWFXSystemEvent(wfx_event_base_t eventBase, sl_wfx_generic_message_t * eventData); +#endif + namespace chip { namespace DeviceLayer { @@ -62,9 +66,6 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener public: // ===== Platform-specific members that may be accessed directly by the application. -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - void HandleWFXSystemEvent(wfx_event_base_t eventBase, sl_wfx_generic_message_t * eventData); -#endif System::Clock::Timestamp GetStartTime() { return mStartTime; } diff --git a/src/platform/silabs/SiWx917/BUILD.gn b/src/platform/silabs/SiWx917/BUILD.gn index 0c2f9032e4..826d8accd9 100644 --- a/src/platform/silabs/SiWx917/BUILD.gn +++ b/src/platform/silabs/SiWx917/BUILD.gn @@ -18,7 +18,7 @@ import("${chip_root}/src/platform/device.gni") import("${chip_root}/build/chip/buildconfig_header.gni") import("${chip_root}/src/crypto/crypto.gni") -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") import("${chip_root}/third_party/silabs/silabs_board.gni") @@ -30,10 +30,14 @@ if (chip_crypto == "platform") { import("//build_overrides/mbedtls.gni") } -config("siwx917-platform-wifi-config") { - include_dirs = [ "wifi" ] - defines = [] +source_set("logging") { + sources = [ "${chip_root}/src/platform/silabs/Logging.cpp" ] + deps = [ + "${chip_root}/src/platform:platform_base", + "${chip_root}/src/platform/logging:headers", + ] } + static_library("SiWx917") { sources = [ "${silabs_platform_dir}/BLEManagerImpl.h", @@ -45,6 +49,7 @@ static_library("SiWx917") { "${silabs_platform_dir}/ConfigurationManagerImpl.cpp", "${silabs_platform_dir}/ConfigurationManagerImpl.h", "${silabs_platform_dir}/ConnectivityManagerImpl.h", + "${silabs_platform_dir}/ConnectivityManagerImpl_WIFI.cpp", "${silabs_platform_dir}/DiagnosticDataProviderImpl.cpp", "${silabs_platform_dir}/DiagnosticDataProviderImpl.h", "${silabs_platform_dir}/InetPlatformConfig.h", @@ -52,6 +57,8 @@ static_library("SiWx917") { "${silabs_platform_dir}/KeyValueStoreManagerImpl.h", "${silabs_platform_dir}/MigrationManager.cpp", "${silabs_platform_dir}/MigrationManager.h", + "${silabs_platform_dir}/NetworkCommissioningWiFiDriver.cpp", + "${silabs_platform_dir}/NetworkCommissioningWiFiDriver.h", "${silabs_platform_dir}/PlatformManagerImpl.cpp", "${silabs_platform_dir}/PlatformManagerImpl.h", "${silabs_platform_dir}/SilabsConfig.cpp", @@ -66,6 +73,7 @@ static_library("SiWx917") { "../rs911x/rsi_ble_config.h", "../rs911x/wfx_sl_ble_init.cpp", "../rs911x/wfx_sl_ble_init.h", + "SiWxPlatformInterface.h", ] if (chip_enable_ota_requestor) { @@ -94,23 +102,7 @@ static_library("SiWx917") { public_deps += [ "${chip_root}/src/crypto", "${mbedtls_root}:mbedtls", + "${silabs_platform_dir}/wifi:wifi-platform", ] } - - sources += [ - "${silabs_platform_dir}/ConnectivityManagerImpl_WIFI.cpp", - "${silabs_platform_dir}/NetworkCommissioningWiFiDriver.cpp", - "${silabs_platform_dir}/NetworkCommissioningWiFiDriver.h", - "${silabs_platform_dir}/wifi/wfx_host_events.h", - "wifi/wfx_msgs.h", - ] - public_configs = [ ":siwx917-platform-wifi-config" ] -} - -source_set("logging") { - sources = [ "${chip_root}/src/platform/silabs/Logging.cpp" ] - deps = [ - "${chip_root}/src/platform:platform_base", - "${chip_root}/src/platform/logging:headers", - ] } diff --git a/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp b/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp index c954600873..074097bac7 100644 --- a/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp +++ b/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp @@ -20,8 +20,8 @@ #include #include -#include "wfx_host_events.h" #include +#include #ifdef __cplusplus extern "C" { #endif diff --git a/examples/platform/silabs/SiWx917/SiWxPlatformInterface.h b/src/platform/silabs/SiWx917/SiWxPlatformInterface.h similarity index 59% rename from examples/platform/silabs/SiWx917/SiWxPlatformInterface.h rename to src/platform/silabs/SiWx917/SiWxPlatformInterface.h index 879ca3013c..8589db3b3f 100644 --- a/examples/platform/silabs/SiWx917/SiWxPlatformInterface.h +++ b/src/platform/silabs/SiWx917/SiWxPlatformInterface.h @@ -27,13 +27,29 @@ extern "C" { #include "sl_si91x_button.h" #include "sl_si91x_button_pin_config.h" #include "sl_si91x_driver_gpio.h" + /** * @brief invoked when button press event is received when in sleep * @param[in] pin_intr GPIO pin interrupt number. * @return none. * @note this is a callback from the Wiseconnect SDK */ -void gpio_uulp_pin_interrupt_callback(uint32_t pin_intr); +void gpio_uulp_pin_interrupt_callback(uint32_t pin_intr) +{ + // UULP_GPIO_2 is used to detect the button 0 press + VerifyOrReturn(pin_intr == RTE_UULP_GPIO_2_PIN, ChipLogError(DeviceLayer, "invalid pin interrupt: %ld", pin_intr)); + sl_status_t status = SL_STATUS_OK; + uint8_t pin_intr_status = sl_si91x_gpio_get_uulp_npss_pin(pin_intr); + if (pin_intr_status == LOW) + { + // BTN_0 is pressed + // NOTE: the GPIO is masked since the interrupt is invoked before scheduler is started, thus this is required to hand over + // control to scheduler, the PIN is unmasked in the power manager flow before going to sleep + status = sl_si91x_gpio_driver_mask_uulp_npss_interrupt(BIT(pin_intr)); + VerifyOrReturn(status == SL_STATUS_OK, ChipLogError(DeviceLayer, "failed to mask interrupt: %ld", status)); + } +} + #endif // SLI_SI91X_MCU_INTERFACE #endif // CHIP_CONFIG_ENABLE_ICD_SERVER #ifdef __cplusplus @@ -64,7 +80,29 @@ inline void sl_si91x_btn_event_handler() * @param[in] none. * @note this requires hardware jumping of the GPIO PINs to work with the baseboard. */ -void sl_si91x_uart_power_requirement_handler(); +void sl_si91x_uart_power_requirement_handler() +{ +#ifdef ENABLE_CHIP_SHELL + // Checking the UULP PIN 1 status to reinit the UART and not allow the device to go to sleep + if (sl_si91x_gpio_get_uulp_npss_pin(RTE_UULP_GPIO_1_PIN)) + { + if (!ps_requirement_added) + { + sl_si91x_power_manager_add_ps_requirement(SL_SI91X_POWER_MANAGER_PS4); + ps_requirement_added = true; + } + } + else + { + if (ps_requirement_added) + { + sl_si91x_power_manager_remove_ps_requirement(SL_SI91X_POWER_MANAGER_PS4); + ps_requirement_added = false; + } + } +#endif // ENABLE_CHIP_SHELL +} + #endif // SLI_SI91X_MCU_INTERFACE #endif // CHIP_CONFIG_ENABLE_ICD_SERVER } // namespace SiWxPlatformInterface diff --git a/src/platform/silabs/SiWx917/wifi/wfx_msgs.h b/src/platform/silabs/SiWx917/wifi/wfx_msgs.h deleted file mode 100644 index b87a7c0707..0000000000 --- a/src/platform/silabs/SiWx917/wifi/wfx_msgs.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _WFX_MSGS_H_ -#define _WFX_MSGS_H_ - -#include -/* - * Taken from sl_wfx firmware - so I can re-use. - * I need to do a better job than to use this stuff - * in the CPP files of Matter - */ -typedef struct -{ - uint8_t octet[6]; ///< Table to store a MAC address -} sl_wfx_mac_address_t; -/** - * @brief General Message header structure - * - */ -typedef struct __attribute__((__packed__)) sl_wfx_header_s -{ - uint16_t length; ///< Message length in bytes including this uint16_t. - ///< Maximum value is 8188 but maximum Request size is FW dependent and reported in the - ///< ::sl_wfx_startup_ind_body_t::size_inp_ch_buf. - uint8_t id; ///< Contains the message Id indexed by sl_wfx_general_commands_ids_t or sl_wfx_message_ids_t. - uint8_t info; ///< TODO comment missing -} sl_wfx_header_t; - -/** - * @brief Generic message structure for all requests, confirmations and indications - * - */ -typedef struct __attribute__((__packed__)) sl_wfx_generic_message_s -{ - sl_wfx_header_t header; ///< 4 bytes header - uint8_t body[]; ///< variable size payload of the message -} sl_wfx_generic_message_t; -#define SL_WFX_OPN_SIZE 14 -#define SL_WFX_UID_SIZE 8 -#define SL_WFX_DISABLED_CHANNEL_LIST_SIZE 2 -#define SL_WFX_FIRMWARE_LABEL_SIZE 128 -/** - * @brief Startup Indication message. - * This is the first message sent to the host to confirm boot success. - * It gives detailed information on the HW and FW versions and capabilities - */ -typedef struct __attribute__((__packed__)) sl_wfx_startup_ind_body_s -{ - uint32_t - status; ///< Initialization status. A value of zero indicates the boot is completed successfully (see enum sl_wfx_status_t) - uint16_t hardware_id; ///<=RO misc_read_reg7 register value - uint8_t mac_addr[6]; -} sl_wfx_startup_ind_body_t; - -typedef struct __attribute__((__packed__)) sl_wfx_startup_ind_s -{ - sl_wfx_header_t header; - sl_wfx_startup_ind_body_t body; -} sl_wfx_startup_ind_t; -/** - * @brief Indication message body for sl_wfx_connect_ind_t. - */ -typedef struct __attribute__((__packed__)) sl_wfx_connect_ind_body_s -{ - /** - * @brief Status of the connection request. - * @details WFM_STATUS_SUCCESS: the connection request was completed successfully. - *
any other value: the connection request failed. - *
See sl_wfx_fmac_status_t for enumeration values. - */ - uint32_t status; - /** - * @brief MAC address of the connected access point. - */ - uint8_t mac[6]; - /** - * @brief Channel of the connected access point. - * @details 1 - 13: Channel number. - */ - uint16_t channel; - /** - * @brief Beacon Interval of the connected access point. - */ - uint8_t beacon_interval; - /** - * @brief DTIM period of the connected access point. - * @details 1 - 255: DTIM period. - */ - uint8_t dtim_period; - /** - * @brief Maximum PHY data rate supported by the connection. - * @details See sl_wfx_rate_index_t for enumeration values. - */ - uint16_t max_phy_rate; -} sl_wfx_connect_ind_body_t; - -/** - * @brief Indication message used to signal the completion of a connection operation. - * @details The device will send this indication to signal the connection request initiated - * with sl_wfx_connect_req_t has been completed. The indication is also sent when - * the device autonomously roams to another access point. - * @ingroup WFM_GROUP_MODE_IDLE - */ -typedef struct __attribute__((__packed__)) sl_wfx_connect_ind_s -{ - /** Common message header. */ - sl_wfx_header_t header; - /** Indication message body. */ - sl_wfx_connect_ind_body_t body; -} sl_wfx_connect_ind_t; -/** - * @brief Indication message body for sl_wfx_disconnect_ind_t. - */ -typedef struct __attribute__((__packed__)) sl_wfx_disconnect_ind_body_s -{ - /** - * @brief MAC address of the access point. - */ - uint8_t mac[6]; - /** - * @brief Reason for disconnection. - * @details WFM_DISCONNECTED_REASON_UNSPECIFIED: The device disconnected because of an internal error. - *
WFM_DISCONNECTED_REASON_AP_LOST: The device lost the AP beacons for too long. - *
WFM_DISCONNECTED_REASON_REJECTED: The device was disconnected by the AP. - *
WFM_DISCONNECTED_REASON_LEAVING_BSS: Disconnection was requested through the device API. - *
WFM_DISCONNECTED_REASON_WPA_COUNTERMEASURES: WPA countermeasures triggered a disconnection - *
See sl_wfx_disconnected_reason_t for enumeration values. - */ - uint16_t reason; -} sl_wfx_disconnect_ind_body_t; - -/** - * @brief Indication message used to signal the completion of a disconnection operation. - * @details The device will send this indication to signal the disconnection request initiated - * with sl_wfx_disconnect_req_t has been completed. The indication is also sent when - * the device has lost the connection to an access point and has been unable to regain it. - * @ingroup WFM_GROUP_MODE_STA - */ -typedef struct __attribute__((__packed__)) sl_wfx_disconnect_ind_s -{ - /** Common message header. */ - sl_wfx_header_t header; - /** Indication message body. */ - sl_wfx_disconnect_ind_body_t body; -} sl_wfx_disconnect_ind_t; - -#endif /* _WFX_MSGS_H_ */ diff --git a/src/platform/silabs/efr32/BUILD.gn b/src/platform/silabs/efr32/BUILD.gn index b1e50faafc..f39628d484 100644 --- a/src/platform/silabs/efr32/BUILD.gn +++ b/src/platform/silabs/efr32/BUILD.gn @@ -20,8 +20,6 @@ import("${chip_root}/src/platform/device.gni") import("${chip_root}/third_party/silabs/efr32_sdk.gni") import("${chip_root}/third_party/silabs/silabs_board.gni") -silabs_platform_dir = "${chip_root}/src/platform/silabs" - assert(chip_device_platform == "efr32") if (chip_enable_openthread) { @@ -32,9 +30,12 @@ if (chip_crypto == "platform") { import("//build_overrides/mbedtls.gni") } -config("efr32-platform-wifi-config") { - include_dirs = [ "wifi" ] - defines = [] +source_set("logging") { + sources = [ "${chip_root}/src/platform/silabs/Logging.cpp" ] + deps = [ + "${chip_root}/src/platform:platform_base", + "${chip_root}/src/platform/logging:headers", + ] } static_library("efr32") { @@ -159,27 +160,8 @@ static_library("efr32") { "${silabs_platform_dir}/ConnectivityManagerImpl_WIFI.cpp", "${silabs_platform_dir}/NetworkCommissioningWiFiDriver.cpp", "${silabs_platform_dir}/NetworkCommissioningWiFiDriver.h", - "${silabs_platform_dir}/wifi/wfx_host_events.h", - "wifi/wfx_msgs.h", ] - if (use_wf200 || use_rs9116) { - sources += [ - "${silabs_platform_dir}/wifi/dhcp_client.cpp", - "wifi/ethernetif.cpp", - "wifi/ethernetif.h", - "wifi/lwip_netif.cpp", - ] - } - - public_configs += [ ":efr32-platform-wifi-config" ] + public_deps += [ "${silabs_platform_dir}/wifi:wifi-platform" ] } } - -source_set("logging") { - sources = [ "${chip_root}/src/platform/silabs/Logging.cpp" ] - deps = [ - "${chip_root}/src/platform:platform_base", - "${chip_root}/src/platform/logging:headers", - ] -} diff --git a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp index 11921d86f3..a0efd10100 100644 --- a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp +++ b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp @@ -19,17 +19,17 @@ #include #include #include +#include + +#if SL_WIFI +#include +#endif // SL_WIFI extern "C" { #include "btl_interface.h" #include "sl_core.h" -#if SL_WIFI -#include "spi_multiplex.h" -#endif // SL_WIFI } -#include - #ifdef _SILICON_LABS_32B_SERIES_2 // Series 2 bootloader_ api calls must be called from a critical section context for thread safeness #define WRAP_BL_DFU_CALL(code) \ diff --git a/src/platform/silabs/wifi/BUILD.gn b/src/platform/silabs/wifi/BUILD.gn new file mode 100644 index 0000000000..882a66deb4 --- /dev/null +++ b/src/platform/silabs/wifi/BUILD.gn @@ -0,0 +1,150 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") +import("//build_overrides/lwip.gni") +import("${chip_root}/src/platform/device.gni") +import("${chip_root}/third_party/silabs/efr32_sdk.gni") +import("${chip_root}/third_party/silabs/silabs_board.gni") + +declare_args() { + # Wifi related stuff - they are overridden by gn -args="use_wf200=true" + sl_wfx_config_softap = false + sl_wfx_config_scan = true + + # Argument to force enable WPA3 security on rs91x + rs91x_wpa3_transition = true + + #default WiFi SSID + chip_default_wifi_ssid = "" + + #default Wifi Password + chip_default_wifi_psk = "" +} + +if (chip_enable_wifi && !wifi_soc) { + assert(use_rs9116 || use_wf200 || use_SiWx917) + import("${chip_root}/src/platform/silabs/wifi/args.gni") + + if (use_rs9116) { + import("${silabs_platform_dir}/wifi/rs911x/rs911x.gni") + } else if (use_SiWx917) { + import("${silabs_platform_dir}/wifi/rs911x/rs9117.gni") + } + if (use_wf200) { + import("${silabs_platform_dir}/wifi/wf200/wf200.gni") + } +} + +config("wifi-platform-config") { + defines = [] + include_dirs = [] + + if (use_rs9116) { + # All the stuff from wiseconnect + include_dirs += rs911x_inc_plat + } else if (use_SiWx917) { + # All the stuff from wiseconnect + include_dirs += rs9117_inc_plat + } + + if (chip_default_wifi_ssid != "") { + defines += [ + "SL_ONNETWORK_PAIRING=1", + "SL_WIFI_SSID=\"${chip_default_wifi_ssid}\"", + ] + } + if (chip_default_wifi_psk != "") { + assert(chip_default_wifi_ssid != "", + "ssid can't be null if psk is provided") + defines += [ "SL_WIFI_PSK=\"${chip_default_wifi_psk}\"" ] + } + + if (sl_wfx_config_softap) { + defines += [ "SL_WFX_CONFIG_SOFTAP" ] + } + + if (sl_wfx_config_scan) { + defines += [ "SL_WFX_CONFIG_SCAN" ] + } + + if (chip_enable_wifi_ipv4) { + defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] + } + + if (rs91x_wpa3_transition) { + # TODO: Change this macro once WF200 support is provided + defines += [ "WIFI_ENABLE_SECURITY_WPA3_TRANSITION=1" ] + } + + # TODO: This defines needs to be here for the spi_multiplex.h configuration header. + # We need to find a better way to handle this. + if (!disable_lcd) { + defines += [ "DISPLAY_ENABLED" ] + } +} + +source_set("wifi-platform") { + sources = [ + "${silabs_platform_dir}/wifi/WifiInterfaceAbstraction.cpp", + "${silabs_platform_dir}/wifi/WifiInterfaceAbstraction.h", + "${silabs_platform_dir}/wifi/wfx_msgs.h", + ] + + public_configs = [ ":wifi-platform-config" ] + + public_deps = [ + "${chip_root}/src/app/icd/server:icd-server-config", + "${chip_root}/src/inet", + "${chip_root}/src/lib/support", + ] + + if (use_rs9116) { + sources += rs911x_src_plat + + # All the stuff from wiseconnect + sources += rs911x_src_sapi + } else if (use_SiWx917) { + sources += rs911x_src_plat + + # All the stuff from wiseconnect + sources += rs9117_src_sapi + + #add compilation flags for rs991x build. This will be addressed directly in wiseconnect sdk in the next version release of that sdk + } else if (use_wf200) { + sources += wf200_plat_src + } + + if (wifi_soc) { + sources += [ + "${silabs_platform_dir}/wifi/SiWx/WifiInterface.cpp", + "${silabs_platform_dir}/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.cpp", + "${silabs_platform_dir}/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.h", + + # Wi-Fi Config - Using the file sdk support until the wiseconnect file is fixed + "${sdk_support_root}/components/service/network_manager/src/sl_net_for_lwip.c", + ] + + public_deps += [ "${lwip_root}:lwip" ] + } + + if (use_wf200 || use_rs9116) { + sources += [ + "${silabs_platform_dir}/wifi/lwip-support/dhcp_client.cpp", + "${silabs_platform_dir}/wifi/lwip-support/ethernetif.cpp", + "${silabs_platform_dir}/wifi/lwip-support/ethernetif.h", + "${silabs_platform_dir}/wifi/lwip-support/lwip_netif.cpp", + ] + } +} diff --git a/examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp b/src/platform/silabs/wifi/SiWx/WifiInterface.cpp similarity index 94% rename from examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp rename to src/platform/silabs/wifi/SiWx/WifiInterface.cpp index 1521519efe..aa25647395 100644 --- a/examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp +++ b/src/platform/silabs/wifi/SiWx/WifiInterface.cpp @@ -28,22 +28,19 @@ #endif // SL_MATTER_GN_BUILD #include "FreeRTOS.h" -#include "WifiInterfaceAbstraction.h" -#include "WiseconnectInterfaceAbstraction.h" #include "ble_config.h" -#include "dhcp_client.h" #include "event_groups.h" -#include "sl_board_configuration.h" #include "sl_status.h" #include "sl_wifi_device.h" #include "task.h" -#include "wfx_host_events.h" #include #include #include #include #include #include +#include +#include extern "C" { #include "sl_si91x_driver.h" @@ -70,11 +67,10 @@ extern "C" { #if (EXP_BOARD) #include "rsi_bt_common_apis.h" +#include #endif #if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE -#include "SiWxPlatformInterface.h" - #include "rsi_rom_power_save.h" #include "sl_gpio_board.h" #include "sl_si91x_driver_gpio.h" @@ -549,48 +545,6 @@ int32_t sl_wifi_platform_disconnect(void) return sl_net_down((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE); } -#if CHIP_CONFIG_ENABLE_ICD_SERVER -#if SLI_SI91X_MCU_INTERFACE -void gpio_uulp_pin_interrupt_callback(uint32_t pin_intr) -{ - // UULP_GPIO_2 is used to detect the button 0 press - VerifyOrReturn(pin_intr == RTE_UULP_GPIO_2_PIN, ChipLogError(DeviceLayer, "invalid pin interrupt: %ld", pin_intr)); - sl_status_t status = SL_STATUS_OK; - uint8_t pin_intr_status = sl_si91x_gpio_get_uulp_npss_pin(pin_intr); - if (pin_intr_status == LOW) - { - // BTN_0 is pressed - // NOTE: the GPIO is masked since the interrupt is invoked before scheduler is started, thus this is required to hand over - // control to scheduler, the PIN is unmasked in the power manager flow before going to sleep - status = sl_si91x_gpio_driver_mask_uulp_npss_interrupt(BIT(pin_intr)); - VerifyOrReturn(status == SL_STATUS_OK, ChipLogError(DeviceLayer, "failed to mask interrupt: %ld", status)); - } -} - -void chip::DeviceLayer::Silabs::SiWxPlatformInterface::sl_si91x_uart_power_requirement_handler(void) -{ -#ifdef ENABLE_CHIP_SHELL - // Checking the UULP PIN 1 status to reinit the UART and not allow the device to go to sleep - if (sl_si91x_gpio_get_uulp_npss_pin(RTE_UULP_GPIO_1_PIN)) - { - if (!ps_requirement_added) - { - sl_si91x_power_manager_add_ps_requirement(SL_SI91X_POWER_MANAGER_PS4); - ps_requirement_added = true; - } - } - else - { - if (ps_requirement_added) - { - sl_si91x_power_manager_remove_ps_requirement(SL_SI91X_POWER_MANAGER_PS4); - ps_requirement_added = false; - } - } -#endif // ENABLE_CHIP_SHELL -} -#endif // SLI_SI91X_MCU_INTERFACE - /****************************************************************** * @fn wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state) * @brief @@ -621,7 +575,6 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_ return status; } -#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result) { diff --git a/examples/platform/silabs/wifi/WifiInterfaceAbstraction.cpp b/src/platform/silabs/wifi/WifiInterfaceAbstraction.cpp similarity index 92% rename from examples/platform/silabs/wifi/WifiInterfaceAbstraction.cpp rename to src/platform/silabs/wifi/WifiInterfaceAbstraction.cpp index 0994416cd2..99d699d8f0 100644 --- a/examples/platform/silabs/wifi/WifiInterfaceAbstraction.cpp +++ b/src/platform/silabs/wifi/WifiInterfaceAbstraction.cpp @@ -17,14 +17,12 @@ // SL MATTER WI-FI INTERFACE -#include "WifiInterfaceAbstraction.h" #include "silabs_utils.h" -#include "wfx_host_events.h" #include #include #include #include -#include +#include #include #include #include @@ -35,6 +33,10 @@ using namespace chip::DeviceLayer; #define CONVERT_SEC_TO_MS(TimeInS) (TimeInS * 1000) +// TODO: This is a workaround because we depend on the platform lib which depends on the platform implementation. +// As such we can't depend on the platform here as well +extern void HandleWFXSystemEvent(wfx_event_base_t eventBase, sl_wfx_generic_message_t * eventData); + namespace { constexpr uint8_t kWlanMinRetryIntervalsInSec = 1; @@ -83,7 +85,7 @@ void sl_matter_wifi_task_started(void) wfx_get_wifi_mac_addr(SL_WFX_STA_INTERFACE, &mac); memcpy(&evt.body.mac_addr[0], &mac.octet[0], MAC_ADDRESS_FIRST_OCTET); - PlatformMgrImpl().HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt); + HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt); } /*********************************************************************************** @@ -110,7 +112,7 @@ void wfx_connected_notify(int32_t status, sl_wfx_mac_address_t * ap) #endif memcpy(&evt.body.mac[0], &ap->octet[0], MAC_ADDRESS_FIRST_OCTET); - PlatformMgrImpl().HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt); + HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt); } /************************************************************************************** @@ -128,7 +130,7 @@ void wfx_disconnected_notify(int32_t status) evt.header.id = SL_WFX_DISCONNECT_IND_ID; evt.header.length = sizeof evt; evt.body.reason = status; - PlatformMgrImpl().HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt); + HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt); } /************************************************************************************** @@ -145,7 +147,7 @@ void wfx_ipv6_notify(int got_ip) memset(&eventData, 0, sizeof(eventData)); eventData.header.id = got_ip ? IP_EVENT_GOT_IP6 : IP_EVENT_STA_LOST_IP; eventData.header.length = sizeof(eventData.header); - PlatformMgrImpl().HandleWFXSystemEvent(IP_EVENT, &eventData); + HandleWFXSystemEvent(IP_EVENT, &eventData); } /************************************************************************************** @@ -162,7 +164,7 @@ void wfx_ip_changed_notify(int got_ip) memset(&eventData, 0, sizeof(eventData)); eventData.header.id = got_ip ? IP_EVENT_STA_GOT_IP : IP_EVENT_STA_LOST_IP; eventData.header.length = sizeof(eventData.header); - PlatformMgrImpl().HandleWFXSystemEvent(IP_EVENT, &eventData); + HandleWFXSystemEvent(IP_EVENT, &eventData); } /************************************************************************************** diff --git a/src/platform/silabs/wifi/wfx_host_events.h b/src/platform/silabs/wifi/WifiInterfaceAbstraction.h similarity index 69% rename from src/platform/silabs/wifi/wfx_host_events.h rename to src/platform/silabs/wifi/WifiInterfaceAbstraction.h index 38808610ee..f6364d040e 100644 --- a/src/platform/silabs/wifi/wfx_host_events.h +++ b/src/platform/silabs/wifi/WifiInterfaceAbstraction.h @@ -14,9 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #pragma once +#include +#include +#include +#include +#include + #include "sl_status.h" #include @@ -26,14 +31,18 @@ #include "lwip/netifapi.h" #include "lwip/tcpip.h" -#include "wfx_msgs.h" - #if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) #include "rsi_common_apis.h" #include "sl_si91x_types.h" #include "sl_wifi_constants.h" #include "sl_wifi_device.h" +/* + * Interface to RSI Sapis + */ + +#define WFX_RSI_DHCP_POLL_INTERVAL (250) /* Poll interval in ms for DHCP */ + // MAX SSID LENGTH excluding NULL character #define WFX_MAX_SSID_LENGTH (32) // MAX PASSKEY LENGTH including NULL character @@ -46,6 +55,7 @@ #define WFX_MAX_PASSKEY_LENGTH (64) #endif // (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) +#define MAX_JOIN_RETRIES_COUNT (5) #define BSSID_LEN (6) #define MAC_ADDRESS_FIRST_OCTET (6) #define CONNECTION_STATUS_SUCCESS (1) @@ -61,6 +71,34 @@ // TASK and Interrupt Macros #define SUCCESS_STATUS (1) +enum class WifiState : uint16_t +{ + kStationInit = (1 << 0), + kAPReady = (1 << 1), + kStationProvisioned = (1 << 2), + kStationConnecting = (1 << 3), + kStationConnected = (1 << 4), + kStationDhcpDone = (1 << 6), /* Requested to do DHCP after conn */ + kStationMode = (1 << 7), /* Enable Station Mode */ + kAPMode = (1 << 8), /* Enable AP Mode */ + kStationReady = (kStationConnected | kStationDhcpDone), + kStationStarted = (1 << 9), /* RSI task started */ + kScanStarted = (1 << 10), /* Scan Started */ +}; + +enum class WifiEvent : uint8_t +{ + kStationConnect = 0, + kStationDisconnect = 1, + kAPStart = 2, + kAPStop = 3, + kScan = 4, /* This is used as scan result and start */ + kStationStartJoin = 5, + kStationDoDhcp = 6, + kStationDhcpDone = 7, + kStationDhcpPoll = 8 +}; + typedef enum { WIFI_EVENT, @@ -137,6 +175,29 @@ typedef enum } sl_wfx_interface_t; #endif +typedef struct wfx_rsi_s +{ + chip::BitFlags dev_state; + uint16_t ap_chan; /* The chan our STA is using */ + wfx_wifi_provision_t sec; +#ifdef SL_WFX_CONFIG_SCAN + void (*scan_cb)(wfx_wifi_scan_result_t *); + char * scan_ssid; /* Which one are we scanning for */ + size_t scan_ssid_length; +#endif +#ifdef SL_WFX_CONFIG_SOFTAP + sl_wfx_mac_address_t softap_mac; +#endif + sl_wfx_mac_address_t sta_mac; + sl_wfx_mac_address_t ap_mac; /* To which our STA is connected */ + sl_wfx_mac_address_t ap_bssid; /* To which our STA is connected */ + uint16_t join_retries; + uint8_t ip4_addr[4]; /* Not sure if this is enough */ +} WfxRsi_t; + +// TODO: We shouldn't need to have access to a global variable in the interface here +extern WfxRsi_t wfx_rsi; + sl_status_t wfx_wifi_start(void); void wfx_enable_sta_mode(void); void wfx_get_wifi_mac_addr(sl_wfx_interface_t interface, sl_wfx_mac_address_t * addr); @@ -203,6 +264,32 @@ sl_status_t wfx_power_save(); #endif /* SL_ICD_ENABLED */ #endif /* RS911X_WIFI */ +void sl_matter_wifi_task(void * arg); + +#if CHIP_DEVICE_CONFIG_ENABLE_IPV4 +void wfx_ip_changed_notify(int got_ip); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ + +int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap); +int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); +int32_t wfx_rsi_reset_count(); +int32_t sl_wifi_platform_disconnect(); + +#if CHIP_CONFIG_ENABLE_ICD_SERVER +#if SLI_SI917 +int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state); +#else +int32_t wfx_rsi_power_save(); +#endif /* SLI_SI917 */ +#endif /* SL_ICD_ENABLED */ + +/** + * @brief Posts an event to the Wi-Fi task + * + * @param[in] event Event to process. + */ +void sl_matter_wifi_post_event(WifiEvent event); + #ifdef __cplusplus extern "C" { #endif diff --git a/src/platform/silabs/wifi_args.gni b/src/platform/silabs/wifi/args.gni similarity index 100% rename from src/platform/silabs/wifi_args.gni rename to src/platform/silabs/wifi/args.gni diff --git a/src/platform/silabs/wifi/dhcp_client.cpp b/src/platform/silabs/wifi/lwip-support/dhcp_client.cpp similarity index 98% rename from src/platform/silabs/wifi/dhcp_client.cpp rename to src/platform/silabs/wifi/lwip-support/dhcp_client.cpp index a219430762..a16064eb1d 100644 --- a/src/platform/silabs/wifi/dhcp_client.cpp +++ b/src/platform/silabs/wifi/lwip-support/dhcp_client.cpp @@ -23,10 +23,7 @@ #include "dhcp_client.h" #include "lwip/dhcp.h" -#include "wfx_host_events.h" - -#include "FreeRTOS.h" -#include "event_groups.h" +#include #include diff --git a/src/platform/silabs/wifi/dhcp_client.h b/src/platform/silabs/wifi/lwip-support/dhcp_client.h similarity index 100% rename from src/platform/silabs/wifi/dhcp_client.h rename to src/platform/silabs/wifi/lwip-support/dhcp_client.h diff --git a/src/platform/silabs/efr32/wifi/ethernetif.cpp b/src/platform/silabs/wifi/lwip-support/ethernetif.cpp similarity index 99% rename from src/platform/silabs/efr32/wifi/ethernetif.cpp rename to src/platform/silabs/wifi/lwip-support/ethernetif.cpp index d6123d2ead..7e880f62e9 100644 --- a/src/platform/silabs/efr32/wifi/ethernetif.cpp +++ b/src/platform/silabs/wifi/lwip-support/ethernetif.cpp @@ -21,12 +21,6 @@ #include #include -#include "em_bus.h" -#include "em_cmu.h" -#include "em_gpio.h" -#include "em_ldma.h" -#include "em_usart.h" - #ifndef WF200_WIFI #include "FreeRTOS.h" #include "event_groups.h" @@ -50,7 +44,7 @@ extern "C" { #endif // (SLI_SI91X_MCU_INTERFACE | EXP_BOARD) #endif // WF200_WIFI -#include "wfx_host_events.h" +#include #ifdef WF200_WIFI #include "sl_wfx.h" #endif diff --git a/src/platform/silabs/efr32/wifi/ethernetif.h b/src/platform/silabs/wifi/lwip-support/ethernetif.h similarity index 100% rename from src/platform/silabs/efr32/wifi/ethernetif.h rename to src/platform/silabs/wifi/lwip-support/ethernetif.h diff --git a/src/platform/silabs/efr32/wifi/lwip_netif.cpp b/src/platform/silabs/wifi/lwip-support/lwip_netif.cpp similarity index 94% rename from src/platform/silabs/efr32/wifi/lwip_netif.cpp rename to src/platform/silabs/wifi/lwip-support/lwip_netif.cpp index b6c523c636..3b8dea41cc 100644 --- a/src/platform/silabs/efr32/wifi/lwip_netif.cpp +++ b/src/platform/silabs/wifi/lwip-support/lwip_netif.cpp @@ -19,23 +19,13 @@ #include #include -#include "em_bus.h" -#include "em_cmu.h" -#include "em_gpio.h" -#include "em_ldma.h" -#include "em_usart.h" - -#include "wfx_host_events.h" +#include #include "dhcp_client.h" #include "ethernetif.h" -#include "FreeRTOS.h" -#include "event_groups.h" -#include "task.h" - #include -#include + using namespace ::chip; using namespace ::chip::DeviceLayer; diff --git a/examples/platform/silabs/efr32/rs911x/Rsi91xWifiInterface.cpp b/src/platform/silabs/wifi/rs911x/WifiInterface.cpp similarity index 98% rename from examples/platform/silabs/efr32/rs911x/Rsi91xWifiInterface.cpp rename to src/platform/silabs/wifi/rs911x/WifiInterface.cpp index 57915298d8..bf04b0610c 100644 --- a/examples/platform/silabs/efr32/rs911x/Rsi91xWifiInterface.cpp +++ b/src/platform/silabs/wifi/rs911x/WifiInterface.cpp @@ -15,24 +15,20 @@ * limitations under the License. */ -#include -#include -#include - -#include "em_bus.h" -#include "em_cmu.h" -#include "em_gpio.h" -#include "em_ldma.h" -#include "em_usart.h" - +#include "lwip/nd6.h" +#include "silabs_utils.h" #include "sl_status.h" #include -// TODO Fix include order issue #33120 -#include "wfx_host_events.h" +#include +#include +#include +#include +#include +#include +#include +#include -#ifdef __cplusplus extern "C" { -#endif #include "rsi_bootup_config.h" #include "rsi_common_apis.h" #include "rsi_data_types.h" @@ -45,21 +41,7 @@ extern "C" { #include "rsi_wlan_apis.h" #include "rsi_wlan_config.h" #include "rsi_wlan_non_rom.h" -#ifdef __cplusplus } -#endif - -#include "WifiInterfaceAbstraction.h" -#include "WiseconnectInterfaceAbstraction.h" -#include "dhcp_client.h" -#include "ethernetif.h" -#include "lwip/nd6.h" -#include "silabs_utils.h" - -#include -#include -#include -#include using WifiStateFlags = chip::BitFlags; diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c b/src/platform/silabs/wifi/rs911x/platform/efx32_ncp_host.c similarity index 96% rename from examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c rename to src/platform/silabs/wifi/rs911x/platform/efx32_ncp_host.c index 6703e2b287..ff67284d2a 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx32_ncp_host.c +++ b/src/platform/silabs/wifi/rs911x/platform/efx32_ncp_host.c @@ -26,9 +26,11 @@ #include "sl_constants.h" #include "sl_rsi_utility.h" #include "sl_si91x_host_interface.h" +#include "sl_si91x_ncp_utility.h" #include "sl_si91x_status.h" #include "sl_status.h" #include "sl_wifi_constants.h" +#include #include #include @@ -40,9 +42,6 @@ #include "sl_board_control.h" #endif // SL_BOARD_NAME -#include "sl_si91x_ncp_utility.h" -#include "spi_multiplex.h" - static bool dma_callback(unsigned int channel, unsigned int sequenceNo, void * userParam); uint32_t rx_ldma_channel; diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/src/platform/silabs/wifi/rs911x/platform/efx_spi.c similarity index 98% rename from examples/platform/silabs/efr32/rs911x/hal/efx_spi.c rename to src/platform/silabs/wifi/rs911x/platform/efx_spi.c index 75f1edcd55..a339f711a4 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/src/platform/silabs/wifi/rs911x/platform/efx_spi.c @@ -18,31 +18,23 @@ /** * Includes */ -#include -#include -#include #include "FreeRTOS.h" -#include "event_groups.h" -#include "semphr.h" -#include "task.h" - -#include "dmadrv.h" -#include "em_chip.h" #include "em_cmu.h" -#include "em_core.h" -#include "em_device.h" -#include "em_gpio.h" -#include "em_ldma.h" +#include "em_eusart.h" #include "gpiointerrupt.h" +#include "rsi_board_configuration.h" +#include "rsi_driver.h" +#include "semphr.h" +#include "silabs_utils.h" #include "sl_device_init_clocks.h" #include "sl_device_init_hfxo.h" +#include "sl_spidrv_eusart_exp_config.h" #include "sl_spidrv_instances.h" #include "sl_status.h" #include "spidrv.h" - -#include "silabs_utils.h" -#include "spi_multiplex.h" +#include "task.h" +#include #ifdef SL_BOARD_NAME #include "sl_board_control.h" @@ -52,9 +44,6 @@ #include "sl_power_manager.h" #endif -#include "rsi_board_configuration.h" -#include "rsi_driver.h" - #if SL_BTLCTRL_MUX #include "btl_interface.h" #endif // SL_BTLCTRL_MUX @@ -66,10 +55,6 @@ #include "sl_mx25_flash_shutdown_usart_config.h" #endif // SL_MX25CTRL_MUX -#include "em_eusart.h" -#include "sl_spidrv_eusart_exp_config.h" -#include "spi_multiplex.h" - #define SL_SPIDRV_HANDLE sl_spidrv_eusart_exp_handle #define SL_SPIDRV_EXP_BITRATE_MULTIPLEXED SL_SPIDRV_EUSART_EXP_BITRATE diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_board_configuration.h b/src/platform/silabs/wifi/rs911x/platform/rsi_board_configuration.h similarity index 100% rename from examples/platform/silabs/efr32/rs911x/hal/rsi_board_configuration.h rename to src/platform/silabs/wifi/rs911x/platform/rsi_board_configuration.h diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal.h b/src/platform/silabs/wifi/rs911x/platform/rsi_hal.h similarity index 100% rename from examples/platform/silabs/efr32/rs911x/hal/rsi_hal.h rename to src/platform/silabs/wifi/rs911x/platform/rsi_hal.h diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c b/src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_interrupt.c similarity index 100% rename from examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c rename to src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_interrupt.c diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c b/src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_ioports.c similarity index 100% rename from examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c rename to src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_ioports.c diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_rtc.c b/src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_rtc.c similarity index 100% rename from examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_rtc.c rename to src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_rtc.c diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_timer.c b/src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_timer.c similarity index 100% rename from examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_timer.c rename to src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_timer.c diff --git a/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h b/src/platform/silabs/wifi/rs911x/platform/sl_board_configuration.h similarity index 100% rename from examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h rename to src/platform/silabs/wifi/rs911x/platform/sl_board_configuration.h diff --git a/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration_SiWx917.h b/src/platform/silabs/wifi/rs911x/platform/sl_board_configuration_SiWx917.h similarity index 100% rename from examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration_SiWx917.h rename to src/platform/silabs/wifi/rs911x/platform/sl_board_configuration_SiWx917.h diff --git a/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c b/src/platform/silabs/wifi/rs911x/platform/sl_si91x_ncp_utility.c similarity index 100% rename from examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c rename to src/platform/silabs/wifi/rs911x/platform/sl_si91x_ncp_utility.c diff --git a/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.h b/src/platform/silabs/wifi/rs911x/platform/sl_si91x_ncp_utility.h similarity index 84% rename from examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.h rename to src/platform/silabs/wifi/rs911x/platform/sl_si91x_ncp_utility.h index 0bd8dae764..b434e35f82 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.h +++ b/src/platform/silabs/wifi/rs911x/platform/sl_si91x_ncp_utility.h @@ -29,7 +29,9 @@ #include "semphr.h" #include "silabs_utils.h" #include "sl_status.h" -#include "spi_multiplex.h" + +// TODO: This is a WF200 specific include. It is not clear why we need this in the 917 NCP files. +#include #if defined(CHIP_9117) #include "em_usart.h" @@ -46,4 +48,4 @@ sl_status_t spi_board_init(void); extern uint32_t rx_ldma_channel; extern uint32_t tx_ldma_channel; -#endif // SL_SI91X_NCP_UTILITY_H \ No newline at end of file +#endif // SL_SI91X_NCP_UTILITY_H diff --git a/examples/platform/silabs/efr32/rs911x/rs9117.gni b/src/platform/silabs/wifi/rs911x/rs9117.gni similarity index 74% rename from examples/platform/silabs/efr32/rs911x/rs9117.gni rename to src/platform/silabs/wifi/rs911x/rs9117.gni index 87e3caeeb7..cbeaf98698 100644 --- a/examples/platform/silabs/efr32/rs911x/rs9117.gni +++ b/src/platform/silabs/wifi/rs911x/rs9117.gni @@ -17,22 +17,22 @@ import("//build_overrides/efr32_sdk.gni") import("${silabs_sdk_build_root}/efr32_sdk.gni") rs911x_src_plat = [ - "${chip_root}/examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp", - "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c", - "${examples_plat_dir}/rs911x/hal/sl_si91x_ncp_utility.c", - "${examples_plat_dir}/rs911x/hal/efx32_ncp_host.c", - "${silabs_common_plat_dir}/wifi/WifiInterfaceAbstraction.cpp", - "${silabs_common_plat_dir}/wifi/WiseconnectInterfaceAbstraction.cpp", -] + "${chip_root}/src/platform/silabs/wifi/SiWx/WifiInterface.cpp", + "${chip_root}/src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_interrupt.c", + "${chip_root}/src/platform/silabs/wifi/rs911x/platform/sl_si91x_ncp_utility.c", + "${chip_root}/src/platform/silabs/wifi/rs911x/platform/sl_board_configuration.h", + "${chip_root}/src/platform/silabs/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.cpp", + "${chip_root}/src/platform/silabs/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.h", + + # TODO: We shouldn't need a file form the WF200 for the SiWx917 NCP builds + "${chip_root}/src/platform/silabs/wifi/wf200/platform/spi_multiplex.h", -rs9117_inc_plat = [ - "${examples_plat_dir}/rs911x", - "${examples_plat_dir}/rs911x/hal", - "${wifi_sdk_root}/components/si91x/ble/inc", - "${silabs_common_plat_dir}/wifi", + # TODO : We should be using the file from the Wiseconnect SDK and not our copy of it. + "${chip_root}/src/platform/silabs/wifi/rs911x/platform/efx32_ncp_host.c", ] -rs911x_cflags = [ "-Wno-empty-body" ] +rs9117_inc_plat = [ "${wifi_sdk_root}/components/si91x/ble/inc" ] + rs9117_src_sapi = [ # sl_si91x_wireless component "${wifi_sdk_root}/components/device/silabs/si91x/wireless/src/sl_si91x_driver.c", diff --git a/examples/platform/silabs/efr32/rs911x/rs911x.gni b/src/platform/silabs/wifi/rs911x/rs911x.gni similarity index 80% rename from examples/platform/silabs/efr32/rs911x/rs911x.gni rename to src/platform/silabs/wifi/rs911x/rs911x.gni index 068d5abdb3..3daba8b049 100644 --- a/examples/platform/silabs/efr32/rs911x/rs911x.gni +++ b/src/platform/silabs/wifi/rs911x/rs911x.gni @@ -17,13 +17,14 @@ import("//build_overrides/efr32_sdk.gni") import("${silabs_sdk_build_root}/efr32_sdk.gni") rs911x_src_plat = [ - "${examples_plat_dir}/rs911x/Rsi91xWifiInterface.cpp", - "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c", - "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_ioports.c", - "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_timer.c", - "${examples_plat_dir}/rs911x/hal/efx_spi.c", - "${silabs_common_plat_dir}/wifi/WifiInterfaceAbstraction.cpp", - "${silabs_common_plat_dir}/wifi/WiseconnectInterfaceAbstraction.cpp", + "${chip_root}/src/platform/silabs/wifi/rs911x/WifiInterface.cpp", + "${chip_root}/src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_interrupt.c", + "${chip_root}/src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_ioports.c", + "${chip_root}/src/platform/silabs/wifi/rs911x/platform/rsi_hal_mcu_timer.c", + "${chip_root}/src/platform/silabs/wifi/rs911x/platform/efx_spi.c", + "${chip_root}/src/platform/silabs/wifi/rs911x/platform/rsi_board_configuration.h", + "${chip_root}/src/platform/silabs/wifi/rs911x/platform/rsi_hal.h", + "${chip_root}/src/platform/silabs/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.cpp", ] # @@ -67,11 +68,4 @@ rs911x_src_sapi = [ "${wiseconnect_sdk_root}/sapi/network/socket/rsi_socket_rom.c", ] -rs911x_cflags = [ "-Wno-empty-body" ] - -rs911x_inc_plat = [ - "${examples_plat_dir}/rs911x", - "${examples_plat_dir}/rs911x/hal", - "${wiseconnect_sdk_root}/sapi/include", - "${silabs_common_plat_dir}/wifi", -] +rs911x_inc_plat = [ "${wiseconnect_sdk_root}/sapi/include" ] diff --git a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h b/src/platform/silabs/wifi/rs911x/rsi_wlan_config.h similarity index 100% rename from examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h rename to src/platform/silabs/wifi/rs911x/rsi_wlan_config.h diff --git a/examples/platform/silabs/efr32/wf200/Wf200WifiInterface.cpp b/src/platform/silabs/wifi/wf200/WifiInterface.cpp similarity index 98% rename from examples/platform/silabs/efr32/wf200/Wf200WifiInterface.cpp rename to src/platform/silabs/wifi/wf200/WifiInterface.cpp index f068842fe5..6d2ce15b82 100644 --- a/examples/platform/silabs/efr32/wf200/Wf200WifiInterface.cpp +++ b/src/platform/silabs/wifi/wf200/WifiInterface.cpp @@ -15,28 +15,26 @@ * limitations under the License. */ -#include "AppConfig.h" #include "FreeRTOS.h" -#include "dhcp_client.h" #include "em_bus.h" #include "em_cmu.h" #include "em_gpio.h" #include "em_ldma.h" #include "em_usart.h" -#include "ethernetif.h" #include "event_groups.h" #include "gpiointerrupt.h" -#include "sl_wfx_board.h" #include "sl_wfx_cmd_api.h" #include "sl_wfx_constants.h" -#include "sl_wfx_host.h" -#include "sl_wfx_task.h" #include "task.h" -#include "wfx_host_events.h" #include #include #include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -44,6 +42,10 @@ using namespace ::chip; using namespace ::chip::DeviceLayer; +// TODO: This is a workaround because we depend on the platform lib which depends on the platform implementation. +// As such we can't depend on the platform here as well +extern void HandleWFXSystemEvent(wfx_event_base_t eventBase, sl_wfx_generic_message_t * eventData); + /* wfxRsi Task will use as its stack */ StackType_t wfxEventTaskStack[1024] = { 0 }; @@ -333,7 +335,7 @@ sl_status_t sl_wfx_host_process_event(sl_wfx_generic_message_t * event_payload) /******** INDICATION ********/ case SL_WFX_STARTUP_IND_ID: { ChipLogProgress(DeviceLayer, "startup completed."); - PlatformMgrImpl().HandleWFXSystemEvent(WIFI_EVENT, event_payload); + HandleWFXSystemEvent(WIFI_EVENT, event_payload); break; } case SL_WFX_CONNECT_IND_ID: { diff --git a/examples/platform/silabs/efr32/wf200/efr_spi.c b/src/platform/silabs/wifi/wf200/platform/efr_spi.c similarity index 99% rename from examples/platform/silabs/efr32/wf200/efr_spi.c rename to src/platform/silabs/wifi/wf200/platform/efr_spi.c index b5a31cbaaf..6f80fc83d9 100644 --- a/examples/platform/silabs/efr32/wf200/efr_spi.c +++ b/src/platform/silabs/wifi/wf200/platform/efr_spi.c @@ -14,14 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include -#include - -#include "AppConfig.h" #include "FreeRTOS.h" -#include "semphr.h" - #include "dmadrv.h" #include "em_bus.h" #include "em_cmu.h" @@ -29,6 +22,7 @@ #include "em_ldma.h" #include "em_usart.h" #include "gpiointerrupt.h" +#include "semphr.h" #include "sl_spidrv_exp_config.h" #include "sl_spidrv_instances.h" #include "sl_wfx.h" @@ -38,8 +32,10 @@ #include "sl_wfx_host_api.h" #include "sl_wfx_task.h" #include "spidrv.h" - -#include "spi_multiplex.h" +#include +#include +#include +#include #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) #include "sl_power_manager.h" @@ -441,6 +437,8 @@ sl_status_t sl_wfx_host_post_lcd_spi_transfer(void) #endif // SL_SPICTRL_MUX return SL_STATUS_OK; } +#else +#error still not working #endif // SL_LCDCTRL_MUX #if SL_UARTCTRL_MUX diff --git a/examples/platform/silabs/efr32/sl_custom_board.h b/src/platform/silabs/wifi/wf200/platform/sl_custom_board.h similarity index 100% rename from examples/platform/silabs/efr32/sl_custom_board.h rename to src/platform/silabs/wifi/wf200/platform/sl_custom_board.h diff --git a/examples/platform/silabs/efr32/wf200/sl_wfx_board.h b/src/platform/silabs/wifi/wf200/platform/sl_wfx_board.h similarity index 100% rename from examples/platform/silabs/efr32/wf200/sl_wfx_board.h rename to src/platform/silabs/wifi/wf200/platform/sl_wfx_board.h diff --git a/examples/platform/silabs/efr32/wf200/sl_wfx_host.h b/src/platform/silabs/wifi/wf200/platform/sl_wfx_host.h similarity index 100% rename from examples/platform/silabs/efr32/wf200/sl_wfx_host.h rename to src/platform/silabs/wifi/wf200/platform/sl_wfx_host.h diff --git a/examples/platform/silabs/efr32/wf200/sl_wfx_task.c b/src/platform/silabs/wifi/wf200/platform/sl_wfx_task.c similarity index 100% rename from examples/platform/silabs/efr32/wf200/sl_wfx_task.c rename to src/platform/silabs/wifi/wf200/platform/sl_wfx_task.c diff --git a/examples/platform/silabs/efr32/wf200/sl_wfx_task.h b/src/platform/silabs/wifi/wf200/platform/sl_wfx_task.h similarity index 100% rename from examples/platform/silabs/efr32/wf200/sl_wfx_task.h rename to src/platform/silabs/wifi/wf200/platform/sl_wfx_task.h diff --git a/examples/platform/silabs/efr32/spi_multiplex.h b/src/platform/silabs/wifi/wf200/platform/spi_multiplex.h similarity index 100% rename from examples/platform/silabs/efr32/spi_multiplex.h rename to src/platform/silabs/wifi/wf200/platform/spi_multiplex.h diff --git a/examples/platform/silabs/efr32/wf200/wf200_init.c b/src/platform/silabs/wifi/wf200/platform/wf200_init.c similarity index 100% rename from examples/platform/silabs/efr32/wf200/wf200_init.c rename to src/platform/silabs/wifi/wf200/platform/wf200_init.c diff --git a/examples/platform/silabs/efr32/wf200/wf200.gni b/src/platform/silabs/wifi/wf200/wf200.gni similarity index 50% rename from examples/platform/silabs/efr32/wf200/wf200.gni rename to src/platform/silabs/wifi/wf200/wf200.gni index c7ebbb8647..437f9def5d 100644 --- a/examples/platform/silabs/efr32/wf200/wf200.gni +++ b/src/platform/silabs/wifi/wf200/wf200.gni @@ -16,15 +16,15 @@ import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") import("${silabs_sdk_build_root}/efr32_sdk.gni") -wf200_plat_incs = [ - "${examples_plat_dir}/wf200", - "${silabs_common_plat_dir}/wifi", -] - wf200_plat_src = [ - "${examples_plat_dir}/wf200/sl_wfx_task.c", - "${examples_plat_dir}/wf200/wf200_init.c", - "${examples_plat_dir}/wf200/efr_spi.c", - "${examples_plat_dir}/wf200/Wf200WifiInterface.cpp", - "${silabs_common_plat_dir}/wifi/WifiInterfaceAbstraction.cpp", + "${chip_root}/src/platform/silabs/wifi/wf200/WifiInterface.cpp", + "${chip_root}/src/platform/silabs/wifi/wf200/platform/sl_wfx_task.c", + "${chip_root}/src/platform/silabs/wifi/wf200/platform/wf200_init.c", + "${chip_root}/src/platform/silabs/wifi/wf200/platform/efr_spi.c", + "${chip_root}/src/platform/silabs/wifi/wf200/platform/sl_wfx_board.h", + "${chip_root}/src/platform/silabs/wifi/wf200/platform/sl_wfx_host.h", + "${chip_root}/src/platform/silabs/wifi/wf200/platform/sl_wfx_task.h", + "${chip_root}/src/platform/silabs/wifi/wf200/platform/sl_custom_board.h", + "${chip_root}/src/platform/silabs/wifi/wf200/platform/spi_multiplex.h", + "${chip_root}/src/platform/silabs/wifi/wf200/platform/sl_wfx_board.h", ] diff --git a/src/platform/silabs/efr32/wifi/wfx_msgs.h b/src/platform/silabs/wifi/wfx_msgs.h similarity index 100% rename from src/platform/silabs/efr32/wifi/wfx_msgs.h rename to src/platform/silabs/wifi/wfx_msgs.h diff --git a/examples/platform/silabs/wifi/WiseconnectInterfaceAbstraction.cpp b/src/platform/silabs/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.cpp similarity index 99% rename from examples/platform/silabs/wifi/WiseconnectInterfaceAbstraction.cpp rename to src/platform/silabs/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.cpp index 3c2ec032a8..2266989b90 100644 --- a/examples/platform/silabs/wifi/WiseconnectInterfaceAbstraction.cpp +++ b/src/platform/silabs/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.cpp @@ -14,10 +14,9 @@ * limitations under the License. */ -#include "WiseconnectInterfaceAbstraction.h" #include #include -#include +#include namespace { diff --git a/examples/platform/silabs/wifi/WiseconnectInterfaceAbstraction.h b/src/platform/silabs/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.h similarity index 95% rename from examples/platform/silabs/wifi/WiseconnectInterfaceAbstraction.h rename to src/platform/silabs/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.h index d847e99fb5..9073a02ef6 100644 --- a/examples/platform/silabs/wifi/WiseconnectInterfaceAbstraction.h +++ b/src/platform/silabs/wifi/wiseconnect-abstraction/WiseconnectInterfaceAbstraction.h @@ -15,12 +15,11 @@ */ #pragma once -#include "WifiInterfaceAbstraction.h" #include #include #include +#include #include -#include #define WFX_RSI_DHCP_POLL_INTERVAL (250) /* Poll interval in ms for DHCP */ #define GET_IPV6_SUCCESS (1) diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 94763d8311..0bc8c7c693 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -19,7 +19,7 @@ import("//build_overrides/mbedtls.gni") import("${chip_root}/src/app/icd/icd.gni") import("${chip_root}/src/crypto/crypto.gni") import("${chip_root}/src/lib/lib.gni") -import("${chip_root}/src/platform/silabs/wifi_args.gni") +import("${chip_root}/src/platform/silabs/wifi/args.gni") import("${silabs_sdk_build_root}/efr32_sdk.gni") import("silabs_board.gni") diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 146077372f..9ca85baa47 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -96,6 +96,7 @@ declare_args() { examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" silabs_plat_efr32_wifi_dir = "${chip_root}/src/platform/silabs/efr32/wifi" silabs_common_plat_dir = "${chip_root}/examples/platform/silabs" +silabs_platform_dir = "${chip_root}/src/platform/silabs" is_series_2 = silabs_family == "mgm24" || silabs_family == "efr32mg24" || silabs_family == "efr32mg26" @@ -333,6 +334,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/radio/wifi/wfx_fmac_driver/firmware", "${efr32_sdk_root}/platform/radio/wifi/wfx_fmac_driver/pds/brd8022a", "${efr32_sdk_root}/platform/radio/wifi/wfx_fmac_driver/secure_link", + "${efr32_sdk_root}/platform/radio/wifi/wfx_fmac_driver/config", ] } @@ -365,12 +367,23 @@ template("efr32_sdk") { "${wifi_sdk_root}/components/protocol/wifi/si91x", ] } + + if (use_rs9116) { + # TODO: we should create a seperate directory for headers that are necessary for the underlying sdks + _include_dirs += [ + "${chip_root}/src/platform/silabs/wifi/rs911x/platform", + "${chip_root}/src/platform/silabs/wifi/rs911x", + ] + } + if (use_rs9116 || use_SiWx917) { _include_dirs += [ "${chip_root}/src/platform/silabs/rs911x" ] } + if (use_wf200 || use_rs9116 || use_SiWx917) { _include_dirs += [ "${chip_root}/src/platform/silabs/wifi" ] } + if (silabs_family != "mgm24") { _include_dirs += [ "${efr32_sdk_root}/platform/radio/rail_lib/hal", @@ -583,7 +596,7 @@ template("efr32_sdk") { } if (use_wf200 || use_rs9116 || use_SiWx917) { - import("${chip_root}/src/platform/silabs/wifi_args.gni") + import("${chip_root}/src/platform/silabs/wifi/args.gni") defines += [ "LWIP_NETIF_API=1" ] if (chip_enable_wifi_ipv4) {