diff --git a/build_overrides/efr32_sdk.gni b/build_overrides/efr32_sdk.gni index 4a7344b4c7ebed..fd5e7ce094bc65 100644 --- a/build_overrides/efr32_sdk.gni +++ b/build_overrides/efr32_sdk.gni @@ -14,5 +14,5 @@ declare_args() { # Root directory for efr32 SDK build files. - efr32_sdk_build_root = "//third_party/silabs" + silabs_sdk_build_root = "//third_party/silabs" } diff --git a/examples/air-quality-sensor-app/silabs/BUILD.gn b/examples/air-quality-sensor-app/silabs/BUILD.gn index ed3077a3f16c65..958918e0d504c1 100644 --- a/examples/air-quality-sensor-app/silabs/BUILD.gn +++ b/examples/air-quality-sensor-app/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -38,7 +38,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/build_overrides/efr32_sdk.gni b/examples/build_overrides/efr32_sdk.gni index d5a35449d9ffd0..ece2fd94e957ff 100644 --- a/examples/build_overrides/efr32_sdk.gni +++ b/examples/build_overrides/efr32_sdk.gni @@ -14,5 +14,5 @@ declare_args() { # Root directory for erf32 SDK. - efr32_sdk_build_root = "//third_party/connectedhomeip/third_party/silabs" + silabs_sdk_build_root = "//third_party/connectedhomeip/third_party/silabs" } diff --git a/examples/chef/silabs/BUILD.gn b/examples/chef/silabs/BUILD.gn index f7192457588b26..34dba76cc343db 100644 --- a/examples/chef/silabs/BUILD.gn +++ b/examples/chef/silabs/BUILD.gn @@ -18,8 +18,8 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/efr32_sdk.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/efr32_sdk.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") diff --git a/examples/dishwasher-app/silabs/BUILD.gn b/examples/dishwasher-app/silabs/BUILD.gn index d024a5da954b9d..c596a8a77e381f 100644 --- a/examples/dishwasher-app/silabs/BUILD.gn +++ b/examples/dishwasher-app/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -39,7 +39,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/energy-management-app/silabs/BUILD.gn b/examples/energy-management-app/silabs/BUILD.gn index 624cfff6250a85..d4a4887ceec3a7 100644 --- a/examples/energy-management-app/silabs/BUILD.gn +++ b/examples/energy-management-app/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -38,7 +38,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/light-switch-app/silabs/BUILD.gn b/examples/light-switch-app/silabs/BUILD.gn index 2602842edf4d83..cbe8a512f822eb 100644 --- a/examples/light-switch-app/silabs/BUILD.gn +++ b/examples/light-switch-app/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -38,7 +38,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/lighting-app/silabs/BUILD.gn b/examples/lighting-app/silabs/BUILD.gn index 55d7d4100946f2..00aa6d9028a2ef 100644 --- a/examples/lighting-app/silabs/BUILD.gn +++ b/examples/lighting-app/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -38,7 +38,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/lit-icd-app/silabs/BUILD.gn b/examples/lit-icd-app/silabs/BUILD.gn index eb7fa7a09a6d95..8dfa759c2b909a 100644 --- a/examples/lit-icd-app/silabs/BUILD.gn +++ b/examples/lit-icd-app/silabs/BUILD.gn @@ -19,7 +19,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -39,7 +39,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/lock-app/silabs/BUILD.gn b/examples/lock-app/silabs/BUILD.gn index a20a4ad66fedc7..81640548c32d5b 100644 --- a/examples/lock-app/silabs/BUILD.gn +++ b/examples/lock-app/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -38,7 +38,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/platform/silabs/FreeRTOSConfig.h b/examples/platform/silabs/FreeRTOSConfig.h index 1c2db9621f61ee..24a1408a47a077 100644 --- a/examples/platform/silabs/FreeRTOSConfig.h +++ b/examples/platform/silabs/FreeRTOSConfig.h @@ -103,8 +103,6 @@ extern "C" { #endif -#include - #include #include diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 4440fcf58444ca..44c60ca0f101e7 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -40,9 +40,9 @@ #include "MemMonitoring.h" #endif -#ifdef SLI_SI91X_MCU_INTERFACE +#if defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 #include "wfx_rsi.h" -#endif /* SLI_SI91X_MCU_INTERFACE */ +#endif // SLI_SI91X_MCU_INTERFACE #include // If building with the EFR32-provided crypto backend, we can use the @@ -121,7 +121,7 @@ void UnlockOpenThreadTask(void) CHIP_ERROR SilabsMatterConfig::InitOpenThread(void) { - SILABS_LOG("Initializing OpenThread stack"); + ChipLogProgress(DeviceLayer, "Initializing OpenThread stack"); ReturnErrorOnFailure(ThreadStackMgr().InitThreadStack()); #if CHIP_DEVICE_CONFIG_THREAD_FTD @@ -138,7 +138,7 @@ CHIP_ERROR SilabsMatterConfig::InitOpenThread(void) #endif // CHIP_CONFIG_ENABLE_ICD_SERVER #endif // CHIP_DEVICE_CONFIG_THREAD_FTD - SILABS_LOG("Starting OpenThread task"); + ChipLogProgress(DeviceLayer, "Starting OpenThread task"); return ThreadStackMgrImpl().StartThreadTask(); } #endif // CHIP_ENABLE_OPENTHREAD @@ -171,7 +171,7 @@ void ApplicationStart(void * unused) SetDeviceAttestationCredentialsProvider(&Provision::Manager::GetInstance().GetStorage()); chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - SILABS_LOG("Starting App Task"); + ChipLogProgress(DeviceLayer, "Starting App Task"); err = AppTask::GetAppTask().StartAppTask(); if (err != CHIP_NO_ERROR) appError(err); @@ -185,13 +185,13 @@ void SilabsMatterConfig::AppInit() { GetPlatform().Init(); sMainTaskHandle = osThreadNew(ApplicationStart, nullptr, &kMainTaskAttr); - SILABS_LOG("Starting scheduler"); + ChipLogProgress(DeviceLayer, "Starting scheduler"); VerifyOrDie(sMainTaskHandle); // We can't proceed if the Main Task creation failed. GetPlatform().StartScheduler(); // Should never get here. chip::Platform::MemoryShutdown(); - SILABS_LOG("Start Scheduler Failed"); + ChipLogProgress(DeviceLayer, "Start Scheduler Failed"); appError(CHIP_ERROR_INTERNAL); } @@ -204,9 +204,9 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) // initialization. mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree); #endif - SILABS_LOG("=================================================="); - SILABS_LOG("%s starting", appName); - SILABS_LOG("=================================================="); + ChipLogProgress(DeviceLayer, "=================================================="); + ChipLogProgress(DeviceLayer, "%s starting", appName); + ChipLogProgress(DeviceLayer, "=================================================="); #if PW_RPC_ENABLED chip::rpc::Init(); @@ -219,7 +219,7 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) //============================================== // Init Matter Stack //============================================== - SILABS_LOG("Init CHIP Stack"); + ChipLogProgress(DeviceLayer, "Init CHIP Stack"); #ifdef SL_WIFI // Init Chip memory management before the stack @@ -309,16 +309,13 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void) // Start wfx bus communication task. wfx_bus_start(); #ifdef SL_WFX_USE_SECURE_LINK - wfx_securelink_task_start(); // start securelink key renegotiation task -#endif // SL_WFX_USE_SECURE_LINK -#endif /* WF200_WIFI */ - -#ifdef SLI_SI91X_MCU_INTERFACE - sl_status_t status; - if ((status = wfx_wifi_rsi_init()) != SL_STATUS_OK) - { - ReturnErrorOnFailure((CHIP_ERROR) status); - } + // start securelink key renegotiation task + wfx_securelink_task_start(); +#endif // SL_WFX_USE_SECURE_LINK +#endif // WF200_WIFI + +#if defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 + VerifyOrReturnError(sl_matter_wifi_platform_init() == SL_STATUS_OK, CHIP_ERROR_INTERNAL); #endif // SLI_SI91X_MCU_INTERFACE return CHIP_NO_ERROR; diff --git a/examples/platform/silabs/MatterConfig.h b/examples/platform/silabs/MatterConfig.h index b6abcc1726f7ac..0f951c36f8b477 100644 --- a/examples/platform/silabs/MatterConfig.h +++ b/examples/platform/silabs/MatterConfig.h @@ -16,6 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#pragma once #include #include diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 6756cc28c726ce..2abc3bc9d27c9a 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -19,7 +19,7 @@ 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}/third_party/silabs/silabs_board.gni") -import("${efr32_sdk_build_root}/SiWx917_sdk.gni") +import("${silabs_sdk_build_root}/SiWx917_sdk.gni") declare_args() { enable_heap_monitoring = false @@ -167,18 +167,17 @@ config("silabs-wifi-config") { source_set("siwx917-common") { deps = [ "${silabs_common_plat_dir}/provision:storage" ] defines = [] - public_deps = [] + public_deps = [ "${lwip_root}:lwip" ] public_configs = [ ":siwx917-common-config", - "${efr32_sdk_build_root}:silabs_config", + "${silabs_sdk_build_root}:silabs_config", ":chip_examples_project_config", ] include_dirs = [ - ".", - "SiWx917/", "${silabs_plat_dir}/wifi", "${silabs_plat_si91x_wifi_dir}", + "${silabs_common_plat_dir}", ] #TO-DO Cleanup to be done for all the wifi files into common folder @@ -191,10 +190,10 @@ source_set("siwx917-common") { "${silabs_common_plat_dir}/syscalls_stubs.cpp", "${silabs_common_plat_dir}/wifi/wfx_notify.cpp", "${silabs_common_plat_dir}/wifi/wfx_rsi_host.cpp", - "${silabs_plat_dir}/wifi/dhcp_client.cpp", - "${silabs_plat_si91x_wifi_dir}/ethernetif.cpp", - "${silabs_plat_si91x_wifi_dir}/lwip_netif.cpp", - "SiWx917/sl_wifi_if.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", ] if (chip_enable_pw_rpc || chip_build_libshell || sl_uart_log_output) { diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wlan_config.h b/examples/platform/silabs/SiWx917/SiWx917/sl_wlan_config.h deleted file mode 100644 index 21ee4a5555f514..00000000000000 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wlan_config.h +++ /dev/null @@ -1,110 +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 RSI_CONFIG_H -#define RSI_CONFIG_H - -#include "ble_config.h" -#if SLI_SI91X_MCU_INTERFACE -#include "rsi_wisemcu_hardware_setup.h" -#endif // SLI_SI91X_MCU_INTERFACE -#include "sl_wifi_device.h" - -//! Enable feature -#define RSI_ENABLE 1 -//! Disable feature -#define RSI_DISABLE 0 - -// Temmporary work-around for wifi-init failure in ACX modules with WiseConnect v3.3.3. This can be removed after integrating with -// WiseConnect v3.4.0 -#if (SL_SI91X_ACX_MODULE == 1) -#define REGION_CODE IGNORE_REGION -#else -#define REGION_CODE US -#endif - -static const sl_wifi_device_configuration_t config = { - .boot_option = LOAD_NWP_FW, - .mac_address = NULL, - .band = SL_SI91X_WIFI_BAND_2_4GHZ, - .region_code = REGION_CODE, - .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, - .coex_mode = SL_SI91X_WLAN_BLE_MODE, - .feature_bit_map = -#ifdef SLI_SI91X_MCU_INTERFACE - (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE), -#else - (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION), -#endif - .tcp_ip_feature_bit_map = (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT | - SL_SI91X_TCP_IP_FEAT_SSL | SL_SI91X_TCP_IP_FEAT_BYPASS -#ifdef ipv6_FEATURE_REQUIRED - | SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT | SL_SI91X_TCP_IP_FEAT_IPV6 -#endif - | SL_SI91X_TCP_IP_FEAT_ICMP | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID), - .custom_feature_bit_map = (SL_SI91X_CUSTOM_FEAT_EXTENTION_VALID | RSI_CUSTOM_FEATURE_BIT_MAP), - .ext_custom_feature_bit_map = (RSI_EXT_CUSTOM_FEATURE_BIT_MAP | (SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE) -#if (defined A2DP_POWER_SAVE_ENABLE) - | SL_SI91X_EXT_FEAT_XTAL_CLK_ENABLE(2) -#endif - ), - .bt_feature_bit_map = (RSI_BT_FEATURE_BITMAP -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), -#ifdef RSI_PROCESS_MAX_RX_DATA - .ext_tcp_ip_feature_bit_map = - (RSI_EXT_TCPIP_FEATURE_BITMAP | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID | SL_SI91X_EXT_TCP_MAX_RECV_LENGTH), -#else - .ext_tcp_ip_feature_bit_map = (RSI_EXT_TCPIP_FEATURE_BITMAP | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), -#endif - //! ENABLE_BLE_PROTOCOL in bt_feature_bit_map - .ble_feature_bit_map = - ((SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) | - SL_SI91X_BLE_MAX_NBR_CENTRALS(RSI_BLE_MAX_NBR_CENTRALS) | - SL_SI91X_BLE_MAX_NBR_ATT_SERV(RSI_BLE_MAX_NBR_ATT_SERV) | - SL_SI91X_BLE_MAX_NBR_ATT_REC(RSI_BLE_MAX_NBR_ATT_REC)) | - SL_SI91X_FEAT_BLE_CUSTOM_FEAT_EXTENTION_VALID | SL_SI91X_BLE_PWR_INX(RSI_BLE_PWR_INX) | - SL_SI91X_BLE_PWR_SAVE_OPTIONS(RSI_BLE_PWR_SAVE_OPTIONS) | SL_SI91X_916_BLE_COMPATIBLE_FEAT_ENABLE -#if RSI_BLE_GATT_ASYNC_ENABLE - | SL_SI91X_BLE_GATT_ASYNC_ENABLE -#endif - ), - - .ble_ext_feature_bit_map = ((SL_SI91X_BLE_NUM_CONN_EVENTS(RSI_BLE_NUM_CONN_EVENTS) | - SL_SI91X_BLE_NUM_REC_BYTES(RSI_BLE_NUM_REC_BYTES)) -#if RSI_BLE_INDICATE_CONFIRMATION_FROM_HOST - | SL_SI91X_BLE_INDICATE_CONFIRMATION_FROM_HOST // indication response from app -#endif -#if RSI_BLE_MTU_EXCHANGE_FROM_HOST - | SL_SI91X_BLE_MTU_EXCHANGE_FROM_HOST // MTU Exchange request initiation from app -#endif -#if RSI_BLE_SET_SCAN_RESP_DATA_FROM_HOST - | (SL_SI91X_BLE_SET_SCAN_RESP_DATA_FROM_HOST) // Set SCAN Resp Data from app -#endif -#if RSI_BLE_DISABLE_CODED_PHY_FROM_HOST - | (SL_SI91X_BLE_DISABLE_CODED_PHY_FROM_HOST) // Disable Coded PHY from app -#endif -#if BLE_SIMPLE_GATT - | SL_SI91X_BLE_GATT_INIT -#endif - ), - .config_feature_bit_map = (SL_SI91X_FEAT_SLEEP_GPIO_SEL_BITMAP | RSI_CONFIG_FEATURE_BITMAP) } -}; - -#endif diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp b/examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp similarity index 56% rename from examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp rename to examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp index d3572289eb7f30..7aab38e663e634 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp +++ b/examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp @@ -33,10 +33,10 @@ #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 "wfx_rsi.h" - #include #include #include @@ -53,14 +53,22 @@ extern "C" { #include "sl_wifi_callback_framework.h" #include "sl_wifi_constants.h" #include "sl_wifi_types.h" -#include "sl_wlan_config.h" #include "wfx_host_events.h" #if SL_MBEDTLS_USE_TINYCRYPT #include "sl_si91x_constants.h" #include "sl_si91x_trng.h" #endif // SL_MBEDTLS_USE_TINYCRYPT + +#include +#include +#include +#include } +#if SLI_SI91X_MCU_INTERFACE +#include "rsi_wisemcu_hardware_setup.h" +#endif // SLI_SI91X_MCU_INTERFACE + #if (EXP_BOARD) #include "rsi_bt_common_apis.h" #endif @@ -69,89 +77,368 @@ extern "C" { #include "rsi_rom_power_save.h" #include "sl_si91x_button_pin_config.h" #include "sl_si91x_power_manager.h" +#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE + +// Temmporary work-around for wifi-init failure in ACX modules with WiseConnect v3.3.3. This can be removed after integrating with +// WiseConnect v3.4.0 +#if (SL_SI91X_ACX_MODULE == 1) +#define REGION_CODE IGNORE_REGION +#else +#define REGION_CODE US +#endif + +WfxRsi_t wfx_rsi; +extern osSemaphoreId_t sl_rs_ble_init_sem; namespace { + +#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE // TODO: should be removed once we are getting the press interrupt for button 0 with sleep -#define BUTTON_PRESSED 1 bool btn0_pressed = false; - #ifdef ENABLE_CHIP_SHELL bool ps_requirement_added = false; #endif // ENABLE_CHIP_SHELL -} // namespace #endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE -#define ADV_SCAN_THRESHOLD -40 -#define ADV_RSSI_TOLERANCE_THRESHOLD 5 -#define ADV_ACTIVE_SCAN_DURATION 15 -#define ADV_PASSIVE_SCAN_DURATION 20 -#define ADV_MULTIPROBE 1 -#define ADV_SCAN_PERIODICITY 10 +bool hasNotifiedWifiConnectivity = false; +bool hasNotifiedIPV6 = false; +#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4) +bool hasNotifiedIPV4 = false; +#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ + +wfx_wifi_scan_ext_t temp_reset; + +osSemaphoreId_t sScanCompleteSemaphore; +osSemaphoreId_t sScanInProgressSemaphore; +osTimerId_t sDHCPTimer; +osMessageQueueId_t sWifiEventQueue = nullptr; + +sl_net_wifi_lwip_context_t wifi_client_context; +sl_wifi_security_t security = SL_WIFI_SECURITY_UNKNOWN; + +const sl_wifi_device_configuration_t config = { + .boot_option = LOAD_NWP_FW, + .mac_address = NULL, + .band = SL_SI91X_WIFI_BAND_2_4GHZ, + .region_code = REGION_CODE, + .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, + .coex_mode = SL_SI91X_WLAN_BLE_MODE, + .feature_bit_map = +#ifdef SLI_SI91X_MCU_INTERFACE + (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE), +#else + (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION), +#endif + .tcp_ip_feature_bit_map = (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT | + SL_SI91X_TCP_IP_FEAT_SSL | SL_SI91X_TCP_IP_FEAT_BYPASS +#ifdef ipv6_FEATURE_REQUIRED + | SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT | SL_SI91X_TCP_IP_FEAT_IPV6 +#endif + | SL_SI91X_TCP_IP_FEAT_ICMP | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID), + .custom_feature_bit_map = (SL_SI91X_CUSTOM_FEAT_EXTENTION_VALID | RSI_CUSTOM_FEATURE_BIT_MAP), + .ext_custom_feature_bit_map = (RSI_EXT_CUSTOM_FEATURE_BIT_MAP | (SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE) +#if (defined A2DP_POWER_SAVE_ENABLE) + | SL_SI91X_EXT_FEAT_XTAL_CLK_ENABLE(2) +#endif + ), + .bt_feature_bit_map = (RSI_BT_FEATURE_BITMAP +#if (RSI_BT_GATT_ON_CLASSIC) + | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ +#endif + ), +#ifdef RSI_PROCESS_MAX_RX_DATA + .ext_tcp_ip_feature_bit_map = + (RSI_EXT_TCPIP_FEATURE_BITMAP | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID | SL_SI91X_EXT_TCP_MAX_RECV_LENGTH), +#else + .ext_tcp_ip_feature_bit_map = (RSI_EXT_TCPIP_FEATURE_BITMAP | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), +#endif + //! ENABLE_BLE_PROTOCOL in bt_feature_bit_map + .ble_feature_bit_map = + ((SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) | + SL_SI91X_BLE_MAX_NBR_CENTRALS(RSI_BLE_MAX_NBR_CENTRALS) | + SL_SI91X_BLE_MAX_NBR_ATT_SERV(RSI_BLE_MAX_NBR_ATT_SERV) | + SL_SI91X_BLE_MAX_NBR_ATT_REC(RSI_BLE_MAX_NBR_ATT_REC)) | + SL_SI91X_FEAT_BLE_CUSTOM_FEAT_EXTENTION_VALID | SL_SI91X_BLE_PWR_INX(RSI_BLE_PWR_INX) | + SL_SI91X_BLE_PWR_SAVE_OPTIONS(RSI_BLE_PWR_SAVE_OPTIONS) | SL_SI91X_916_BLE_COMPATIBLE_FEAT_ENABLE +#if RSI_BLE_GATT_ASYNC_ENABLE + | SL_SI91X_BLE_GATT_ASYNC_ENABLE +#endif + ), + + .ble_ext_feature_bit_map = ((SL_SI91X_BLE_NUM_CONN_EVENTS(RSI_BLE_NUM_CONN_EVENTS) | + SL_SI91X_BLE_NUM_REC_BYTES(RSI_BLE_NUM_REC_BYTES)) +#if RSI_BLE_INDICATE_CONFIRMATION_FROM_HOST + | SL_SI91X_BLE_INDICATE_CONFIRMATION_FROM_HOST // indication response from app +#endif +#if RSI_BLE_MTU_EXCHANGE_FROM_HOST + | SL_SI91X_BLE_MTU_EXCHANGE_FROM_HOST // MTU Exchange request initiation from app +#endif +#if RSI_BLE_SET_SCAN_RESP_DATA_FROM_HOST + | (SL_SI91X_BLE_SET_SCAN_RESP_DATA_FROM_HOST) // Set SCAN Resp Data from app +#endif +#if RSI_BLE_DISABLE_CODED_PHY_FROM_HOST + | (SL_SI91X_BLE_DISABLE_CODED_PHY_FROM_HOST) // Disable Coded PHY from app +#endif +#if BLE_SIMPLE_GATT + | SL_SI91X_BLE_GATT_INIT +#endif + ), + .config_feature_bit_map = (SL_SI91X_FEAT_SLEEP_GPIO_SEL_BITMAP | RSI_CONFIG_FEATURE_BITMAP) } +}; + +constexpr int8_t kAdvScanThreshold = -40; +constexpr uint8_t kAdvRssiToleranceThreshold = 5; +constexpr uint8_t kAdvActiveScanDuration = 15; +constexpr uint8_t kAdvPassiveScanDuration = 20; +constexpr uint8_t kAdvMultiProbe = 1; +constexpr uint8_t kAdvScanPeriodicity = 10; // TODO: Confirm that this value works for size and timing -#define WFX_QUEUE_SIZE 10 +constexpr uint8_t kWfxQueueSize = 10; // TODO: Figure out why we actually need this, we are already handling failure and retries somewhere else. -#define WIFI_SCAN_TIMEOUT_TICK 10000 +constexpr uint16_t kWifiScanTimeoutTicks = 10000; -WfxRsi_t wfx_rsi; +void DHCPTimerEventHandler(void * arg) +{ + WfxEvent_t event = { .eventType = WFX_EVT_DHCP_POLL }; + sl_matter_wifi_post_event(&event); +} -bool hasNotifiedIPV6 = false; -#if (CHIP_DEVICE_CONFIG_ENABLE_IPV4) -bool hasNotifiedIPV4 = false; -#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ -bool hasNotifiedWifiConnectivity = false; +void CancelDHCPTimer(void) +{ + VerifyOrReturn(osTimerIsRunning(sDHCPTimer), ChipLogDetail(DeviceLayer, "CancelDHCPTimer: timer not running")); + VerifyOrReturn(osTimerStop(sDHCPTimer) == osOK, ChipLogError(DeviceLayer, "CancelDHCPTimer: failed to stop timer")); +} -volatile bool scan_results_complete = false; -volatile bool bg_scan_results_complete = false; -extern osSemaphoreId_t sl_rs_ble_init_sem; -static wfx_wifi_scan_ext_t temp_reset; -volatile sl_status_t callback_status = SL_STATUS_OK; -// Scan semaphore -static osSemaphoreId_t sScanSemaphore; -// DHCP Poll timer -static osTimerId_t sDHCPTimer; -static osMessageQueueId_t sWifiEventQueue = NULL; - -static void DHCPTimerEventHandler(void * arg) +void StartDHCPTimer(uint32_t timeout) { - WfxEvent_t event; - event.eventType = WFX_EVT_DHCP_POLL; - WfxPostEvent(&event); + // Cancel timer if already started + CancelDHCPTimer(); + + VerifyOrReturn(osTimerStart(sDHCPTimer, pdMS_TO_TICKS(timeout)) == osOK, + ChipLogError(DeviceLayer, "StartDHCPTimer: failed to start timer")); } -static void CancelDHCPTimer(void) +sl_status_t sl_wifi_siwx917_init(void) { - osStatus_t status; + sl_status_t status = SL_STATUS_OK; + +#ifdef SLI_SI91X_MCU_INTERFACE + // SoC Configurations + uint8_t xtal_enable = 1; + status = sl_si91x_m4_ta_secure_handshake(SL_SI91X_ENABLE_XTAL, 1, &xtal_enable, 0, nullptr); + VerifyOrReturnError(status == SL_STATUS_OK, status, + ChipLogError(DeviceLayer, "sl_si91x_m4_ta_secure_handshake failed: 0x%lx", static_cast(status))); + +#if CHIP_CONFIG_ENABLE_ICD_SERVER +#ifdef ENABLE_CHIP_SHELL + // While using the matter shell with a Low Power Build, GPIO 1 is used to check the UULP PIN 1 status + // since UART doesn't act as a wakeup source in the UULP mode. + + // Configuring the NPS GPIO 1 + RSI_NPSSGPIO_SetPinMux(RTE_UULP_GPIO_1_PIN, 0); + + // Configure the NPSS GPIO direction to input + RSI_NPSSGPIO_SetDir(RTE_UULP_GPIO_1_PIN, 1); + + // Enable the REN + RSI_NPSSGPIO_InputBufferEn(RTE_UULP_GPIO_1_PIN, 1); +#endif // ENABLE_CHIP_SHELL +#endif // CHIP_CONFIG_ENABLE_ICD_SERVER + +#else + // NCP Configurations + status = sl_matter_wifi_platform_init(); + VerifyOrReturnError(status == SL_STATUS_OK, status, + ChipLogError(DeviceLayer, "sl_matter_wifi_platform_init failed: 0x%lx", static_cast(status))); +#endif // SLI_SI91X_MCU_INTERFACE + + sl_wifi_firmware_version_t version = { 0 }; + status = sl_wifi_get_firmware_version(&version); + VerifyOrReturnError(status == SL_STATUS_OK, status, + ChipLogError(DeviceLayer, "sl_wifi_get_firmware_version failed: 0x%lx", static_cast(status))); + + ChipLogDetail(DeviceLayer, "Firmware version is: %x%x.%d.%d.%d.%d.%d.%d", version.chip_id, version.rom_id, version.major, + version.minor, version.security_version, version.patch_num, version.customer_id, version.build_num); + + status = sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, (sl_mac_address_t *) &wfx_rsi.sta_mac.octet[0]); + VerifyOrReturnError(status == SL_STATUS_OK, status, + ChipLogError(DeviceLayer, "sl_wifi_get_mac_address failed: 0x%lx", static_cast(status))); + +#ifdef SL_MBEDTLS_USE_TINYCRYPT + constexpr uint32_t trngKey[TRNG_KEY_SIZE] = { 0x16157E2B, 0xA6D2AE28, 0x8815F7AB, 0x3C4FCF09 }; + + // To check the Entropy of TRNG and verify TRNG functioning. + status = sl_si91x_trng_entropy(); + VerifyOrReturnError(status == SL_STATUS_OK, status, + ChipLogError(DeviceLayer, "sl_si91x_trng_entropy failed: 0x%lx", static_cast(status))); + + // Initiate and program the key required for TRNG hardware engine + status = sl_si91x_trng_program_key((uint32_t *) trngKey, TRNG_KEY_SIZE); + VerifyOrReturnError(status == SL_STATUS_OK, status, + ChipLogError(DeviceLayer, "sl_si91x_trng_program_key failed: 0x%lx", static_cast(status))); +#endif // SL_MBEDTLS_USE_TINYCRYPT + + wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY; + osSemaphoreRelease(sl_rs_ble_init_sem); + return status; +} + +// TODO: this changes will be reverted back after the Silabs WiFi SDK team fix the scan API +#ifndef EXP_BOARD +sl_status_t ScanCallback(sl_wifi_event_t event, sl_wifi_scan_result_t * scan_result, uint32_t result_length, void * arg) +{ + sl_status_t status = SL_STATUS_OK; + if (SL_WIFI_CHECK_IF_EVENT_FAILED(event)) + { + ChipLogError(DeviceLayer, "Scan Netwrok Failed: 0x%lx", *reinterpret_cast(status)); +#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION + security = SL_WIFI_WPA3; +#else + security = SL_WIFI_WPA_WPA2_MIXED; +#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */ - // Check if timer started - if (!osTimerIsRunning(sDHCPTimer)) + status = SL_STATUS_FAIL; + } + else { - ChipLogDetail(DeviceLayer, "CancelDHCPTimer: timer not running"); - return; + security = static_cast(scan_result->scan_info[0].security_mode); + wfx_rsi.ap_chan = scan_result->scan_info[0].rf_channel; + memcpy(&wfx_rsi.ap_mac.octet, scan_result->scan_info[0].bssid, BSSID_LEN); } - status = osTimerStop(sDHCPTimer); - if (status != osOK) + osSemaphoreRelease(sScanCompleteSemaphore); + return status; +} +#endif + +sl_status_t InitiateScan() +{ + sl_status_t status = SL_STATUS_OK; + +// TODO: this changes will be reverted back after the Silabs WiFi SDK team fix the scan API +#ifndef EXP_BOARD + sl_wifi_ssid_t ssid = { 0 }; + + // TODO: this changes will be reverted back after the Silabs WiFi SDK team fix the scan API + sl_wifi_scan_configuration_t wifi_scan_configuration = default_wifi_scan_configuration; + + ssid.length = wfx_rsi.sec.ssid_length; + + // TODO: workaround because the string management with the null termination is flawed + chip::Platform::CopyString((char *) &ssid.value[0], ssid.length + 1, wfx_rsi.sec.ssid); + sl_wifi_set_scan_callback(ScanCallback, NULL); + + osSemaphoreAcquire(sScanInProgressSemaphore, osWaitForever); + + // This is an odd success code? + status = sl_wifi_start_scan(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, &ssid, &wifi_scan_configuration); + if (status == SL_STATUS_IN_PROGRESS) { - ChipLogError(DeviceLayer, "CancelDHCPTimer: failed to stop timer: %d", status); + osSemaphoreAcquire(sScanCompleteSemaphore, kWifiScanTimeoutTicks); + status = SL_STATUS_OK; } + else + { + osSemaphoreRelease(sScanInProgressSemaphore); + } +#endif + + return status; } -static void StartDHCPTimer(uint32_t timeout) +sl_status_t SetWifiConfigurations() { - osStatus_t status; + sl_status_t status = SL_STATUS_OK; - // Cancel timer if already started - CancelDHCPTimer(); +#if CHIP_CONFIG_ENABLE_ICD_SERVER + // Setting the listen interval to 0 which will set it to DTIM interval + sl_wifi_listen_interval_t sleep_interval = { .listen_interval = 0 }; + status = sl_wifi_set_listen_interval(SL_WIFI_CLIENT_INTERFACE, sleep_interval); + VerifyOrReturnError(status == SL_STATUS_OK, status); + + sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 5 }; + status = sl_wifi_set_advanced_client_configuration(SL_WIFI_CLIENT_INTERFACE, &client_config); + VerifyOrReturnError(status == SL_STATUS_OK, status); +#endif // CHIP_CONFIG_ENABLE_ICD_SERVER + + status = sl_net_set_credential(SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID, SL_NET_WIFI_PSK, &wfx_rsi.sec.passkey[0], + wfx_rsi.sec.passkey_length); + VerifyOrReturnError(status == SL_STATUS_OK, status); + + sl_net_wifi_client_profile_t profile = { + .config = { + .ssid = { + //static cast because the types dont match + .length = static_cast(wfx_rsi.sec.ssid_length), + }, + .channel = { + .channel = SL_WIFI_AUTO_CHANNEL, + .band = SL_WIFI_AUTO_BAND, + .bandwidth = SL_WIFI_AUTO_BANDWIDTH + }, + .bssid = {{0}}, + .bss_type = SL_WIFI_BSS_TYPE_INFRASTRUCTURE, + .security = security, + .encryption = SL_WIFI_NO_ENCRYPTION, + .client_options = SL_WIFI_JOIN_WITH_SCAN, + .credential_id = SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID, + }, + .ip = { + .mode = SL_IP_MANAGEMENT_DHCP, + .type = SL_IPV6, + .host_name = NULL, + .ip = {{{0}}}, + } + }; + // TODO: memcpy for now since the types dont match + memcpy((char *) &profile.config.ssid.value, wfx_rsi.sec.ssid, wfx_rsi.sec.ssid_length); + + status = sl_net_set_profile((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID, &profile); + VerifyOrReturnError(status == SL_STATUS_OK, status, ChipLogError(DeviceLayer, "sl_net_set_profile Failed")); - status = osTimerStart(sDHCPTimer, pdMS_TO_TICKS(timeout)); - if (status != osOK) + return status; +} + +sl_status_t JoinWifiNetwork(void) +{ + VerifyOrReturnError(!(wfx_rsi.dev_state & (WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED)), SL_STATUS_IN_PROGRESS); + sl_status_t status = SL_STATUS_OK; + + // Start Join Network + wfx_rsi.dev_state |= WFX_RSI_ST_STA_CONNECTING; + + status = SetWifiConfigurations(); + VerifyOrReturnError(status == SL_STATUS_OK, status, ChipLogError(DeviceLayer, "Failure to set the Wifi Configurations!")); + + status = sl_net_up((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID); + + if (status == SL_STATUS_OK || status == SL_STATUS_IN_PROGRESS) { - ChipLogError(DeviceLayer, "StartDHCPTimer: failed to start timer: %d", status); + WfxEvent_t event; + event.eventType = WFX_EVT_STA_CONN; + sl_matter_wifi_post_event(&event); + return status; } + + // failure only happens when the firmware returns an error + ChipLogError(DeviceLayer, "sl_wifi_connect failed: 0x%lx", static_cast(status)); + VerifyOrReturnError((wfx_rsi.join_retries <= MAX_JOIN_RETRIES_COUNT), status); + + wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED); + ChipLogProgress(DeviceLayer, "Connection retry attempt %d", wfx_rsi.join_retries); + wfx_retry_connection(++wfx_rsi.join_retries); + + WfxEvent_t event; + event.eventType = WFX_EVT_STA_START_JOIN; + sl_matter_wifi_post_event(&event); + + return status; } +} // namespace + /****************************************************************** * @fn int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t *ap) * @brief @@ -223,41 +510,16 @@ int32_t wfx_rsi_reset_count(void) } /****************************************************************** - * @fn wfx_rsi_disconnect(void) + * @fn sl_wifi_platform_disconnect(void) * @brief * Getting the driver disconnect status * @param[in] None * @return * status *********************************************************************/ -int32_t wfx_rsi_disconnect(void) +int32_t sl_wifi_platform_disconnect(void) { - return sl_wifi_disconnect(SL_WIFI_CLIENT_INTERFACE); -} - -sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t result_length, void * arg) -{ - WfxEvent_t WfxEvent; - - wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING); - if (SL_WIFI_CHECK_IF_EVENT_FAILED(event)) - { - callback_status = *(sl_status_t *) result; - ChipLogError(DeviceLayer, "join_callback_handler: failed: 0x%lx", static_cast(callback_status)); - wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTED); - wfx_retry_connection(++wfx_rsi.join_retries); - return SL_STATUS_FAIL; - } - /* - * Join was complete - Do the DHCP - */ - ChipLogDetail(DeviceLayer, "join_callback_handler: success"); - memset(&temp_reset, 0, sizeof(temp_reset)); - wfx_rsi.join_retries = 0; - callback_status = SL_STATUS_OK; - WfxEvent.eventType = WFX_EVT_STA_CONN; - WfxPostEvent(&WfxEvent); - return SL_STATUS_OK; + return sl_net_down((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE); } #if CHIP_CONFIG_ENABLE_ICD_SERVER @@ -268,7 +530,7 @@ void sl_si91x_invoke_btn_press_event(void) // TODO: should be removed once we are getting the press interrupt for button 0 with sleep if (!RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN) && !btn0_pressed) { - sl_button_on_change(SL_BUTTON_BTN0_NUMBER, BUTTON_PRESSED); + sl_button_on_change(SL_BUTTON_BTN0_NUMBER, 1 /* Button Pressed */); btn0_pressed = true; } if (RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN)) @@ -330,206 +592,10 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_ } #endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ -/************************************************************************************* - * @fn static int32_t wfx_wifi_rsi_init(void) - * @brief - * Wifi initialization called from app main - * @param[in] None - * @return - * None - *****************************************************************************************/ -int32_t wfx_wifi_rsi_init(void) -{ - ChipLogDetail(DeviceLayer, "wfx_wifi_rsi_init: started"); - sl_status_t status; - status = sl_wifi_init(&config, NULL, sl_wifi_default_event_handler); - VerifyOrReturnError(status == SL_STATUS_OK, status); - - // Create Sempaphore for scan - sScanSemaphore = osSemaphoreNew(1, 0, NULL); - VerifyOrReturnError(sScanSemaphore != NULL, SL_STATUS_ALLOCATION_FAILED); - - // Create the message queue - sWifiEventQueue = osMessageQueueNew(WFX_QUEUE_SIZE, sizeof(WfxEvent_t), NULL); - VerifyOrReturnError(sWifiEventQueue != NULL, SL_STATUS_ALLOCATION_FAILED); - - // Create timer for DHCP polling - // TODO: Use LWIP timer instead of creating a new one here - sDHCPTimer = osTimerNew(DHCPTimerEventHandler, osTimerPeriodic, NULL, NULL); - VerifyOrReturnError(sDHCPTimer != NULL, SL_STATUS_ALLOCATION_FAILED); - - return status; -} - -/************************************************************************************* - * @fn static void sl_print_firmware_version(sl_wifi_firmware_version_t*) - * @brief - * To print the firmware version - * @param[in] sl_wifi_firmware_version_t* - * @return - * None - *****************************************************************************************/ -static void sl_print_firmware_version(sl_wifi_firmware_version_t * firmware_version) -{ - ChipLogDetail(DeviceLayer, "Firmware version is: %x%x.%d.%d.%d.%d.%d.%d", firmware_version->chip_id, firmware_version->rom_id, - firmware_version->major, firmware_version->minor, firmware_version->security_version, firmware_version->patch_num, - firmware_version->customer_id, firmware_version->build_num); -} - -/************************************************************************************* - * @fn static int32_t wfx_rsi_init(void) - * @brief - * driver initialization - * @param[in] None - * @return - * None - *****************************************************************************************/ -static sl_status_t wfx_rsi_init(void) -{ - sl_status_t status; - -#ifndef SLI_SI91X_MCU_INTERFACE - status = wfx_wifi_rsi_init(); - if (status != SL_STATUS_OK) - { - ChipLogError(DeviceLayer, "wfx_rsi_init failed: 0x%lx", static_cast(status)); - return status; - } -#else // For SoC -#if CHIP_CONFIG_ENABLE_ICD_SERVER - uint8_t xtal_enable = 1; - status = sl_si91x_m4_ta_secure_handshake(SL_SI91X_ENABLE_XTAL, 1, &xtal_enable, 0, NULL); - if (status != SL_STATUS_OK) - { - ChipLogError(DeviceLayer, "sl_si91x_m4_ta_secure_handshake failed: 0x%lx", static_cast(status)); - return status; - } -#ifdef ENABLE_CHIP_SHELL - // While using the matter shell with the ICD server, the GPIO 1 is used to check the UULP PIN 1 status - // since UART doesn't act as a wakeup source in the UULP mode - /*Configuring the NPS GPIO 1*/ - RSI_NPSSGPIO_SetPinMux(RTE_UULP_GPIO_1_PIN, 0); - /*Configure the NPSS GPIO direction to input */ - RSI_NPSSGPIO_SetDir(RTE_UULP_GPIO_1_PIN, 1); - /*Enable the REN*/ - RSI_NPSSGPIO_InputBufferEn(RTE_UULP_GPIO_1_PIN, 1); -#endif // ENABLE_CHIP_SHELL -#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ -#endif /* SLI_SI91X_MCU_INTERFACE */ - - sl_wifi_firmware_version_t version = { 0 }; - status = sl_wifi_get_firmware_version(&version); - if (status != SL_STATUS_OK) - { - ChipLogError(DeviceLayer, "sl_wifi_get_firmware_version failed: 0x%lx", static_cast(status)); - return status; - } - sl_print_firmware_version(&version); - - status = sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, (sl_mac_address_t *) &wfx_rsi.sta_mac.octet[0]); - if (status != SL_STATUS_OK) - { - ChipLogDetail(DeviceLayer, "sl_wifi_get_mac_address failed: 0x%lx", static_cast(status)); - return status; - } - -#ifdef SL_MBEDTLS_USE_TINYCRYPT - const uint32_t trngKey[TRNG_KEY_SIZE] = { 0x16157E2B, 0xA6D2AE28, 0x8815F7AB, 0x3C4FCF09 }; - - // To check the Entropy of TRNG and verify TRNG functioning. - status = sl_si91x_trng_entropy(); - if (status != SL_STATUS_OK) - { - ChipLogError(DeviceLayer, "sl_si91x_trng_entropy failed: 0x%lx", static_cast(status)); - return status; - } - - // Initiate and program the key required for TRNG hardware engine - status = sl_si91x_trng_program_key((uint32_t *) trngKey, TRNG_KEY_SIZE); - if (status != SL_STATUS_OK) - { - ChipLogError(DeviceLayer, "sl_si91x_trng_program_key failed: 0x%lx", static_cast(status)); - return status; - } -#endif // SL_MBEDTLS_USE_TINYCRYPT - - wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY; - osSemaphoreRelease(sl_rs_ble_init_sem); - return status; -} - -/************************************************************************************* - * @fn void wfx_show_err(char *msg) - * @brief - * driver shows error message - * @param[in] msg - * @return - * None - *****************************************************************************************/ -void wfx_show_err(char * msg) -{ - ChipLogError(DeviceLayer, "wfx_show_err: message: %s", msg); -} - -sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * scan_result, uint32_t result_length, void * arg) -{ - if (SL_WIFI_CHECK_IF_EVENT_FAILED(event)) - { - callback_status = *(sl_status_t *) scan_result; - ChipLogError(DeviceLayer, "scan_callback_handler: failed: 0x%lx", static_cast(callback_status)); - scan_results_complete = true; -#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION - wfx_rsi.sec.security = WFX_SEC_WPA3; -#else - wfx_rsi.sec.security = WFX_SEC_WPA2; -#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */ - - osSemaphoreRelease(sScanSemaphore); - return SL_STATUS_FAIL; - } - wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED; - wfx_rsi.ap_chan = scan_result->scan_info[0].rf_channel; - memcpy(&wfx_rsi.ap_mac.octet, scan_result->scan_info[0].bssid, BSSID_LEN); - switch (scan_result->scan_info[0].security_mode) - { - case SL_WIFI_OPEN: - wfx_rsi.sec.security = WFX_SEC_NONE; - break; - case SL_WIFI_WPA: - case SL_WIFI_WPA_ENTERPRISE: - wfx_rsi.sec.security = WFX_SEC_WPA; - break; - case SL_WIFI_WPA_WPA2_MIXED: - case SL_WIFI_WPA2: - case SL_WIFI_WPA2_ENTERPRISE: - wfx_rsi.sec.security = WFX_SEC_WPA2; - break; - case SL_WIFI_WEP: - wfx_rsi.sec.security = WFX_SEC_WEP; - break; - case SL_WIFI_WPA3_TRANSITION: -#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION - case SL_WIFI_WPA3: - wfx_rsi.sec.security = WFX_SEC_WPA3; -#else - wfx_rsi.sec.security = WFX_SEC_WPA2; -#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */ - break; - default: - wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED; - break; - } - wfx_rsi.dev_state &= ~WFX_RSI_ST_SCANSTARTED; - scan_results_complete = true; - - osSemaphoreRelease(sScanSemaphore); - return SL_STATUS_OK; -} - sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result) { SL_WIFI_ARGS_CHECK_NULL_POINTER(scan_result); - VerifyOrReturnError(wfx_rsi.scan_cb != NULL, SL_STATUS_INVALID_HANDLE); + VerifyOrReturnError(wfx_rsi.scan_cb != nullptr, SL_STATUS_INVALID_HANDLE); wfx_wifi_scan_result_t cur_scan_result; for (int idx = 0; idx < (int) scan_result->scan_count; idx++) @@ -541,7 +607,7 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result) chip::Platform::CopyString(cur_scan_result.ssid, cur_scan_result.ssid_length, (char *) scan_result->scan_info[idx].ssid); // if user has provided ssid, then check if the current scan result ssid matches the user provided ssid - if (wfx_rsi.scan_ssid != NULL && + if (wfx_rsi.scan_ssid != nullptr && (strncmp(wfx_rsi.scan_ssid, cur_scan_result.ssid, std::min(strlen(wfx_rsi.scan_ssid), strlen(cur_scan_result.ssid))) == CMP_SUCCESS)) { @@ -553,7 +619,7 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result) wfx_rsi.scan_cb(&cur_scan_result); // if user has not provided the ssid, then call the callback for each scan result - if (wfx_rsi.scan_ssid == NULL) + if (wfx_rsi.scan_ssid == nullptr) { continue; } @@ -567,135 +633,17 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result) if (wfx_rsi.scan_ssid) { chip::Platform::MemoryFree(wfx_rsi.scan_ssid); - wfx_rsi.scan_ssid = NULL; + wfx_rsi.scan_ssid = nullptr; } return SL_STATUS_OK; } sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * result, uint32_t result_length, void * arg) { - callback_status = show_scan_results(result); - bg_scan_results_complete = true; - osSemaphoreRelease(sScanSemaphore); + show_scan_results(result); // To do Check error + osSemaphoreRelease(sScanCompleteSemaphore); return SL_STATUS_OK; } -/*************************************************************************************** - * @fn static void wfx_rsi_save_ap_info(void) - * @brief - * Saving the details of the AP - * @param[in] None - * @return - * None - *******************************************************************************************/ -static void wfx_rsi_save_ap_info(void) // translation -{ - sl_status_t status = SL_STATUS_OK; -#ifndef EXP_BOARD - // TODO: this changes will be reverted back after the Silabs WiFi SDK team fix the scan API - sl_wifi_scan_configuration_t wifi_scan_configuration = default_wifi_scan_configuration; -#endif - sl_wifi_ssid_t ssid_arg; - memset(&ssid_arg, 0, sizeof(ssid_arg)); - ssid_arg.length = wfx_rsi.sec.ssid_length; - chip::Platform::CopyString((char *) &ssid_arg.value[0], ssid_arg.length, wfx_rsi.sec.ssid); - sl_wifi_set_scan_callback(scan_callback_handler, NULL); - scan_results_complete = false; -#ifndef EXP_BOARD - // TODO: this changes will be reverted back after the Silabs WiFi SDK team fix the scan API - status = sl_wifi_start_scan(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, &ssid_arg, &wifi_scan_configuration); -#endif - if (SL_STATUS_IN_PROGRESS == status) - { - osSemaphoreAcquire(sScanSemaphore, WIFI_SCAN_TIMEOUT_TICK); - } -} - -/******************************************************************************************** - * @fn static void wfx_rsi_do_join(void) - * @brief - * Start an async Join command - * @return - * None - **********************************************************************************************/ -static sl_status_t wfx_rsi_do_join(void) -{ - VerifyOrReturnError(!(wfx_rsi.dev_state & (WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED)), SL_STATUS_IN_PROGRESS); - sl_status_t status = SL_STATUS_OK; - sl_wifi_client_configuration_t ap; - memset(&ap, 0, sizeof(ap)); - - switch (wfx_rsi.sec.security) - { - case WFX_SEC_WEP: - ap.security = SL_WIFI_WEP; - break; - case WFX_SEC_WPA: - ap.security = SL_WIFI_WPA_WPA2_MIXED; - break; - case WFX_SEC_WPA2: -#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION - ap.security = SL_WIFI_WPA3_TRANSITION; - break; - case WFX_SEC_WPA3: - ap.security = SL_WIFI_WPA3_TRANSITION; -#else - ap.security = SL_WIFI_WPA_WPA2_MIXED; -#endif // WIFI_ENABLE_SECURITY_WPA3_TRANSITION - break; - case WFX_SEC_NONE: - ap.security = SL_WIFI_OPEN; - break; - default: - ChipLogError(DeviceLayer, "wfx_rsi_do_join: unknown security type."); - return status; - } - /* - * Join the network - */ - wfx_rsi.dev_state |= WFX_RSI_ST_STA_CONNECTING; - status = sl_wifi_set_join_callback(join_callback_handler, NULL); - VerifyOrReturnError(status == SL_STATUS_OK, status); - -#if CHIP_CONFIG_ENABLE_ICD_SERVER - // Setting the listen interval to 0 which will set it to DTIM interval - sl_wifi_listen_interval_t sleep_interval = { .listen_interval = 0 }; - status = sl_wifi_set_listen_interval(SL_WIFI_CLIENT_INTERFACE, sleep_interval); - VerifyOrReturnError(status == SL_STATUS_OK, status); - - sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 5 }; - status = sl_wifi_set_advanced_client_configuration(SL_WIFI_CLIENT_INTERFACE, &client_config); - VerifyOrReturnError(status == SL_STATUS_OK, status); -#endif // CHIP_CONFIG_ENABLE_ICD_SERVER - sl_net_credential_id_t id = SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID; - status = sl_net_set_credential(id, SL_NET_WIFI_PSK, &wfx_rsi.sec.passkey[0], wfx_rsi.sec.passkey_length); - VerifyOrReturnError(status == SL_STATUS_OK, status); - - uint32_t timeout_ms = 0; - ap.ssid.length = wfx_rsi.sec.ssid_length; - ap.encryption = SL_WIFI_NO_ENCRYPTION; - ap.credential_id = id; - memcpy((char *) &ap.ssid.value[0], wfx_rsi.sec.ssid, wfx_rsi.sec.ssid_length); - ChipLogDetail(DeviceLayer, "wfx_rsi_do_join: SSID: %s, SECURITY: %d(%d)", ap.ssid.value, ap.security, wfx_rsi.sec.security); - - status = sl_wifi_connect(SL_WIFI_CLIENT_INTERFACE, &ap, timeout_ms); - // sl_wifi_connect returns SL_STATUS_IN_PROGRESS if join is in progress - // after the initial scan is done, the scan does not check for SSID - VerifyOrReturnError(status != SL_STATUS_OK && status != SL_STATUS_IN_PROGRESS, status); - - // failure only happens when the firmware returns an error - ChipLogError(DeviceLayer, "wfx_rsi_do_join: sl_wifi_connect failed: 0x%lx", static_cast(status)); - VerifyOrReturnError((wfx_rsi.join_retries <= MAX_JOIN_RETRIES_COUNT), status); - - wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED); - ChipLogProgress(DeviceLayer, "wfx_rsi_do_join: retry attempt %d", wfx_rsi.join_retries); - wfx_retry_connection(++wfx_rsi.join_retries); - - WfxEvent_t event; - event.eventType = WFX_EVT_STA_START_JOIN; - WfxPostEvent(&event); - - return status; -} /// NotifyConnectivity /// @brief Notify the application about the connectivity status if it has not been notified yet. @@ -709,16 +657,12 @@ void NotifyConnectivity(void) void HandleDHCPPolling(void) { - struct netif * sta_netif; WfxEvent_t event; - sta_netif = wfx_get_netif(SL_WFX_STA_INTERFACE); - if (sta_netif == NULL) - { - // TODO: Notify the application that the interface is not set up or Chipdie here because we are in an unkonwn state - ChipLogError(DeviceLayer, "HandleDHCPPolling: failed to get STA netif"); - return; - } + // TODO: Notify the application that the interface is not set up or Chipdie here because we are in an unkonwn state + struct netif * sta_netif = &wifi_client_context.netif; + VerifyOrReturn(sta_netif != nullptr, ChipLogError(DeviceLayer, "HandleDHCPPolling: failed to get STA netif")); + #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4) uint8_t dhcp_state = dhcpclient_poll(sta_netif); if (dhcp_state == DHCP_ADDRESS_ASSIGNED && !hasNotifiedIPV4) @@ -726,7 +670,7 @@ void HandleDHCPPolling(void) wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr); hasNotifiedIPV4 = true; event.eventType = WFX_EVT_STA_DHCP_DONE; - WfxPostEvent(&event); + sl_matter_wifi_post_event(&event); NotifyConnectivity(); } else if (dhcp_state == DHCP_OFF) @@ -741,23 +685,21 @@ void HandleDHCPPolling(void) if ((ip6_addr_ispreferred(netif_ip6_addr_state(sta_netif, 0))) && !hasNotifiedIPV6) { char addrStr[chip::Inet::IPAddress::kMaxStringLength] = { 0 }; - VerifyOrReturn(ip6addr_ntoa_r(netif_ip6_addr(sta_netif, 0), addrStr, sizeof(addrStr)) != NULL); + VerifyOrReturn(ip6addr_ntoa_r(netif_ip6_addr(sta_netif, 0), addrStr, sizeof(addrStr)) != nullptr); ChipLogProgress(DeviceLayer, "SLAAC OK: linklocal addr: %s", addrStr); wfx_ipv6_notify(GET_IPV6_SUCCESS); hasNotifiedIPV6 = true; event.eventType = WFX_EVT_STA_DHCP_DONE; - WfxPostEvent(&event); + sl_matter_wifi_post_event(&event); NotifyConnectivity(); } } -void WfxPostEvent(WfxEvent_t * event) +void sl_matter_wifi_post_event(WfxEvent_t * event) { - sl_status_t status = osMessageQueuePut(sWifiEventQueue, event, 0, 0); - - if (status != osOK) + if (osMessageQueuePut(sWifiEventQueue, event, 0, 0) != osOK) { - ChipLogError(DeviceLayer, "WfxPostEvent: failed to post event: 0x%lx", static_cast(status)); + ChipLogError(DeviceLayer, "sl_matter_wifi_post_event: failed to post event.") // TODO: Handle error, requeue event depending on queue size or notify relevant task, Chipdie, etc. } } @@ -776,7 +718,7 @@ void ResetDHCPNotificationFlags(void) hasNotifiedWifiConnectivity = false; outEvent.eventType = WFX_EVT_STA_DO_DHCP; - WfxPostEvent(&outEvent); + sl_matter_wifi_post_event(&outEvent); } void ProcessEvent(WfxEvent_t inEvent) @@ -788,13 +730,9 @@ void ProcessEvent(WfxEvent_t inEvent) ChipLogDetail(DeviceLayer, "WFX_EVT_STA_CONN"); wfx_rsi.dev_state |= WFX_RSI_ST_STA_CONNECTED; ResetDHCPNotificationFlags(); - wfx_lwip_set_sta_link_up(); - /* We need to get AP Mac - TODO */ - // Uncomment once the hook into MATTER is moved to IP connectivty instead - // of AP connectivity. - // wfx_connected_notify(0, &wfx_rsi.ap_mac); // This - // is independant of IP connectivity. + break; + case WFX_EVT_STA_DISCONN: ChipLogDetail(DeviceLayer, "WFX_EVT_STA_DISCONN"); // TODO: This event is not being posted anywhere, seems to be a dead code or we are missing something @@ -802,20 +740,23 @@ void ProcessEvent(WfxEvent_t inEvent) ~(WFX_RSI_ST_STA_READY | WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE); /* TODO: Implement disconnect notify */ ResetDHCPNotificationFlags(); - wfx_lwip_set_sta_link_down(); // Internally dhcpclient_poll(netif) -> - // wfx_ip_changed_notify(0) for IPV4 #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4) + wfx_ip_changed_notify(0); // for IPV4 wfx_ip_changed_notify(IP_STATUS_FAIL); #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ wfx_ipv6_notify(GET_IPV6_FAIL); break; + case WFX_EVT_AP_START: // TODO: Currently unimplemented break; case WFX_EVT_AP_STOP: // TODO: Currently unimplemented break; + case WFX_EVT_SCAN: + ChipLogDetail(DeviceLayer, "WFX_EVT_SCAN"); + #ifdef SL_WFX_CONFIG_SCAN if (!(wfx_rsi.dev_state & WFX_RSI_ST_SCANSTARTED)) { @@ -826,11 +767,11 @@ void ProcessEvent(WfxEvent_t inEvent) // TODO: Add scan logic sl_wifi_advanced_scan_configuration_t advanced_scan_configuration = { 0 }; int32_t status; - advanced_scan_configuration.active_channel_time = ADV_ACTIVE_SCAN_DURATION; - advanced_scan_configuration.passive_channel_time = ADV_PASSIVE_SCAN_DURATION; - advanced_scan_configuration.trigger_level = ADV_SCAN_THRESHOLD; - advanced_scan_configuration.trigger_level_change = ADV_RSSI_TOLERANCE_THRESHOLD; - advanced_scan_configuration.enable_multi_probe = ADV_MULTIPROBE; + advanced_scan_configuration.active_channel_time = kAdvActiveScanDuration; + advanced_scan_configuration.passive_channel_time = kAdvPassiveScanDuration; + advanced_scan_configuration.trigger_level = kAdvScanThreshold; + advanced_scan_configuration.trigger_level_change = kAdvRssiToleranceThreshold; + advanced_scan_configuration.enable_multi_probe = kAdvMultiProbe; status = sl_wifi_set_advanced_scan_configuration(&advanced_scan_configuration); if (SL_STATUS_OK != status) { @@ -843,44 +784,88 @@ void ProcessEvent(WfxEvent_t inEvent) { /* Terminate with end of scan which is no ap sent back */ wifi_scan_configuration.type = SL_WIFI_SCAN_TYPE_ADV_SCAN; - wifi_scan_configuration.periodic_scan_interval = ADV_SCAN_PERIODICITY; + wifi_scan_configuration.periodic_scan_interval = kAdvScanPeriodicity; } else { wifi_scan_configuration = default_wifi_scan_configuration; } - sl_wifi_set_scan_callback(bg_scan_callback_handler, NULL); - scan_results_complete = false; + sl_wifi_set_scan_callback(bg_scan_callback_handler, nullptr); wfx_rsi.dev_state |= WFX_RSI_ST_SCANSTARTED; - status = sl_wifi_start_scan(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, NULL, &wifi_scan_configuration); + + osSemaphoreAcquire(sScanInProgressSemaphore, osWaitForever); + status = sl_wifi_start_scan(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, nullptr, &wifi_scan_configuration); if (SL_STATUS_IN_PROGRESS == status) { - osSemaphoreAcquire(sScanSemaphore, WIFI_SCAN_TIMEOUT_TICK); + osSemaphoreAcquire(sScanCompleteSemaphore, kWifiScanTimeoutTicks); + } + else + { + osSemaphoreRelease(sScanInProgressSemaphore); } } break; #endif /* SL_WFX_CONFIG_SCAN */ case WFX_EVT_STA_START_JOIN: - // saving the AP related info - wfx_rsi_save_ap_info(); + ChipLogDetail(DeviceLayer, "WFX_EVT_STA_START_JOIN"); + + // Trigger Netwrok scan + InitiateScan(); + // Joining to the network - wfx_rsi_do_join(); + JoinWifiNetwork(); break; + case WFX_EVT_STA_DO_DHCP: + ChipLogDetail(DeviceLayer, "WFX_EVT_STA_DO_DHCP"); StartDHCPTimer(WFX_RSI_DHCP_POLL_INTERVAL); break; case WFX_EVT_STA_DHCP_DONE: + ChipLogDetail(DeviceLayer, "WFX_EVT_STA_DHCP_DONE"); CancelDHCPTimer(); break; case WFX_EVT_DHCP_POLL: + ChipLogDetail(DeviceLayer, "WFX_EVT_DHCP_POLL"); HandleDHCPPolling(); default: break; } } +/** + * @brief Wifi initialization called from app main + * + * @return sl_status_t Returns underlying Wi-Fi initialization error + */ +sl_status_t sl_matter_wifi_platform_init(void) +{ + sl_status_t status = SL_STATUS_OK; + + status = sl_net_init((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE, &config, &wifi_client_context, nullptr); + VerifyOrReturnError(status == SL_STATUS_OK, status, ChipLogError(DeviceLayer, "sl_net_init failed: %lx", status)); + + // Create Sempaphore for scan completion + sScanCompleteSemaphore = osSemaphoreNew(1, 0, nullptr); + VerifyOrReturnError(sScanCompleteSemaphore != nullptr, SL_STATUS_ALLOCATION_FAILED); + + // Create Semaphore for scan in-progress protection + sScanInProgressSemaphore = osSemaphoreNew(1, 1, nullptr); + VerifyOrReturnError(sScanCompleteSemaphore != nullptr, SL_STATUS_ALLOCATION_FAILED); + + // Create the message queue + sWifiEventQueue = osMessageQueueNew(kWfxQueueSize, sizeof(WfxEvent_t), nullptr); + VerifyOrReturnError(sWifiEventQueue != nullptr, SL_STATUS_ALLOCATION_FAILED); + + // Create timer for DHCP polling + // TODO: Use LWIP timer instead of creating a new one here + sDHCPTimer = osTimerNew(DHCPTimerEventHandler, osTimerPeriodic, nullptr, nullptr); + VerifyOrReturnError(sDHCPTimer != nullptr, SL_STATUS_ALLOCATION_FAILED); + + return status; +} + /********************************************************************************* - * @fn void wfx_rsi_task(void *arg) + * @fn void sl_matter_wifi_task(void *arg) * @brief * The main WLAN task - started by wfx_wifi_start() that interfaces with RSI. * The rest of RSI stuff come in call-backs. @@ -890,31 +875,29 @@ void ProcessEvent(WfxEvent_t inEvent) * None **********************************************************************************/ /* ARGSUSED */ -void wfx_rsi_task(void * arg) +void sl_matter_wifi_task(void * arg) { (void) arg; - sl_status_t status = wfx_rsi_init(); - WfxEvent_t wfxEvent; - if (status != RSI_SUCCESS) - { - ChipLogError(DeviceLayer, "wfx_rsi_task: wfx_rsi_init failed: 0x%lx", static_cast(status)); - return; - } - wfx_lwip_start(); - wfx_started_notify(); + sl_status_t status = SL_STATUS_OK; + + status = sl_wifi_siwx917_init(); + VerifyOrReturn( + status == SL_STATUS_OK, + ChipLogError(DeviceLayer, "sl_matter_wifi_task: sl_wifi_siwx917_init failed: 0x%lx", static_cast(status))); + + sl_matter_wifi_task_started(); - ChipLogDetail(DeviceLayer, "wfx_rsi_task: starting event loop"); + ChipLogDetail(DeviceLayer, "sl_matter_wifi_task: starting event loop"); for (;;) { - status = osMessageQueueGet(sWifiEventQueue, &wfxEvent, NULL, osWaitForever); - if (status == osOK) + if (osMessageQueueGet(sWifiEventQueue, &wfxEvent, nullptr, osWaitForever) == osOK) { ProcessEvent(wfxEvent); } else { - ChipLogError(DeviceLayer, "wfx_rsi_task: get event failed: 0x%lx", static_cast(status)); + ChipLogError(DeviceLayer, "sl_matter_wifi_task: get event failed: 0x%lx", static_cast(status)); } } } diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index 2d417c22c1a641..9e6b700cfde727 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -18,8 +18,8 @@ import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/app/icd/icd.gni") import("${chip_root}/src/lib/lib.gni") import("${chip_root}/src/platform/device.gni") -import("${efr32_sdk_build_root}/efr32_sdk.gni") -import("${efr32_sdk_build_root}/silabs_board.gni") +import("${silabs_sdk_build_root}/efr32_sdk.gni") +import("${silabs_sdk_build_root}/silabs_board.gni") declare_args() { enable_heap_monitoring = false @@ -111,10 +111,10 @@ source_set("openthread_core_config_efr32_chip_examples") { if (chip_enable_openthread) { sources = [ "project_include/OpenThreadConfig.h" ] - public_deps = [ "${efr32_sdk_build_root}:efr32_sdk" ] + public_deps = [ "${silabs_sdk_build_root}:silabs_sdk" ] if (use_silabs_thread_lib) { - public_deps += [ "${efr32_sdk_build_root}:openthread_core_config_efr32" ] + public_deps += [ "${silabs_sdk_build_root}:openthread_core_config_efr32" ] } else { public_deps += [ "${chip_root}/third_party/openthread/platforms/efr32:openthread_core_config_efr32" ] } @@ -207,7 +207,7 @@ source_set("efr32-common") { public_deps = [] public_configs = [ ":efr32-common-config", - "${efr32_sdk_build_root}:silabs_config", + "${silabs_sdk_build_root}:silabs_config", ":chip_examples_project_config", ] diff --git a/examples/platform/silabs/efr32/rs911x/rs9117.gni b/examples/platform/silabs/efr32/rs911x/rs9117.gni index cff3e3da1fea8c..1adf21a6168d58 100644 --- a/examples/platform/silabs/efr32/rs911x/rs9117.gni +++ b/examples/platform/silabs/efr32/rs911x/rs9117.gni @@ -1,9 +1,9 @@ import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") -import("${efr32_sdk_build_root}/efr32_sdk.gni") +import("${silabs_sdk_build_root}/efr32_sdk.gni") rs911x_src_plat = [ - "${examples_plat_dir}/rs911x/sl_wifi_if.cpp", + "${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", @@ -30,6 +30,9 @@ rs9117_src_sapi = [ "${wifi_sdk_root}/components/device/silabs/si91x/wireless/ncp_interface/spi/sl_si91x_spi.c", "${wifi_sdk_root}/components/device/silabs/si91x/wireless/ncp_interface/sl_si91x_ncp_driver.c", + # 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", + # wifi component "${wifi_sdk_root}/components/protocol/wifi/src/sl_wifi_callback_framework.c", "${wifi_sdk_root}/components/protocol/wifi/si91x/sl_wifi.c", diff --git a/examples/platform/silabs/efr32/rs911x/rs911x.gni b/examples/platform/silabs/efr32/rs911x/rs911x.gni index b25fbefc8e43b6..c2a20607cc67bd 100644 --- a/examples/platform/silabs/efr32/rs911x/rs911x.gni +++ b/examples/platform/silabs/efr32/rs911x/rs911x.gni @@ -1,6 +1,6 @@ import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") -import("${efr32_sdk_build_root}/efr32_sdk.gni") +import("${silabs_sdk_build_root}/efr32_sdk.gni") rs911x_src_plat = [ "${examples_plat_dir}/rs911x/rsi_if.cpp", diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.cpp b/examples/platform/silabs/efr32/rs911x/rsi_if.cpp index 78d13498efa5ab..7c727e013e235c 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.cpp +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.cpp @@ -50,6 +50,7 @@ extern "C" { #endif #include "dhcp_client.h" +#include "ethernetif.h" #include "lwip/nd6.h" #include "silabs_utils.h" #include "wfx_rsi.h" @@ -109,7 +110,7 @@ static void DHCPTimerEventHandler(void * arg) { WfxEvent_t event; event.eventType = WFX_EVT_DHCP_POLL; - WfxPostEvent(&event); + sl_matter_wifi_post_event(&event); } static void CancelDHCPTimer(void) @@ -226,14 +227,14 @@ int32_t wfx_rsi_reset_count(void) } /****************************************************************** - * @fn wfx_rsi_disconnect(void) + * @fn sl_wifi_platform_disconnect(void) * @brief * Getting the driver disconnect status * @param[in] None * @return * status *********************************************************************/ -int32_t wfx_rsi_disconnect(void) +int32_t sl_wifi_platform_disconnect(void) { return rsi_wlan_disconnect(); } @@ -301,7 +302,7 @@ static void wfx_rsi_join_cb(uint16_t status, const uint8_t * buf, const uint16_t ChipLogProgress(DeviceLayer, "wfx_rsi_join_cb: success"); memset(&temp_reset, 0, sizeof(wfx_wifi_scan_ext_t)); WfxEvent.eventType = WFX_EVT_STA_CONN; - WfxPostEvent(&WfxEvent); + sl_matter_wifi_post_event(&WfxEvent); wfx_rsi.join_retries = 0; } @@ -322,7 +323,7 @@ static void wfx_rsi_join_fail_cb(uint16_t status, uint8_t * buf, uint32_t len) wfx_rsi.join_retries += 1; wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED); WfxEvent.eventType = WFX_EVT_STA_START_JOIN; - WfxPostEvent(&WfxEvent); + sl_matter_wifi_post_event(&WfxEvent); } /************************************************************************************* * @fn wfx_rsi_wlan_pkt_cb(uint16_t status, uint8_t *buf, uint32_t len) @@ -344,31 +345,30 @@ static void wfx_rsi_wlan_pkt_cb(uint16_t status, uint8_t * buf, uint32_t len) } /************************************************************************************* - * @fn static int32_t wfx_rsi_init(void) + * @fn static int32_t sl_matter_wifi_init(void) * @brief * driver initialization * @param[in] None * @return * None *****************************************************************************************/ -static int32_t wfx_rsi_init(void) +static int32_t sl_matter_wifi_init(void) { int32_t status; uint8_t buf[RSI_RESPONSE_HOLD_BUFF_SIZE]; extern void rsi_hal_board_init(void); - ChipLogProgress(DeviceLayer, "wfx_rsi_init: starting(HEAP_SZ = %d)", SL_HEAP_SIZE); //! Driver initialization status = rsi_driver_init(wfx_rsi_drv_buf, WFX_RSI_BUF_SZ); if ((status < RSI_DRIVER_STATUS) || (status > WFX_RSI_BUF_SZ)) { - ChipLogError(DeviceLayer, "wfx_rsi_init: rsi_driver_init failed: %ld", status); + ChipLogError(DeviceLayer, "rsi_driver_init failed: %ld", status); return status; } /* ! Redpine module intialisation */ if ((status = rsi_device_init(LOAD_NWP_FW)) != RSI_SUCCESS) { - ChipLogError(DeviceLayer, "wfx_rsi_init: rsi_device_init failed: %ld", status); + ChipLogError(DeviceLayer, "rsi_device_init failed: %ld", status); return status; } /* @@ -377,7 +377,7 @@ static int32_t wfx_rsi_init(void) sDrvThread = osThreadNew(rsi_wireless_driver_task_wrapper, NULL, &kDrvTaskAttr); if (NULL == sDrvThread) { - ChipLogError(DeviceLayer, "wfx_rsi_init: failed to create task"); + ChipLogError(DeviceLayer, "failed to create task"); return RSI_ERROR_INVALID_PARAM; } @@ -388,7 +388,7 @@ static int32_t wfx_rsi_init(void) if ((status = rsi_wireless_init(OPER_MODE_0, COEX_MODE_0)) != RSI_SUCCESS) { #endif - ChipLogError(DeviceLayer, "wfx_rsi_init: rsi_wireless_init failed: %ld", status); + ChipLogError(DeviceLayer, "rsi_wireless_init failed: %ld", status); return status; } @@ -397,7 +397,7 @@ static int32_t wfx_rsi_init(void) */ if (rsi_wlan_get(RSI_FW_VERSION, buf, sizeof(buf)) != RSI_SUCCESS) { - ChipLogError(DeviceLayer, "wfx_rsi_init: rsi_wlan_get(RSI_FW_VERSION) failed: %ld", status); + ChipLogError(DeviceLayer, "rsi_wlan_get(RSI_FW_VERSION) failed: %ld", status); return status; } @@ -415,13 +415,12 @@ static int32_t wfx_rsi_init(void) (void) rsi_wlan_radio_init(); /* Required so we can get MAC address */ if ((status = rsi_wlan_get(RSI_MAC_ADDRESS, &wfx_rsi.sta_mac.octet[0], RESP_BUFF_SIZE)) != RSI_SUCCESS) { - ChipLogError(DeviceLayer, "wfx_rsi_init: rsi_wlan_get(RSI_MAC_ADDRESS) failed: %ld", status); + ChipLogError(DeviceLayer, "rsi_wlan_get(RSI_MAC_ADDRESS) failed: %ld", status); return status; } - ChipLogDetail(DeviceLayer, "wfx_rsi_init: MAC: %02x:%02x:%02x %02x:%02x:%02x", wfx_rsi.sta_mac.octet[0], - wfx_rsi.sta_mac.octet[1], wfx_rsi.sta_mac.octet[2], wfx_rsi.sta_mac.octet[3], wfx_rsi.sta_mac.octet[4], - wfx_rsi.sta_mac.octet[5]); + ChipLogDetail(DeviceLayer, "MAC: %02x:%02x:%02x %02x:%02x:%02x", wfx_rsi.sta_mac.octet[0], wfx_rsi.sta_mac.octet[1], + wfx_rsi.sta_mac.octet[2], wfx_rsi.sta_mac.octet[3], wfx_rsi.sta_mac.octet[4], wfx_rsi.sta_mac.octet[5]); // Create the message queue sWifiEventQueue = osMessageQueueNew(WFX_QUEUE_SIZE, sizeof(WfxEvent_t), NULL); @@ -443,12 +442,12 @@ static int32_t wfx_rsi_init(void) */ if ((status = rsi_wlan_register_callbacks(RSI_JOIN_FAIL_CB, wfx_rsi_join_fail_cb)) != RSI_SUCCESS) { - ChipLogError(DeviceLayer, "wfx_rsi_init: rsi_wlan_register_callbacks failed: %ld", status); + ChipLogError(DeviceLayer, "rsi_wlan_register_callbacks failed: %ld", status); return status; } if ((status = rsi_wlan_register_callbacks(RSI_WLAN_DATA_RECEIVE_NOTIFY_CB, wfx_rsi_wlan_pkt_cb)) != RSI_SUCCESS) { - ChipLogError(DeviceLayer, "wfx_rsi_init: rsi_wlan_register_callbacks failed: %ld", status); + ChipLogError(DeviceLayer, "rsi_wlan_register_callbacks failed: %ld", status); return status; } @@ -457,7 +456,6 @@ static int32_t wfx_rsi_init(void) #endif wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY; - ChipLogProgress(DeviceLayer, "wfx_rsi_init: success"); return RSI_SUCCESS; } @@ -530,20 +528,20 @@ static void wfx_rsi_save_ap_info(void) // translation } /******************************************************************************************** - * @fn static void wfx_rsi_do_join(void) + * @fn static void sl_wifi_platform_join_network(void) * @brief * Start an async Join command * @return * None **********************************************************************************************/ -static void wfx_rsi_do_join(void) +static void sl_wifi_platform_join_network(void) { - int32_t status; + int32_t status = SL_STATUS_OK; rsi_security_mode_t connect_security_mode; if (wfx_rsi.dev_state & (WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED)) { - ChipLogProgress(DeviceLayer, "wfx_rsi_do_join: already in progress"); + ChipLogProgress(DeviceLayer, "sl_wifi_platform_join_network: already in progress"); return; } @@ -566,11 +564,12 @@ static void wfx_rsi_do_join(void) connect_security_mode = RSI_OPEN; break; default: - ChipLogError(DeviceLayer, "wfx_rsi_do_join: error: unknown security type."); + ChipLogError(DeviceLayer, "sl_wifi_platform_join_network: error: unknown security type."); return; } - ChipLogProgress(DeviceLayer, "wfx_rsi_do_join: connecting to %s, sec=%d", &wfx_rsi.sec.ssid[0], wfx_rsi.sec.security); + ChipLogProgress(DeviceLayer, "sl_wifi_platform_join_network: connecting to %s, sec=%d", &wfx_rsi.sec.ssid[0], + wfx_rsi.sec.security); /* * Join the network @@ -582,7 +581,7 @@ static void wfx_rsi_do_join(void) if ((status = rsi_wlan_register_callbacks(RSI_JOIN_FAIL_CB, wfx_rsi_join_fail_cb)) != RSI_SUCCESS) { - ChipLogError(DeviceLayer, "wfx_rsi_do_join: rsi_wlan_register_callbacks failed: %ld", status); + ChipLogError(DeviceLayer, "sl_wifi_platform_join_network: rsi_wlan_register_callbacks failed: %ld", status); } /* Try to connect Wifi with given Credentials @@ -592,7 +591,8 @@ static void wfx_rsi_do_join(void) wfx_rsi_join_cb)) != RSI_SUCCESS) { wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_CONNECTING; - ChipLogProgress(DeviceLayer, "wfx_rsi_do_join: rsi_wlan_connect_async failed: %ld on try %d", status, wfx_rsi.join_retries); + ChipLogProgress(DeviceLayer, "sl_wifi_platform_join_network: rsi_wlan_connect_async failed: %ld on try %d", status, + wfx_rsi.join_retries); wfx_retry_connection(++wfx_rsi.join_retries); } } @@ -645,7 +645,7 @@ void HandleDHCPPolling(void) wfx_ipv6_notify(GET_IPV6_SUCCESS); hasNotifiedIPV6 = true; event.eventType = WFX_EVT_STA_DHCP_DONE; - WfxPostEvent(&event); + sl_matter_wifi_post_event(&event); NotifyConnectivity(); } } @@ -665,19 +665,16 @@ void ResetDHCPNotificationFlags(void) hasNotifiedWifiConnectivity = false; outEvent.eventType = WFX_EVT_STA_DO_DHCP; - WfxPostEvent(&outEvent); + sl_matter_wifi_post_event(&outEvent); } -/** - * @brief Post the WfxEvent to tue WiFiEventQueue to be process by the wfx_rsi_task - */ -void WfxPostEvent(WfxEvent_t * event) +void sl_matter_wifi_post_event(WfxEvent_t * event) { sl_status_t status = osMessageQueuePut(sWifiEventQueue, event, 0, 0); if (status != osOK) { - ChipLogError(DeviceLayer, "WfxPostEvent: failed to post event with status: %ld", status); + ChipLogError(DeviceLayer, "sl_matter_wifi_post_event: failed to post event with status: %ld", status); // TODO: Handle error, requeue event depending on queue size or notify relevant task, // Chipdie, etc. } @@ -798,7 +795,7 @@ void ProcessEvent(WfxEvent_t inEvent) // saving the AP related info wfx_rsi_save_ap_info(); // Joining to the network - wfx_rsi_do_join(); + sl_wifi_platform_join_network(); } break; case WFX_EVT_STA_DO_DHCP: { @@ -819,7 +816,7 @@ void ProcessEvent(WfxEvent_t inEvent) } /********************************************************************************* - * @fn void wfx_rsi_task(void *arg) + * @fn void sl_matter_wifi_task(void *arg) * @brief * The main WLAN task - started by wfx_wifi_start () that interfaces with RSI. * The rest of RSI stuff come in call-backs. @@ -829,20 +826,20 @@ void ProcessEvent(WfxEvent_t inEvent) * None **********************************************************************************/ /* ARGSUSED */ -void wfx_rsi_task(void * arg) +void sl_matter_wifi_task(void * arg) { (void) arg; - uint32_t rsi_status = wfx_rsi_init(); + uint32_t rsi_status = sl_matter_wifi_init(); if (rsi_status != RSI_SUCCESS) { - ChipLogError(DeviceLayer, "wfx_rsi_task: wfx_rsi_init failed: %ld", rsi_status); + ChipLogError(DeviceLayer, "sl_matter_wifi_task: sl_matter_wifi_init failed: %ld", rsi_status); return; } WfxEvent_t wfxEvent; - wfx_lwip_start(); - wfx_started_notify(); + sl_matter_lwip_start(); + sl_matter_wifi_task_started(); - ChipLogProgress(DeviceLayer, "wfx_rsi_task: starting event loop"); + ChipLogProgress(DeviceLayer, "sl_matter_wifi_task: starting event loop"); for (;;) { osStatus_t status = osMessageQueueGet(sWifiEventQueue, &wfxEvent, NULL, osWaitForever); @@ -852,7 +849,7 @@ void wfx_rsi_task(void * arg) } else { - ChipLogProgress(DeviceLayer, "wfx_rsi_task: get event failed: %x", status); + ChipLogProgress(DeviceLayer, "sl_matter_wifi_task: get event failed: %x", status); } } } diff --git a/examples/platform/silabs/efr32/rs911x/sl_wifi_if.cpp b/examples/platform/silabs/efr32/rs911x/sl_wifi_if.cpp deleted file mode 120000 index 2f233ccc6cdbe0..00000000000000 --- a/examples/platform/silabs/efr32/rs911x/sl_wifi_if.cpp +++ /dev/null @@ -1 +0,0 @@ -../../SiWx917/SiWx917/sl_wifi_if.cpp \ No newline at end of file diff --git a/examples/platform/silabs/efr32/rs911x/sl_wlan_config.h b/examples/platform/silabs/efr32/rs911x/sl_wlan_config.h deleted file mode 100644 index 2ce2060cd7deeb..00000000000000 --- a/examples/platform/silabs/efr32/rs911x/sl_wlan_config.h +++ /dev/null @@ -1,109 +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 RSI_CONFIG_H -#define RSI_CONFIG_H - -#include "ble_config.h" -#include "sl_wifi_device.h" - -//! Enable feature -#define RSI_ENABLE 1 -//! Disable feature -#define RSI_DISABLE 0 - -static const sl_wifi_device_configuration_t config = { - .boot_option = LOAD_NWP_FW, - .mac_address = NULL, - .band = SL_SI91X_WIFI_BAND_2_4GHZ, - .region_code = US, - .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, - .coex_mode = SL_SI91X_WLAN_BLE_MODE, - .feature_bit_map = -#ifdef SLI_SI91X_MCU_INTERFACE - (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE), -#else - (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION), -#endif - .tcp_ip_feature_bit_map = (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT | - SL_SI91X_TCP_IP_FEAT_SSL | SL_SI91X_TCP_IP_FEAT_BYPASS -#ifdef ipv6_FEATURE_REQUIRED - | SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT | SL_SI91X_TCP_IP_FEAT_IPV6 -#endif - | SL_SI91X_TCP_IP_FEAT_ICMP | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID), - .custom_feature_bit_map = (SL_SI91X_CUSTOM_FEAT_EXTENTION_VALID | RSI_CUSTOM_FEATURE_BIT_MAP), - .ext_custom_feature_bit_map = ( -#ifdef SLI_SI917 - (RSI_EXT_CUSTOM_FEATURE_BIT_MAP) -#else // defaults -#ifdef SLI_SI91X_MCU_INTERFACE - (SL_SI91X_EXT_FEAT_256K_MODE | RSI_EXT_CUSTOM_FEATURE_BIT_MAP) -#else - (SL_SI91X_EXT_FEAT_384K_MODE | RSI_EXT_CUSTOM_FEATURE_BIT_MAP) -#endif -#endif - | (SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE) -#if (defined A2DP_POWER_SAVE_ENABLE) - | SL_SI91X_EXT_FEAT_XTAL_CLK_ENABLE(2) -#endif - ), - .bt_feature_bit_map = (RSI_BT_FEATURE_BITMAP -#if (RSI_BT_GATT_ON_CLASSIC) - | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ -#endif - ), -#ifdef RSI_PROCESS_MAX_RX_DATA - .ext_tcp_ip_feature_bit_map = - (RSI_EXT_TCPIP_FEATURE_BITMAP | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID | SL_SI91X_EXT_TCP_MAX_RECV_LENGTH), -#else - .ext_tcp_ip_feature_bit_map = (RSI_EXT_TCPIP_FEATURE_BITMAP | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), -#endif - //! ENABLE_BLE_PROTOCOL in bt_feature_bit_map - .ble_feature_bit_map = - ((SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) | - SL_SI91X_BLE_MAX_NBR_CENTRALS(RSI_BLE_MAX_NBR_CENTRALS) | - SL_SI91X_BLE_MAX_NBR_ATT_SERV(RSI_BLE_MAX_NBR_ATT_SERV) | - SL_SI91X_BLE_MAX_NBR_ATT_REC(RSI_BLE_MAX_NBR_ATT_REC)) | - SL_SI91X_FEAT_BLE_CUSTOM_FEAT_EXTENTION_VALID | SL_SI91X_BLE_PWR_INX(RSI_BLE_PWR_INX) | - SL_SI91X_BLE_PWR_SAVE_OPTIONS(RSI_BLE_PWR_SAVE_OPTIONS) | SL_SI91X_916_BLE_COMPATIBLE_FEAT_ENABLE -#if RSI_BLE_GATT_ASYNC_ENABLE - | SL_SI91X_BLE_GATT_ASYNC_ENABLE -#endif - ), - - .ble_ext_feature_bit_map = ((SL_SI91X_BLE_NUM_CONN_EVENTS(RSI_BLE_NUM_CONN_EVENTS) | - SL_SI91X_BLE_NUM_REC_BYTES(RSI_BLE_NUM_REC_BYTES)) -#if RSI_BLE_INDICATE_CONFIRMATION_FROM_HOST - | SL_SI91X_BLE_INDICATE_CONFIRMATION_FROM_HOST // indication response from app -#endif -#if RSI_BLE_MTU_EXCHANGE_FROM_HOST - | SL_SI91X_BLE_MTU_EXCHANGE_FROM_HOST // MTU Exchange request initiation from app -#endif -#if RSI_BLE_SET_SCAN_RESP_DATA_FROM_HOST - | (SL_SI91X_BLE_SET_SCAN_RESP_DATA_FROM_HOST) // Set SCAN Resp Data from app -#endif -#if RSI_BLE_DISABLE_CODED_PHY_FROM_HOST - | (SL_SI91X_BLE_DISABLE_CODED_PHY_FROM_HOST) // Disable Coded PHY from app -#endif -#if BLE_SIMPLE_GATT - | SL_SI91X_BLE_GATT_INIT -#endif - ), - .config_feature_bit_map = (SL_SI91X_FEAT_SLEEP_GPIO_SEL_BITMAP | RSI_CONFIG_FEATURE_BITMAP) } -}; - -#endif diff --git a/examples/platform/silabs/efr32/wf200/host_if.cpp b/examples/platform/silabs/efr32/wf200/host_if.cpp index 516abca22b98e6..e38f4c43a27e67 100644 --- a/examples/platform/silabs/efr32/wf200/host_if.cpp +++ b/examples/platform/silabs/efr32/wf200/host_if.cpp @@ -28,8 +28,6 @@ #include "em_usart.h" #include "gpiointerrupt.h" -#include "wifi_config.h" - #include "AppConfig.h" #include "sl_wfx_board.h" #include "sl_wfx_host.h" @@ -715,8 +713,8 @@ static void wfx_wifi_hw_start(void) { /* Initialize the LwIP stack */ ChipLogDetail(DeviceLayer, "WF200:Start LWIP"); - wfx_lwip_start(); - wfx_started_notify(); + sl_matter_lwip_start(); + sl_matter_wifi_task_started(); wifiContext.state = SL_WFX_STARTED; /* Really this is a bit mask */ ChipLogDetail(DeviceLayer, "WF200:ready.."); } @@ -1071,7 +1069,7 @@ bool wfx_have_ipv6_addr(sl_wfx_interface_t which_if) * @returns Returns SL_STATUS_OK if successful, * SL_STATUS_FAIL otherwise *****************************************************************************/ -sl_status_t wfx_sta_discon(void) +sl_status_t sl_matter_wifi_disconnect(void) { ChipLogProgress(DeviceLayer, "STA-Disconnecting"); int32_t status = sl_wfx_send_disconnect_command(); diff --git a/examples/platform/silabs/efr32/wf200/wf200.gni b/examples/platform/silabs/efr32/wf200/wf200.gni index 307b6815374c38..f904f74495c632 100644 --- a/examples/platform/silabs/efr32/wf200/wf200.gni +++ b/examples/platform/silabs/efr32/wf200/wf200.gni @@ -1,6 +1,6 @@ import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") -import("${efr32_sdk_build_root}/efr32_sdk.gni") +import("${silabs_sdk_build_root}/efr32_sdk.gni") wf200_plat_incs = [ "${examples_plat_dir}/wf200" ] wf200_plat_src = [ diff --git a/examples/platform/silabs/provision/BUILD.gn b/examples/platform/silabs/provision/BUILD.gn index f9e056f5ffa8a2..517dd33c124e47 100644 --- a/examples/platform/silabs/provision/BUILD.gn +++ b/examples/platform/silabs/provision/BUILD.gn @@ -14,12 +14,12 @@ import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") -import("${efr32_sdk_build_root}/silabs_board.gni") +import("${silabs_sdk_build_root}/silabs_board.gni") if (wifi_soc) { - import("${efr32_sdk_build_root}/SiWx917_sdk.gni") + import("${silabs_sdk_build_root}/SiWx917_sdk.gni") } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") } source_set("storage") { diff --git a/examples/platform/silabs/wfx_rsi.h b/examples/platform/silabs/wfx_rsi.h index 0e62cb78029a79..4ef6bd224fdfb5 100644 --- a/examples/platform/silabs/wfx_rsi.h +++ b/examples/platform/silabs/wfx_rsi.h @@ -91,19 +91,24 @@ typedef struct wfx_rsi_s extern WfxRsi_t wfx_rsi; -#ifdef __cplusplus -extern "C" { -#endif -void wfx_rsidev_init(void); -void wfx_rsi_task(void * arg); +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 wfx_rsi_disconnect(); -int32_t wfx_wifi_rsi_init(void); +int32_t sl_wifi_platform_disconnect(); + +// TODO : this needs to be extern otherwise we get a linking error. We need to figure out why in the header clean up +// NCP files are including this while being c files +#ifdef __cplusplus +extern "C" { +#endif +sl_status_t sl_matter_wifi_platform_init(void); + #if CHIP_CONFIG_ENABLE_ICD_SERVER #if SLI_SI91X_MCU_INTERFACE void sl_si91x_invoke_btn_press_event(); @@ -114,11 +119,14 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_ int32_t wfx_rsi_power_save(); #endif /* SLI_SI917 */ #endif /* SL_ICD_ENABLED */ - -/// WfxPostEvent -/// @brief Allows to allocate an event to the WFX task event queue from outside of sl_wifi_if.c -/// @param event The event that will be allocated to the event queue -void WfxPostEvent(WfxEvent_t * event); #ifdef __cplusplus } #endif + +/** + * @brief Posts an event to the Wi-Fi task + * + * @param[in] event Event to process. Must be valid ptr + */ +// TODO: Can't be a const & since the ncp builds are still using c files +void sl_matter_wifi_post_event(WfxEvent_t * event); diff --git a/examples/platform/silabs/wifi/wfx_notify.cpp b/examples/platform/silabs/wifi/wfx_notify.cpp index de1becacb33b30..fe097a60983e7f 100644 --- a/examples/platform/silabs/wifi/wfx_notify.cpp +++ b/examples/platform/silabs/wifi/wfx_notify.cpp @@ -60,13 +60,13 @@ static void RetryConnectionTimerHandler(void * arg) } } /*********************************************************************************** - * @fn wfx_started_notify(void) + * @fn sl_matter_wifi_task_started(void) * @brief * Wifi device started notification * @param[in]: None * @return None *************************************************************************************/ -void wfx_started_notify(void) +void sl_matter_wifi_task_started(void) { sl_wfx_startup_ind_t evt; sl_wfx_mac_address_t mac; diff --git a/examples/platform/silabs/wifi/wfx_rsi_host.cpp b/examples/platform/silabs/wifi/wfx_rsi_host.cpp index d76bc9c7959c8b..026cd9936ef591 100644 --- a/examples/platform/silabs/wifi/wfx_rsi_host.cpp +++ b/examples/platform/silabs/wifi/wfx_rsi_host.cpp @@ -15,6 +15,8 @@ * limitations under the License. */ +// MATTER INTERFACE + #include #include #include @@ -62,11 +64,11 @@ sl_status_t wfx_wifi_start(void) wfx_rsi.dev_state |= WFX_RSI_ST_STARTED; // Creating a Wi-Fi driver thread - sWlanThread = osThreadNew(wfx_rsi_task, NULL, &kWlanTaskAttr); + sWlanThread = osThreadNew(sl_matter_wifi_task, NULL, &kWlanTaskAttr); VerifyOrReturnError(sWlanThread != NULL, SL_STATUS_FAIL); - ChipLogProgress(DeviceLayer, "wfx_rsi_task created successfully"); + ChipLogProgress(DeviceLayer, "sl_matter_wifi_task created successfully"); return SL_STATUS_OK; } @@ -175,7 +177,7 @@ sl_status_t wfx_connect_to_ap(void) ChipLogProgress(DeviceLayer, "connect to access point: %s", wfx_rsi.sec.ssid); WfxEvent_t event; event.eventType = WFX_EVT_STA_START_JOIN; - WfxPostEvent(&event); + sl_matter_wifi_post_event(&event); return SL_STATUS_OK; } @@ -221,7 +223,7 @@ sl_status_t wfx_power_save(void) void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif) { /* - * TODO: Implement IPV6 setup, currently in wfx_rsi_task() + * TODO: Implement IPV6 setup, currently in sl_matter_wifi_task() * This is hooked with MATTER code. */ } @@ -256,17 +258,17 @@ wifi_mode_t wfx_get_wifi_mode(void) } /********************************************************************* - * @fn sl_status_t wfx_sta_discon(void) + * @fn sl_status_t sl_matter_wifi_disconnect(void) * @brief * called fuction when STA disconnected * @param[in] None * @return return SL_STATUS_OK if successful, * SL_STATUS_FAIL otherwise ***********************************************************************/ -sl_status_t wfx_sta_discon(void) +sl_status_t sl_matter_wifi_disconnect(void) { sl_status_t status; - status = wfx_rsi_disconnect(); + status = sl_wifi_platform_disconnect(); wfx_rsi.dev_state &= ~WFX_RSI_ST_STA_CONNECTED; return status; } @@ -376,7 +378,7 @@ bool wfx_start_scan(char * ssid, void (*callback)(wfx_wifi_scan_result_t *)) WfxEvent_t event; event.eventType = WFX_EVT_SCAN; - WfxPostEvent(&event); + sl_matter_wifi_post_event(&event); return true; } diff --git a/examples/pump-app/silabs/BUILD.gn b/examples/pump-app/silabs/BUILD.gn index 8321ba6c80adc9..e8acd1501c5a18 100644 --- a/examples/pump-app/silabs/BUILD.gn +++ b/examples/pump-app/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -38,7 +38,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/smoke-co-alarm-app/silabs/BUILD.gn b/examples/smoke-co-alarm-app/silabs/BUILD.gn index c6fe0967a9775b..ad2db014594416 100644 --- a/examples/smoke-co-alarm-app/silabs/BUILD.gn +++ b/examples/smoke-co-alarm-app/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -38,7 +38,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/thermostat/silabs/BUILD.gn b/examples/thermostat/silabs/BUILD.gn index f51ee14825d27e..623d87c2f74555 100644 --- a/examples/thermostat/silabs/BUILD.gn +++ b/examples/thermostat/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -38,7 +38,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/window-app/silabs/BUILD.gn b/examples/window-app/silabs/BUILD.gn index c45dbda632a5f9..f55d63012f8444 100644 --- a/examples/window-app/silabs/BUILD.gn +++ b/examples/window-app/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -39,7 +39,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index ca08a8c392182d..78657a635a4268 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -219,7 +219,7 @@ if (current_os == "zephyr" || current_os == "mbed") { } else if (lwip_platform == "cc32xx") { public_deps += [ "${ti_simplelink_sdk_build_root}:ti_simplelink_sdk" ] } else if (lwip_platform == "silabs") { - public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ] + public_deps += [ "${silabs_sdk_build_root}:silabs_sdk" ] sources += [ "${lwip_platform}/lwipopts-rs911x.h", diff --git a/src/platform/silabs/ConfigurationManagerImpl.cpp b/src/platform/silabs/ConfigurationManagerImpl.cpp index b4dd5c9c524f72..0219852813f28e 100644 --- a/src/platform/silabs/ConfigurationManagerImpl.cpp +++ b/src/platform/silabs/ConfigurationManagerImpl.cpp @@ -290,10 +290,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) PersistedStorage::KeyValueStoreMgrImpl().ErasePartition(); #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - sl_status_t status = wfx_sta_discon(); + sl_status_t status = sl_matter_wifi_disconnect(); if (status != SL_STATUS_OK) { - ChipLogError(DeviceLayer, "wfx_sta_discon() failed: %lx", status); + ChipLogError(DeviceLayer, "sl_matter_wifi_disconnect() failed: %lx", status); } ChipLogProgress(DeviceLayer, "Clearing WiFi provision"); wfx_clear_wifi_provision(); diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index 6e5470f7d05f26..2dd946feb12a6d 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -277,7 +277,7 @@ void ConnectivityManagerImpl::DriveStationState() (mWiFiStationMode != kWiFiStationMode_Enabled && !IsWiFiStationProvisioned())) { ChipLogProgress(DeviceLayer, "Disconnecting WiFi station interface"); - serr = wfx_sta_discon(); + serr = sl_matter_wifi_disconnect(); if (serr != SL_STATUS_OK) { ChipLogError(DeviceLayer, "wfx_wifi_disconnect() failed: %lx", serr); diff --git a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp index 7f6240c32c5858..ba80a94be6a96c 100644 --- a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp @@ -140,7 +140,7 @@ CHIP_ERROR SlWiFiDriver::ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, if (ConnectivityMgr().IsWiFiStationProvisioned()) { ChipLogProgress(DeviceLayer, "Disconecting for current wifi"); - status = wfx_sta_discon(); + status = sl_matter_wifi_disconnect(); if (status != SL_STATUS_OK) { return CHIP_ERROR_INTERNAL; diff --git a/src/platform/silabs/PlatformManagerImpl.cpp b/src/platform/silabs/PlatformManagerImpl.cpp index dccb5db7657251..20d7b94ada5edf 100644 --- a/src/platform/silabs/PlatformManagerImpl.cpp +++ b/src/platform/silabs/PlatformManagerImpl.cpp @@ -84,10 +84,10 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) err = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().Init(); SuccessOrExit(err); -#if CHIP_SYSTEM_CONFIG_USE_LWIP +#if CHIP_SYSTEM_CONFIG_USE_LWIP && !defined(SLI_SI91X_MCU_INTERFACE) // Initialize LwIP. tcpip_init(NULL, NULL); -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP +#endif // CHIP_SYSTEM_CONFIG_USE_LWIP && !defined(SLI_SI91X_MCU_INTERFACE) ReturnErrorOnFailure(System::Clock::InitClock_RealTime()); diff --git a/src/platform/silabs/SiWx917/BUILD.gn b/src/platform/silabs/SiWx917/BUILD.gn index 188f1f3396f7de..0c2f9032e4bc81 100644 --- a/src/platform/silabs/SiWx917/BUILD.gn +++ b/src/platform/silabs/SiWx917/BUILD.gn @@ -103,7 +103,6 @@ static_library("SiWx917") { "${silabs_platform_dir}/NetworkCommissioningWiFiDriver.h", "${silabs_platform_dir}/wifi/wfx_host_events.h", "wifi/wfx_msgs.h", - "wifi/wifi_config.h", ] public_configs = [ ":siwx917-platform-wifi-config" ] } diff --git a/src/platform/silabs/SiWx917/wifi/ethernetif.cpp b/src/platform/silabs/SiWx917/wifi/ethernetif.cpp deleted file mode 100644 index 2860b895ce7fae..00000000000000 --- a/src/platform/silabs/SiWx917/wifi/ethernetif.cpp +++ /dev/null @@ -1,269 +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. - */ - -/* Includes */ - -#include -#include -#include - -#include "wfx_host_events.h" -#include "wifi_config.h" -#ifdef __cplusplus -extern "C" { -#endif -#include "cmsis_os2.h" -#include "sl_board_configuration.h" -#include "sl_net.h" -#include "sl_si91x_driver.h" -#include "sl_si91x_host_interface.h" -#include "sl_si91x_types.h" -#include "sl_wifi.h" -#include "sl_wifi_callback_framework.h" -#include "sl_wifi_constants.h" -#include "sl_wifi_types.h" -#ifdef __cplusplus -} -#endif -/* LwIP includes. */ -#include "ethernetif.h" -#include "lwip/ethip6.h" -#include "lwip/timeouts.h" -#include "netif/etharp.h" -#include - -StaticSemaphore_t xEthernetIfSemaBuffer; - -/***************************************************************************** - * Defines - ******************************************************************************/ -#define STATION_NETIF0 's' -#define STATION_NETIF1 't' - -#define LWIP_FRAME_ALIGNMENT 60 - -uint32_t gOverrunCount = 0; - -/***************************************************************************** - * Variables - ******************************************************************************/ - -/***************************************************************************** - * @fn static void low_level_init(struct netif *netif) - * @brief - * Initializes the hardware parameters. Called from ethernetif_init(). - * - * @param[in] netif: the already initialized lwip network interface structure - * - * @return - * None - ******************************************************************************/ -static void low_level_init(struct netif * netif) -{ - /* set netif MAC hardware address length */ - netif->hwaddr_len = ETH_HWADDR_LEN; - - /* Set netif MAC hardware address */ - sl_wfx_mac_address_t mac_addr; - - wfx_get_wifi_mac_addr(SL_WFX_STA_INTERFACE, &mac_addr); - - netif->hwaddr[0] = mac_addr.octet[0]; - netif->hwaddr[1] = mac_addr.octet[1]; - netif->hwaddr[2] = mac_addr.octet[2]; - netif->hwaddr[3] = mac_addr.octet[3]; - netif->hwaddr[4] = mac_addr.octet[4]; - netif->hwaddr[5] = mac_addr.octet[5]; - - /* Set netif maximum transfer unit */ - netif->mtu = 1500; - - /* Accept broadcast address and ARP traffic */ - netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_IGMP; - -#if LWIP_IPV6_MLD - netif->flags |= NETIF_FLAG_MLD6; -#endif /* LWIP_IPV6_MLD */ -} - -/******************************************************************************** - * @fn static void low_level_input(struct netif *netif, uint8_t *b, uint16_t len) - * @brief - * Make PBUF out of a linear buffer - that can be fed into lwip - * @param[in] netif: the already initialized lwip network interface structure - * @param[in] len: length - * @return - * None - ************************************************************************************/ -static void low_level_input(struct netif * netif, uint8_t * b, uint16_t len) -{ - struct pbuf *p, *q; - uint32_t bufferoffset; - - if (len <= 0) - { - return; - } - if (len < LWIP_FRAME_ALIGNMENT) - { /* 60 : LWIP frame alignment */ - len = LWIP_FRAME_ALIGNMENT; - } - - /* Drop packets originated from the same interface and is not destined for the said interface */ - const uint8_t * src_mac = b + netif->hwaddr_len; - const uint8_t * dst_mac = b; - - if (!(ip6_addr_ispreferred(netif_ip6_addr_state(netif, 0))) && (memcmp(netif->hwaddr, src_mac, netif->hwaddr_len) == 0) && - (memcmp(netif->hwaddr, dst_mac, netif->hwaddr_len) != 0)) - { -#ifdef WIFI_DEBUG_ENABLED - ChipLogDetail(DeviceLayer, "DROP: [%02x:%02x:%02x:%02x:%02x:%02x]->[%02x:%02x:%02x:%02x:%02x:%02x] type=%02x%02x", - - src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], - - dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5], - - b[12], b[13]); -#endif - return; - } - - /* We allocate a pbuf chain of pbufs from the Lwip buffer pool - * and copy the data to the pbuf chain - */ - if ((p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL)) != STRUCT_PBUF) - { - for (q = p, bufferoffset = 0; q != NULL; q = q->next) - { - memcpy((uint8_t *) q->payload, (uint8_t *) b + bufferoffset, q->len); - bufferoffset += q->len; - } -#ifdef WIFI_DEBUG_ENABLED - ChipLogDetail(DeviceLayer, "ACCEPT(%d): [%02x:%02x:%02x:%02x:%02x:%02x]->[%02x:%02x:%02x:%02x:%02x:%02x] type=%02x%02x", - bufferoffset, - - src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5], - - dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5], - - b[12], b[13]); -#endif - - if (netif->input(p, netif) != ERR_OK) - { - gOverrunCount++; - pbuf_free(p); - } - } - else - { - gOverrunCount++; - } -} - -static SemaphoreHandle_t ethout_sem; -/***************************************************************************** - * @fn static err_t low_level_output(struct netif *netif, struct pbuf *p) - * @brief - * This function is called from LWIP task when LWIP stack - * has some data to be forwarded over WiFi Network - * - * @param[in] netif: lwip network interface - * - * @param[in] p: the packet to send - * - * @return - * ERR_OK if successful - ******************************************************************************/ -static err_t low_level_output(struct netif * netif, struct pbuf * p) -{ - UNUSED_PARAMETER(netif); - sl_status_t status; - status = sl_wifi_send_raw_data_frame(SL_WIFI_CLIENT_INTERFACE, (uint8_t *) p->payload, p->len); - if (status != SL_STATUS_OK) - { - return ERR_IF; - } - return ERR_OK; -} - -/***************************************************************************** - * @fn void sl_si91x_host_process_data_frame(uint8_t *buf, int len) - * @brief - * host received frame cb - * - * @param[in] buf: buffer - * - * @param[in] len: length - * - * @return - * None - ******************************************************************************/ -sl_status_t sl_si91x_host_process_data_frame(sl_wifi_interface_t interface, sl_wifi_buffer_t * buffer) -{ - struct pbuf * pbuf_packet; - void * packet; - struct netif * ifp; - sl_si91x_packet_t * rsi_pkt; - packet = sl_si91x_host_get_buffer_data(buffer, 0, NULL); - rsi_pkt = (sl_si91x_packet_t *) packet; - - /* get the network interface for STATION interface, - * and forward the received frame buffer to LWIP - */ - if ((ifp = wfx_get_netif(SL_WFX_STA_INTERFACE)) != (struct netif *) 0) - { - low_level_input(ifp, rsi_pkt->data, rsi_pkt->length); - } - return SL_STATUS_OK; -} - -/***************************************************************************** - * @fn err_t sta_ethernetif_init(struct netif *netif) - * @brief - * sta ethernet if initialization - * - * @param[in] netif: the lwip network interface structure - * - * @return - * ERR_OK if successful - ******************************************************************************/ -err_t sta_ethernetif_init(struct netif * netif) -{ - LWIP_ASSERT("netif != NULL", (netif != NULL)); - - /* Set the netif name to identify the interface */ - netif->name[0] = STATION_NETIF0; - netif->name[1] = STATION_NETIF1; - -#if LWIP_IPV4 && LWIP_ARP - netif->output = etharp_output; -#endif /* #if LWIP_IPV4 && LWIP_ARP */ -#if LWIP_IPV6 && LWIP_ETHERNET - netif->output_ip6 = ethip6_output; -#endif /* LWIP_IPV6 && LWIP_ETHERNET */ - netif->linkoutput = low_level_output; - - /* initialize the hardware */ - low_level_init(netif); - - /* Need single output only */ - ethout_sem = xSemaphoreCreateBinaryStatic(&xEthernetIfSemaBuffer); - xSemaphoreGive(ethout_sem); - - return ERR_OK; -} diff --git a/src/platform/silabs/SiWx917/wifi/ethernetif.h b/src/platform/silabs/SiWx917/wifi/ethernetif.h deleted file mode 100644 index bac51b9258cd85..00000000000000 --- a/src/platform/silabs/SiWx917/wifi/ethernetif.h +++ /dev/null @@ -1,49 +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 "lwip/err.h" -#include "lwip/netif.h" -#ifdef __cplusplus -extern "C" { -#endif -/*************************************************************************** - * @fn err_t sta_ethernetif_init(struct netif *netif) - * @brief - * Sets up the station network interface. - * - * @param netif the lwip network interface structure - * @returns ERR_OK if successful - ******************************************************************************/ -err_t sta_ethernetif_init(struct netif * netif); - -/*************************************************************************** - * @fn err_t ap_ethernetif_init(struct netif *netif - * @brief - * Sets up the AP network interface. - * - * @param netif the lwip network interface structure - * @returns ERR_OK if successful - ******************************************************************************/ -err_t ap_ethernetif_init(struct netif * netif); - -void wfx_host_received_sta_frame_cb(uint8_t * buf, int len); - -#ifdef __cplusplus -} -#endif diff --git a/src/platform/silabs/SiWx917/wifi/lwip_netif.cpp b/src/platform/silabs/SiWx917/wifi/lwip_netif.cpp deleted file mode 100644 index d4bcbe4739a10f..00000000000000 --- a/src/platform/silabs/SiWx917/wifi/lwip_netif.cpp +++ /dev/null @@ -1,149 +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. - */ - -#include -#include -#include - -#include "wfx_host_events.h" -#include "wifi_config.h" - -#include "dhcp_client.h" -#include "ethernetif.h" - -#include "FreeRTOS.h" -#include "event_groups.h" -#include "task.h" - -#include -using namespace ::chip; -using namespace ::chip::DeviceLayer; -static struct netif sta_netif; - -#ifdef SL_WFX_CONFIG_SOFTAP -static struct netif ap_netif; -#endif - -/**************************************************************************** - * @fn static void netif_config(struct netif *sta_if, struct netif *ap_if) - * @brief - * netif configuration - * @param[in] sta_if: - * @param[in] ap_if: - * @return None - *****************************************************************************/ -static void netif_config(struct netif * sta_if, struct netif * ap_if) -{ - if (sta_if != NULL) - { -#if LWIP_IPV4 - ip_addr_t sta_ipaddr; - ip_addr_t sta_netmask; - ip_addr_t sta_gw; - - /* Initialize the Station information */ - ip_addr_set_zero_ip4(&sta_ipaddr); - ip_addr_set_zero_ip4(&sta_netmask); - ip_addr_set_zero_ip4(&sta_gw); -#endif /* LWIP_IPV4 */ - - /* Add station interfaces */ - netif_add(sta_if, -#if LWIP_IPV4 - (const ip4_addr_t *) &sta_ipaddr, (const ip4_addr_t *) &sta_netmask, (const ip4_addr_t *) &sta_gw, -#endif /* LWIP_IPV4 */ - NULL, &sta_ethernetif_init, &tcpip_input); - - /* Registers the default network interface */ - netif_set_default(sta_if); - } -} - -/**************************************************************************** - * @fn void wfx_lwip_set_sta_link_up(void) - * @brief - * Set station link status to up. - * @param[in] None - * @return None - *****************************************************************************/ -void wfx_lwip_set_sta_link_up(void) -{ - netifapi_netif_set_up(&sta_netif); - netifapi_netif_set_link_up(&sta_netif); -#if LWIP_IPV4 && LWIP_DHCP - dhcpclient_set_link_state(LINK_UP); -#endif /* LWIP_IPV4 && LWIP_DHCP */ - /* - * Enable IPV6 - */ - -#if LWIP_IPV6_AUTOCONFIG - sta_netif.ip6_autoconfig_enabled = 1; -#endif /* LWIP_IPV6_AUTOCONFIG */ - netif_create_ip6_linklocal_address(&sta_netif, MAC_48_BIT_SET); -} - -/*************************************************************************** - * @fn void wfx_lwip_set_sta_link_down(void) - * @brief - * Set station link status to down. - * @param[in] None - * @return None - *****************************************************************************/ -void wfx_lwip_set_sta_link_down(void) -{ -#if LWIP_IPV4 && LWIP_DHCP - dhcpclient_set_link_state(LINK_DOWN); -#endif /* LWIP_IPV4 && LWIP_DHCP */ - netifapi_netif_set_link_down(&sta_netif); - netifapi_netif_set_down(&sta_netif); -} - -/*************************************************************************** - * @fn void wfx_lwip_start(void) - * @brief - * Initialize the LwIP stack - * @param[in] None - * @return None - *****************************************************************************/ -void wfx_lwip_start(void) -{ - /* Initialize the LwIP stack */ - netif_config(&sta_netif, NULL); -} - -/*************************************************************************** - * @fn struct netif *wfx_get_netif(sl_wfx_interface_t interface) - * @brief - * get the netif - * @param[in] interface: - * @return None - *****************************************************************************/ -struct netif * wfx_get_netif(sl_wfx_interface_t interface) -{ - if (interface == SL_WFX_STA_INTERFACE) - { - return &sta_netif; - } -#ifdef SL_WFX_CONFIG_SOFTAP - else if (interface == SL_WFX_SOFTAP_INTERFACE) - { - return &ap_netif; - } -#endif - return (struct netif *) 0; -} diff --git a/src/platform/silabs/SiWx917/wifi/wifi_config.h b/src/platform/silabs/SiWx917/wifi/wifi_config.h deleted file mode 100644 index f2f3b7ffeb3740..00000000000000 --- a/src/platform/silabs/SiWx917/wifi/wifi_config.h +++ /dev/null @@ -1,71 +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 DEMO_CONFIG_H -#define DEMO_CONFIG_H - -#define USE_DHCP_CLIENT_DEFAULT (1) ///< If defined, DHCP is enabled, otherwise static address below is used - -/************************** Station Static Default ****************************/ -#define STA_IP_ADDR0_DEFAULT ((uint8_t) 192) ///< Static IP: IP address value 0 -#define STA_IP_ADDR1_DEFAULT ((uint8_t) 168) ///< Static IP: IP address value 1 -#define STA_IP_ADDR2_DEFAULT ((uint8_t) 0) ///< Static IP: IP address value 2 -#define STA_IP_ADDR3_DEFAULT ((uint8_t) 1) ///< Static IP: IP address value 3 - -/*NETMASK*/ -#define STA_NETMASK_ADDR0_DEFAULT ((uint8_t) 255) ///< Static IP: Netmask value 0 -#define STA_NETMASK_ADDR1_DEFAULT ((uint8_t) 255) ///< Static IP: Netmask value 1 -#define STA_NETMASK_ADDR2_DEFAULT ((uint8_t) 255) ///< Static IP: Netmask value 2 -#define STA_NETMASK_ADDR3_DEFAULT ((uint8_t) 0) ///< Static IP: Netmask value 3 - -/*Gateway Address*/ -#define STA_GW_ADDR0_DEFAULT ((uint8_t) 0) ///< Static IP: Gateway value 0 -#define STA_GW_ADDR1_DEFAULT ((uint8_t) 0) ///< Static IP: Gateway value 1 -#define STA_GW_ADDR2_DEFAULT ((uint8_t) 0) ///< Static IP: Gateway value 2 -#define STA_GW_ADDR3_DEFAULT ((uint8_t) 0) ///< Static IP: Gateway value 3 - -/************************** Access Point Static Default ****************************/ -// #define AP_IP_ADDR0_DEFAULT (uint8_t) 10 ///< Static IP: IP address value 0 -// #define AP_IP_ADDR1_DEFAULT (uint8_t) 10 ///< Static IP: IP address value 1 -// #define AP_IP_ADDR2_DEFAULT (uint8_t) 0 ///< Static IP: IP address value 2 -// #define AP_IP_ADDR3_DEFAULT (uint8_t) 1 ///< Static IP: IP address value 3 - -/*NETMASK*/ -// #define AP_NETMASK_ADDR0_DEFAULT (uint8_t) 255 ///< Static IP: Netmask value 0 -// #define AP_NETMASK_ADDR1_DEFAULT (uint8_t) 255 ///< Static IP: Netmask value 1 -// #define AP_NETMASK_ADDR2_DEFAULT (uint8_t) 255 ///< Static IP: Netmask value 2 -// #define AP_NETMASK_ADDR3_DEFAULT (uint8_t) 0 ///< Static IP: Netmask value 3 - -/*Gateway Address*/ -// #define AP_GW_ADDR0_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 0 -// #define AP_GW_ADDR1_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 1 -// #define AP_GW_ADDR2_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 2 -// #define AP_GW_ADDR3_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 3 - -#define WLAN_SSID_DEFAULT "AP_name" ///< wifi ssid for client mode -#define WLAN_PASSKEY_DEFAULT "passkey" ///< wifi password for client mode -#define WLAN_SECURITY_DEFAULT WFM_SECURITY_MODE_WPA2_PSK ///< wifi security mode for client mode: -///< WFM_SECURITY_MODE_OPEN/WFM_SECURITY_MODE_WEP/WFM_SECURITY_MODE_WPA2_WPA1_PSK - -#define SOFTAP_SSID_DEFAULT "silabs_softap" ///< wifi ssid for soft ap mode -#define SOFTAP_PASSKEY_DEFAULT "changeme" ///< wifi password for soft ap mode -#define SOFTAP_SECURITY_DEFAULT WFM_SECURITY_MODE_WPA2_PSK ///< wifi security for soft ap mode: -///< WFM_SECURITY_MODE_OPEN/WFM_SECURITY_MODE_WEP/WFM_SECURITY_MODE_WPA2_WPA1_PSK - -#define SOFTAP_CHANNEL_DEFAULT (6) ///< wifi channel for soft ap - -#endif // DEMO_CONFIG_H diff --git a/src/platform/silabs/efr32/BUILD.gn b/src/platform/silabs/efr32/BUILD.gn index 4bc881f5f54a27..b1e50faafca0e0 100644 --- a/src/platform/silabs/efr32/BUILD.gn +++ b/src/platform/silabs/efr32/BUILD.gn @@ -161,10 +161,9 @@ static_library("efr32") { "${silabs_platform_dir}/NetworkCommissioningWiFiDriver.h", "${silabs_platform_dir}/wifi/wfx_host_events.h", "wifi/wfx_msgs.h", - "wifi/wifi_config.h", ] - if (use_wf200 || use_rs9116 || use_SiWx917) { + if (use_wf200 || use_rs9116) { sources += [ "${silabs_platform_dir}/wifi/dhcp_client.cpp", "wifi/ethernetif.cpp", diff --git a/src/platform/silabs/efr32/args.gni b/src/platform/silabs/efr32/args.gni index 394e4bb1bd806a..501661866ad61e 100644 --- a/src/platform/silabs/efr32/args.gni +++ b/src/platform/silabs/efr32/args.gni @@ -20,9 +20,9 @@ import("${chip_root}/examples/platform/silabs/args.gni") import("${chip_root}/src/crypto/crypto.gni") # ARM architecture flags will be set based on silabs_family. -arm_platform_config = "${efr32_sdk_build_root}/silabs_arm.gni" +arm_platform_config = "${silabs_sdk_build_root}/silabs_arm.gni" -mbedtls_target = "${efr32_sdk_build_root}:efr32_sdk" +mbedtls_target = "${silabs_sdk_build_root}:silabs_sdk" openthread_external_mbedtls = mbedtls_target diff --git a/src/platform/silabs/efr32/wifi/ethernetif.cpp b/src/platform/silabs/efr32/wifi/ethernetif.cpp index d0f0ec6daf47f7..5993cf90cc631a 100644 --- a/src/platform/silabs/efr32/wifi/ethernetif.cpp +++ b/src/platform/silabs/efr32/wifi/ethernetif.cpp @@ -51,7 +51,6 @@ extern "C" { #endif // WF200_WIFI #include "wfx_host_events.h" -#include "wifi_config.h" #ifdef WF200_WIFI #include "sl_wfx.h" #endif diff --git a/src/platform/silabs/efr32/wifi/lwip_netif.cpp b/src/platform/silabs/efr32/wifi/lwip_netif.cpp index 3a0d104a90be71..f8d719b387fb09 100644 --- a/src/platform/silabs/efr32/wifi/lwip_netif.cpp +++ b/src/platform/silabs/efr32/wifi/lwip_netif.cpp @@ -26,7 +26,6 @@ #include "em_usart.h" #include "wfx_host_events.h" -#include "wifi_config.h" #include "dhcp_client.h" #include "ethernetif.h" @@ -121,13 +120,13 @@ void wfx_lwip_set_sta_link_down(void) } /*************************************************************************** - * @fn void wfx_lwip_start(void) + * @fn void sl_matter_lwip_start(void) * @brief * Initialize the LwIP stack * @param[in] None * @return None *****************************************************************************/ -void wfx_lwip_start(void) +void sl_matter_lwip_start(void) { /* Initialize the LwIP stack */ netif_config(&sta_netif, NULL); diff --git a/src/platform/silabs/efr32/wifi/wifi_config.h b/src/platform/silabs/efr32/wifi/wifi_config.h deleted file mode 100644 index 8e00201b7fc102..00000000000000 --- a/src/platform/silabs/efr32/wifi/wifi_config.h +++ /dev/null @@ -1,53 +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 WIFI_CONFIG_H -#define WIFI_CONFIG_H - -#define USE_DHCP_CLIENT_DEFAULT 1 ///< If defined, DHCP is enabled, otherwise static address below is used - -/************************** Station Static Default ****************************/ -#define STA_IP_ADDR0_DEFAULT (uint8_t) 192 ///< Static IP: IP address value 0 -#define STA_IP_ADDR1_DEFAULT (uint8_t) 168 ///< Static IP: IP address value 1 -#define STA_IP_ADDR2_DEFAULT (uint8_t) 0 ///< Static IP: IP address value 2 -#define STA_IP_ADDR3_DEFAULT (uint8_t) 1 ///< Static IP: IP address value 3 - -/*NETMASK*/ -#define STA_NETMASK_ADDR0_DEFAULT (uint8_t) 255 ///< Static IP: Netmask value 0 -#define STA_NETMASK_ADDR1_DEFAULT (uint8_t) 255 ///< Static IP: Netmask value 1 -#define STA_NETMASK_ADDR2_DEFAULT (uint8_t) 255 ///< Static IP: Netmask value 2 -#define STA_NETMASK_ADDR3_DEFAULT (uint8_t) 0 ///< Static IP: Netmask value 3 - -/*Gateway Address*/ -#define STA_GW_ADDR0_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 0 -#define STA_GW_ADDR1_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 1 -#define STA_GW_ADDR2_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 2 -#define STA_GW_ADDR3_DEFAULT (uint8_t) 0 ///< Static IP: Gateway value 3 - -#define WLAN_SSID_DEFAULT "AP_name" ///< wifi ssid for client mode -#define WLAN_PASSKEY_DEFAULT "passkey" ///< wifi password for client mode -#define WLAN_SECURITY_DEFAULT WFM_SECURITY_MODE_WPA2_PSK ///< wifi security mode for client mode: -///< WFM_SECURITY_MODE_OPEN/WFM_SECURITY_MODE_WEP/WFM_SECURITY_MODE_WPA2_WPA1_PSK - -#define SOFTAP_SSID_DEFAULT "silabs_softap" ///< wifi ssid for soft ap mode -#define SOFTAP_PASSKEY_DEFAULT "changeme" ///< wifi password for soft ap mode -#define SOFTAP_SECURITY_DEFAULT WFM_SECURITY_MODE_WPA2_PSK ///< wifi security for soft ap mode: -///< WFM_SECURITY_MODE_OPEN/WFM_SECURITY_MODE_WEP/WFM_SECURITY_MODE_WPA2_WPA1_PSK - -#define SOFTAP_CHANNEL_DEFAULT 6 ///< wifi channel for soft ap - -#endif // WIFI_CONFIG_H diff --git a/src/platform/silabs/provision/BUILD.gn b/src/platform/silabs/provision/BUILD.gn index ea5d4b072a03ac..7ae41c05154731 100644 --- a/src/platform/silabs/provision/BUILD.gn +++ b/src/platform/silabs/provision/BUILD.gn @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") -import("${efr32_sdk_build_root}/silabs_board.gni") +import("${silabs_sdk_build_root}/silabs_board.gni") config("provision-config") { include_dirs = [ "." ] diff --git a/src/platform/silabs/wifi/dhcp_client.cpp b/src/platform/silabs/wifi/dhcp_client.cpp index c8b47a9f2b3735..a219430762cf50 100644 --- a/src/platform/silabs/wifi/dhcp_client.cpp +++ b/src/platform/silabs/wifi/dhcp_client.cpp @@ -24,7 +24,6 @@ #include "dhcp_client.h" #include "lwip/dhcp.h" #include "wfx_host_events.h" -#include "wifi_config.h" #include "FreeRTOS.h" #include "event_groups.h" diff --git a/src/platform/silabs/wifi/wfx_host_events.h b/src/platform/silabs/wifi/wfx_host_events.h index 3bd973467bf915..d3d8de6ec78569 100644 --- a/src/platform/silabs/wifi/wfx_host_events.h +++ b/src/platform/silabs/wifi/wfx_host_events.h @@ -316,7 +316,7 @@ void wfx_clear_wifi_provision(void); sl_status_t wfx_connect_to_ap(void); void wfx_setup_ip6_link_local(sl_wfx_interface_t); bool wfx_is_sta_connected(void); -sl_status_t wfx_sta_discon(void); +sl_status_t sl_matter_wifi_disconnect(void); #if CHIP_DEVICE_CONFIG_ENABLE_IPV4 bool wfx_have_ipv4_addr(sl_wfx_interface_t); #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ @@ -328,14 +328,14 @@ void wfx_cancel_scan(void); /* * Call backs into the Matter Platform code */ -void wfx_started_notify(void); +void sl_matter_wifi_task_started(void); void wfx_connected_notify(int32_t status, sl_wfx_mac_address_t * ap); void wfx_disconnected_notify(int32_t status); + /* Implemented for LWIP */ -void wfx_host_received_sta_frame_cb(uint8_t * buf, int len); void wfx_lwip_set_sta_link_up(void); void wfx_lwip_set_sta_link_down(void); -void wfx_lwip_start(void); +void sl_matter_lwip_start(void); struct netif * wfx_get_netif(sl_wfx_interface_t interface); bool wfx_hw_ready(void); diff --git a/src/platform/silabs/wifi_args.gni b/src/platform/silabs/wifi_args.gni index 5d523bd3a65d8c..7b4da179daf885 100644 --- a/src/platform/silabs/wifi_args.gni +++ b/src/platform/silabs/wifi_args.gni @@ -21,9 +21,9 @@ import("${chip_root}/examples/platform/silabs/args.gni") import("${chip_root}/src/crypto/crypto.gni") # ARM architecture flags will be set based on silabs_family. -arm_platform_config = "${efr32_sdk_build_root}/silabs_arm.gni" +arm_platform_config = "${silabs_sdk_build_root}/silabs_arm.gni" -mbedtls_target = "${efr32_sdk_build_root}:efr32_sdk" +mbedtls_target = "${silabs_sdk_build_root}:silabs_sdk" # default to platform crypto implementation but allow commandline override if (chip_crypto == "") { @@ -35,7 +35,7 @@ if (chip_crypto == "") { chip_use_transitional_commissionable_data_provider = false # Use GSDK lwip instead of CHIP -lwip_root = "${efr32_sdk_build_root}/silabs_lwip" +lwip_root = "${silabs_sdk_build_root}/silabs_lwip" #lwip_platform = "external" lwip_platform = "silabs" diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 40ae99ae99c77e..a8d15cf83f4223 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -177,7 +177,7 @@ source_set("system_config_header") { public_deps += [ "${lwip_root}:lwip" ] } else { if (chip_device_platform == "efr32") { - public_deps += [ "${efr32_sdk_build_root}:efr32_sdk" ] + public_deps += [ "${silabs_sdk_build_root}:silabs_sdk" ] } if (chip_device_platform == "qpg") { public_deps += [ "${qpg_sdk_build_root}:qpg_sdk" ] diff --git a/src/test_driver/efr32/BUILD.gn b/src/test_driver/efr32/BUILD.gn index 51fe90751ae219..9df7e4787a0325 100644 --- a/src/test_driver/efr32/BUILD.gn +++ b/src/test_driver/efr32/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/efr32_sdk.gni") +import("${silabs_sdk_build_root}/efr32_sdk.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") diff --git a/src/test_driver/efr32/args.gni b/src/test_driver/efr32/args.gni index 35be5dd63e3870..c4bc72c2a3cd97 100644 --- a/src/test_driver/efr32/args.gni +++ b/src/test_driver/efr32/args.gni @@ -38,7 +38,7 @@ pw_unit_test_BACKEND = "$dir_pw_unit_test:light" # Override the executable type and the test main's target. pw_unit_test_EXECUTABLE_TARGET_TYPE = "silabs_executable" pw_unit_test_EXECUTABLE_TARGET_TYPE_FILE = - "${efr32_sdk_build_root}/silabs_executable.gni" + "${silabs_sdk_build_root}/silabs_executable.gni" pw_unit_test_MAIN = "//:efr32_test_main" # Additional variables needed by silabs_executable that must be passed in to pw_test. diff --git a/third_party/openthread/platforms/efr32/BUILD.gn b/third_party/openthread/platforms/efr32/BUILD.gn index e270db2ae8757f..88f8f44c107e1b 100644 --- a/third_party/openthread/platforms/efr32/BUILD.gn +++ b/third_party/openthread/platforms/efr32/BUILD.gn @@ -18,8 +18,8 @@ import("//build_overrides/openthread.gni") import("//build_overrides/openthread.gni") -import("${efr32_sdk_build_root}/efr32_sdk.gni") -import("${efr32_sdk_build_root}/silabs_board.gni") +import("${silabs_sdk_build_root}/efr32_sdk.gni") +import("${silabs_sdk_build_root}/silabs_board.gni") config("openthread_efr32_config") { defines = [ @@ -48,7 +48,7 @@ source_set("openthread_core_config_efr32") { "${sl_ot_efr32_root}/openthread-core-efr32-config.h", ] - public_deps = [ "${efr32_sdk_build_root}:efr32_sdk" ] + public_deps = [ "${silabs_sdk_build_root}:silabs_sdk" ] public_configs = [ ":openthread_efr32_config" ] } diff --git a/third_party/silabs/BUILD.gn b/third_party/silabs/BUILD.gn index 16e0ba68c4607a..16d823dd4e73a3 100644 --- a/third_party/silabs/BUILD.gn +++ b/third_party/silabs/BUILD.gn @@ -18,12 +18,12 @@ import("//build_overrides/jlink.gni") import("//build_overrides/openthread.gni") import("${chip_root}/src/lwip/lwip.gni") import("${chip_root}/src/platform/device.gni") -import("${efr32_sdk_build_root}/silabs_board.gni") +import("${silabs_sdk_build_root}/silabs_board.gni") if (wifi_soc == true) { # CCP board - import("${efr32_sdk_build_root}/SiWx917_sdk.gni") + import("${silabs_sdk_build_root}/SiWx917_sdk.gni") } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") } declare_args() { @@ -49,7 +49,7 @@ config("silabs_config") { } assert(silabs_sdk_target != "", "silabs_sdk_target must be specified") -group("efr32_sdk") { +group("silabs_sdk") { public_deps = [ silabs_sdk_target ] public_configs = [ ":silabs_config" ] } @@ -117,7 +117,7 @@ if (wifi_soc != true) { # CCP board public_deps = [ ":libopenthread-platform", - "${efr32_sdk_build_root}:efr32_sdk", + "${silabs_sdk_build_root}:silabs_sdk", ] public_configs = [ ":openthread_efr32_config" ] @@ -190,7 +190,7 @@ if (wifi_soc != true) { # CCP board "${segger_rtt_root}:segger_rtt", ] - deps = [ "${efr32_sdk_build_root}:efr32_sdk" ] + deps = [ "${silabs_sdk_build_root}:silabs_sdk" ] # selected thread device type FTD or MTD XTD = "ftd" diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 3accbed0bc12f2..ab94c6372d18e0 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -16,12 +16,11 @@ import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") import("//build_overrides/jlink.gni") 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("${efr32_sdk_build_root}/efr32_sdk.gni") +import("${silabs_sdk_build_root}/efr32_sdk.gni") import("silabs_board.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" @@ -682,7 +681,6 @@ template("siwx917_sdk") { "${wifi_sdk_root}/components/device/silabs/si91x/wireless/src/sl_si91x_callback_framework.c", "${wifi_sdk_root}/components/device/silabs/si91x/wireless/src/sl_si91x_driver.c", "${wifi_sdk_root}/components/device/silabs/si91x/wireless/threading/sli_si91x_multithreaded.c", - "${wifi_sdk_root}/components/service/network_manager/si91x/sl_net_si91x.c", # modified hal "${efr32_sdk_root}/platform/emdrv/nvm3/src/nvm3_default_common_linker.c", @@ -829,7 +827,7 @@ template("siwx917_sdk") { "${_mbedtls_root}/library/ssl_srv.c", "${_mbedtls_root}/library/ssl_tls.c", "${_mbedtls_root}/library/x509.c", - "${efr32_sdk_build_root}/mqtt/stack/mqtt.c", + "${silabs_sdk_build_root}/mqtt/stack/mqtt.c", ] } diff --git a/third_party/silabs/lwip.gni b/third_party/silabs/lwip.gni index 9a35e7c45f7a61..db19c088398b68 100644 --- a/third_party/silabs/lwip.gni +++ b/third_party/silabs/lwip.gni @@ -13,7 +13,7 @@ # limitations under the License. import("//build_overrides/efr32_sdk.gni") import("//build_overrides/lwip.gni") -import("${efr32_sdk_build_root}/efr32_sdk.gni") +import("${silabs_sdk_build_root}/efr32_sdk.gni") # Defines a lwIP build target. # diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index fddcd73de5d30e..eab695e438ada9 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit fddcd73de5d30e41036993dc575f78835fba6e7c +Subproject commit eab695e438ada903a18956eb916696678227cb0d diff --git a/third_party/silabs/silabs_lwip/BUILD.gn b/third_party/silabs/silabs_lwip/BUILD.gn index e148763a9ca70d..4d0bcb24c518f1 100644 --- a/third_party/silabs/silabs_lwip/BUILD.gn +++ b/third_party/silabs/silabs_lwip/BUILD.gn @@ -41,7 +41,7 @@ lwip_target("silabs_lwip") { public_deps = [ "${chip_root}/src/lwip:lwip_buildconfig", - "${efr32_sdk_build_root}:efr32_sdk", + "${silabs_sdk_build_root}:silabs_sdk", ] public_configs = [