[Silabs] Rename Wifi interface sources files (#36318)
* Rename Wifi interface sources files
* restyle
diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp
index 44c60ca..43bd2c1 100644
--- a/examples/platform/silabs/MatterConfig.cpp
+++ b/examples/platform/silabs/MatterConfig.cpp
@@ -41,7 +41,7 @@
#endif
#if defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1
-#include "wfx_rsi.h"
+#include "WifiInterfaceAbstraction.h"
#endif // SLI_SI91X_MCU_INTERFACE
#include <crypto/CHIPCryptoPAL.h>
diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn
index 2abc3bc..3409d8e 100644
--- a/examples/platform/silabs/SiWx917/BUILD.gn
+++ b/examples/platform/silabs/SiWx917/BUILD.gn
@@ -15,6 +15,7 @@
import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
+import("${chip_root}/examples/platform/silabs/args.gni")
import("${chip_root}/src/lib/lib.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/platform/silabs/wifi_args.gni")
@@ -50,10 +51,7 @@
silabs_plat_dir = "${chip_root}/src/platform/silabs"
silabs_plat_si91x_wifi_dir = "${chip_root}/src/platform/silabs/SiWx917/wifi"
-import("${silabs_common_plat_dir}/args.gni")
config("chip_examples_project_config") {
- include_dirs = [ "project_include" ]
-
# Link options that provide a replacement for dynamic memory operations in standard
# library with the sl_memory_manager in platform code.
ldflags = [
@@ -107,6 +105,40 @@
]
}
+config("wifi-interface-config") {
+ include_dirs = [
+ "${silabs_plat_dir}/wifi",
+ "${silabs_common_plat_dir}/wifi",
+ ]
+}
+
+source_set("wifi-interface") {
+ sources = [
+ "${silabs_common_plat_dir}/wifi/WifiInterfaceAbstraction.cpp",
+ "SiWxWifiInterface.cpp",
+
+ # Wi-Fi Config - Using the file sdk support until the wiseconnect file is fixed
+ "${sdk_support_root}/components/service/network_manager/src/sl_net_for_lwip.c",
+ ]
+
+ public_deps = [
+ "${chip_root}/src/app/icd/server:icd-server-config",
+ "${chip_root}/src/lib/core",
+ "${chip_root}/src/lib/support",
+ "${chip_root}/src/platform:platform",
+ "${chip_root}/src/platform/silabs/SiWx917:SiWx917",
+ "${lwip_root}:lwip",
+ ]
+
+ public_configs = [
+ ":siwx917-common-config",
+ "${silabs_sdk_build_root}:silabs_config",
+ ":chip_examples_project_config",
+ ":wifi-interface-config",
+ ":silabs-wifi-config",
+ ]
+}
+
config("siwx917-common-config") {
defines = [ "OTA_PERIODIC_TIMEOUT=${ota_periodic_query_timeout_sec}" ]
@@ -167,7 +199,11 @@
source_set("siwx917-common") {
deps = [ "${silabs_common_plat_dir}/provision:storage" ]
defines = []
- public_deps = [ "${lwip_root}:lwip" ]
+ public_deps = [
+ ":wifi-interface",
+ "${lwip_root}:lwip",
+ ]
+
public_configs = [
":siwx917-common-config",
"${silabs_sdk_build_root}:silabs_config",
@@ -176,6 +212,7 @@
include_dirs = [
"${silabs_plat_dir}/wifi",
+ "${silabs_common_plat_dir}/wifi",
"${silabs_plat_si91x_wifi_dir}",
"${silabs_common_plat_dir}",
]
@@ -188,12 +225,6 @@
"${silabs_common_plat_dir}/SoftwareFaultReports.cpp",
"${silabs_common_plat_dir}/silabs_utils.cpp",
"${silabs_common_plat_dir}/syscalls_stubs.cpp",
- "${silabs_common_plat_dir}/wifi/wfx_notify.cpp",
- "${silabs_common_plat_dir}/wifi/wfx_rsi_host.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/SiWxWifiInterface.cpp b/examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp
index 1e573ed..26a16f9 100644
--- a/examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp
+++ b/examples/platform/silabs/SiWx917/SiWxWifiInterface.cpp
@@ -28,6 +28,7 @@
#endif // SL_MATTER_GN_BUILD
#include "FreeRTOS.h"
+#include "WifiInterfaceAbstraction.h"
#include "ble_config.h"
#include "dhcp_client.h"
#include "event_groups.h"
@@ -36,7 +37,6 @@
#include "sl_wifi_device.h"
#include "task.h"
#include "wfx_host_events.h"
-#include "wfx_rsi.h"
#include <app/icd/server/ICDServerConfig.h>
#include <inet/IPAddress.h>
#include <lib/support/CHIPMem.h>
@@ -800,8 +800,8 @@
osSemaphoreRelease(sScanInProgressSemaphore);
}
- break;
#endif /* SL_WFX_CONFIG_SCAN */
+ break;
case WFX_EVT_STA_START_JOIN:
ChipLogDetail(DeviceLayer, "WFX_EVT_STA_START_JOIN");
diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.cpp b/examples/platform/silabs/efr32/rs911x/Rsi91xWifiInterface.cpp
similarity index 99%
rename from examples/platform/silabs/efr32/rs911x/rsi_if.cpp
rename to examples/platform/silabs/efr32/rs911x/Rsi91xWifiInterface.cpp
index 7c727e0..233230b 100644
--- a/examples/platform/silabs/efr32/rs911x/rsi_if.cpp
+++ b/examples/platform/silabs/efr32/rs911x/Rsi91xWifiInterface.cpp
@@ -49,11 +49,11 @@
}
#endif
+#include "WifiInterfaceAbstraction.h"
#include "dhcp_client.h"
#include "ethernetif.h"
#include "lwip/nd6.h"
#include "silabs_utils.h"
-#include "wfx_rsi.h"
#include <lib/support/CHIPMem.h>
#include <lib/support/CHIPMemString.h>
diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c
index 1f10640..b1e4468 100644
--- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c
+++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c
@@ -41,10 +41,10 @@
#include "sl_status.h"
#include "spidrv.h"
+#include "WifiInterfaceAbstraction.h"
#include "silabs_utils.h"
#include "spi_multiplex.h"
#include "wfx_host_events.h"
-#include "wfx_rsi.h"
#ifdef SL_BOARD_NAME
#include "sl_board_control.h"
diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c
index 1cb5ddf..fb6a947 100644
--- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c
+++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c
@@ -35,8 +35,8 @@
#include "event_groups.h"
#include "task.h"
+#include "WifiInterfaceAbstraction.h"
#include "wfx_host_events.h"
-#include "wfx_rsi.h"
#if (SLI_SI91X_MCU_INTERFACE | EXP_BOARD)
#include "sl_board_configuration.h"
diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c
index 6ea20ca..bb7dcf4 100644
--- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c
+++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c
@@ -35,8 +35,8 @@
#include "event_groups.h"
#include "task.h"
+#include "WifiInterfaceAbstraction.h"
#include "wfx_host_events.h"
-#include "wfx_rsi.h"
#include "rsi_board_configuration.h"
#include "rsi_driver.h"
diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_timer.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_timer.c
index 7a80072..b8ffea8 100644
--- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_timer.c
+++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_timer.c
@@ -39,6 +39,7 @@
/* RSI Driver include file */
#include "rsi_driver.h"
/* RSI WLAN Config include file */
+#include "WifiInterfaceAbstraction.h"
#include "rsi_bootup_config.h"
#include "rsi_common_apis.h"
#include "rsi_data_types.h"
@@ -49,7 +50,6 @@
#include "rsi_wlan.h"
#include "rsi_wlan_apis.h"
#include "rsi_wlan_config.h"
-#include "wfx_rsi.h"
#ifndef _use_the_rsi_defined_functions
diff --git a/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c b/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c
index b16bbdc..4db0470 100644
--- a/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c
+++ b/examples/platform/silabs/efr32/rs911x/hal/sl_si91x_ncp_utility.c
@@ -44,10 +44,10 @@
#include "sl_device_init_hfxo.h"
#include "sl_status.h"
+#include "WifiInterfaceAbstraction.h"
#include "silabs_utils.h"
#include "sl_si91x_ncp_utility.h"
#include "wfx_host_events.h"
-#include "wfx_rsi.h"
#if SL_MX25CTRL_MUX
sl_status_t sl_wfx_host_spiflash_cs_assert(void);
diff --git a/examples/platform/silabs/efr32/rs911x/rs9117.gni b/examples/platform/silabs/efr32/rs911x/rs9117.gni
index 1adf21a..63f027e 100644
--- a/examples/platform/silabs/efr32/rs911x/rs9117.gni
+++ b/examples/platform/silabs/efr32/rs911x/rs9117.gni
@@ -1,3 +1,17 @@
+# Copyright (c) 2024 Project CHIP Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("${silabs_sdk_build_root}/efr32_sdk.gni")
@@ -7,14 +21,14 @@
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c",
"${examples_plat_dir}/rs911x/hal/sl_si91x_ncp_utility.c",
"${examples_plat_dir}/rs911x/hal/efx32_ncp_host.c",
- "${silabs_common_plat_dir}/wifi/wfx_notify.cpp",
- "${silabs_common_plat_dir}/wifi/wfx_rsi_host.cpp",
+ "${silabs_common_plat_dir}/wifi/WifiInterfaceAbstraction.cpp",
]
rs9117_inc_plat = [
"${examples_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x/hal",
"${wifi_sdk_root}/components/si91x/ble/inc",
+ "${silabs_common_plat_dir}/wifi",
]
rs911x_cflags = [ "-Wno-empty-body" ]
diff --git a/examples/platform/silabs/efr32/rs911x/rs911x.gni b/examples/platform/silabs/efr32/rs911x/rs911x.gni
index c2a2060..4aedb66 100644
--- a/examples/platform/silabs/efr32/rs911x/rs911x.gni
+++ b/examples/platform/silabs/efr32/rs911x/rs911x.gni
@@ -1,15 +1,28 @@
+# Copyright (c) 2024 Project CHIP Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("${silabs_sdk_build_root}/efr32_sdk.gni")
rs911x_src_plat = [
- "${examples_plat_dir}/rs911x/rsi_if.cpp",
+ "${examples_plat_dir}/rs911x/Rsi91xWifiInterface.cpp",
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c",
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_ioports.c",
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_timer.c",
"${examples_plat_dir}/rs911x/hal/efx_spi.c",
- "${silabs_common_plat_dir}/wifi/wfx_notify.cpp",
- "${silabs_common_plat_dir}/wifi/wfx_rsi_host.cpp",
+ "${silabs_common_plat_dir}/wifi/WifiInterfaceAbstraction.cpp",
]
#
@@ -59,4 +72,5 @@
"${examples_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x/hal",
"${wiseconnect_sdk_root}/sapi/include",
+ "${silabs_common_plat_dir}/wifi",
]
diff --git a/examples/platform/silabs/efr32/wf200/host_if.cpp b/examples/platform/silabs/efr32/wf200/Wf200WifiInterface.cpp
similarity index 100%
rename from examples/platform/silabs/efr32/wf200/host_if.cpp
rename to examples/platform/silabs/efr32/wf200/Wf200WifiInterface.cpp
diff --git a/examples/platform/silabs/efr32/wf200/sl_wfx_crypto.c b/examples/platform/silabs/efr32/wf200/sl_wfx_crypto.c
deleted file mode 100644
index ddad3ec..0000000
--- a/examples/platform/silabs/efr32/wf200/sl_wfx_crypto.c
+++ /dev/null
@@ -1,409 +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.
- */
-
-#ifdef SL_WFX_USE_SECURE_LINK
-
-/* Includes */
-
-#include "sl_wfx.h"
-#include <stdio.h>
-
-#include "mbedtls/ccm.h"
-#include "mbedtls/ctr_drbg.h"
-#include "mbedtls/ecdh.h"
-#include "mbedtls/entropy.h"
-#include "mbedtls/md.h"
-#include "mbedtls/sha256.h"
-
-#include "FreeRTOS.h"
-#include "queue.h"
-#include "semphr.h"
-#include "task.h"
-
-// Secure link MAC key location for WGM160P (in DI page in flash)
-#ifdef EFM32GG11B820F2048GM64 // WGM160PX22KGA2
-#define SL_WFX_FCCC_BASE_ADDR ((void *) 0x0fe08000ul)
-#define SL_WFX_FCCC_DI_OFFSET 0x1B0ul
-#define SL_WFX_FCCC_DI_ADDR ((void *) (SL_WFX_FCCC_BASE_ADDR + SL_WFX_FCCC_DI_OFFSET))
-#define SL_WFX_SECURE_LINK_MAC_KEY_LOCATION ((void *) (SL_WFX_FCCC_BASE_ADDR + 0x3D0))
-#endif
-/******************************************************
- * Macros
- ******************************************************/
-#define MAC_KEY_FAIL_BYTE 0XFF
-#define KEY_DIGEST_SIZE 92
-#define MEMCMP_FAIL 0
-#define MPI_SET 1
-#define SUCCESS_STATUS_WIFI_SECURE_LINK_EXCHANGE 0
-#define SHA224_0 0
-#define HMAC_SIZE 92
-#define MEMSET_LEN 1
-#define LABLE_LEN 24
-#define ADDRESS_LENGTH 0
-#define CCM_STATUS_SUCCESS 0
-/******************************************************
- * Constants
- ******************************************************/
-
-/* Semaphore to signal wfx driver available */
-extern TaskHandle_t wfx_securelink_task;
-extern SemaphoreHandle_t wfx_securelink_rx_mutex;
-
-/******************************************************
- * Enumerations
- ******************************************************/
-
-/******************************************************
- * Type Definitions
- ******************************************************/
-
-/******************************************************
- * Structures
- ******************************************************/
-
-/******************************************************
- * Function Declarations
- ******************************************************/
-
-static inline void reverse_bytes(uint8_t * src, uint8_t length);
-
-/******************************************************
- * Variable Definitions
- ******************************************************/
-
-#if SL_WFX_SLK_CURVE25519
-static mbedtls_ecdh_context mbedtls_host_context;
-static mbedtls_ctr_drbg_context host_drbg_context;
-#endif
-static mbedtls_entropy_context entropy;
-uint8_t temp_key_location[SL_WFX_HOST_PUB_KEY_MAC_SIZE];
-#ifdef EFM32GG11B820F2048GM64 // WGM160PX22KGA2
-static const uint8_t * const secure_link_mac_key = (uint8_t *) SL_WFX_SECURE_LINK_MAC_KEY_LOCATION;
-#else
-static const uint8_t secure_link_mac_key[SL_WFX_SECURE_LINK_MAC_KEY_LENGTH] = { 0x2B, 0x49, 0xFD, 0x66, 0xCB, 0x74, 0x6D, 0x6B,
- 0x4F, 0xDC, 0xC3, 0x79, 0x4E, 0xC5, 0x9A, 0x86,
- 0xE5, 0x48, 0x2A, 0x41, 0x22, 0x87, 0x8B, 0x12,
- 0x1A, 0x7C, 0x3E, 0xEF, 0xB7, 0x04, 0x9E, 0xB3 };
-#endif
-/******************************************************
- * Function Definitions
- ******************************************************/
-/****************************************************************************
- * @fn sl_status_t sl_wfx_host_get_secure_link_mac_key(uint8_t *sl_mac_key)
- * @brief
- * Get secure link mac key
- * @param[in] sl_mac_key:
- * @return returns SL_STATUS_OK
- *****************************************************************************/
-sl_status_t sl_wfx_host_get_secure_link_mac_key(uint8_t * sl_mac_key)
-{
- sl_status_t result = SL_STATUS_WIFI_SECURE_LINK_MAC_KEY_ERROR;
-
- memcpy(sl_mac_key, secure_link_mac_key, SL_WFX_SECURE_LINK_MAC_KEY_LENGTH);
-
- for (uint8_t index = 0; index < SL_WFX_SECURE_LINK_MAC_KEY_LENGTH; ++index)
- {
- // Assuming 0xFF... when not written
- if (sl_mac_key[index] != MAC_KEY_FAIL_BYTE)
- {
- result = SL_STATUS_OK;
- break;
- }
- }
-
- return result;
-}
-
-/****************************************************************************
- * @fn sl_status_t sl_wfx_host_compute_pub_key(sl_wfx_securelink_exchange_pub_keys_req_body_t *request,
- const uint8_t *sl_mac_key)
- * @brief
- * compute host public key
- * @param[in] request :
- * @param[in] sl_mac_key :
- * @return returns SL_STATUS_OK
- *****************************************************************************/
-sl_status_t sl_wfx_host_compute_pub_key(sl_wfx_securelink_exchange_pub_keys_req_body_t * request, const uint8_t * sl_mac_key)
-{
- sl_status_t status = SL_STATUS_OK;
-
-#if SL_WFX_SLK_CURVE25519
- const char identifier[] = "ecdh";
-
- mbedtls_ecdh_init(&mbedtls_host_context);
- mbedtls_ctr_drbg_init(&host_drbg_context);
- mbedtls_entropy_init(&entropy);
- status = mbedtls_ctr_drbg_seed(&host_drbg_context, mbedtls_entropy_func, &entropy, (const unsigned char *) identifier,
- sizeof(identifier));
- status += mbedtls_ecp_group_load(&mbedtls_host_context.grp, MBEDTLS_ECP_DP_CURVE25519);
- status += mbedtls_ecdh_gen_public(&mbedtls_host_context.grp, &mbedtls_host_context.d, &mbedtls_host_context.Q,
- mbedtls_ctr_drbg_random, &host_drbg_context);
- status += mbedtls_mpi_write_binary(&mbedtls_host_context.Q.X, request->host_pub_key, SL_WFX_HOST_PUB_KEY_SIZE);
-#else
- mbedtls_entropy_init(&entropy);
- status = mbedtls_entropy_func(&entropy, request->host_pub_key, SL_WFX_HOST_PUB_KEY_SIZE);
-#endif
- reverse_bytes(request->host_pub_key, SL_WFX_HOST_PUB_KEY_SIZE);
- SL_WFX_ERROR_CHECK(status);
-
- // Generate SHA512 digest of public key
- status = mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA512), sl_mac_key, SL_WFX_HOST_PUB_KEY_SIZE,
- request->host_pub_key, SL_WFX_HOST_PUB_KEY_SIZE, request->host_pub_key_mac);
- SL_WFX_ERROR_CHECK(status);
-
-error_handler:
- if (status != SL_STATUS_OK)
- {
- return SL_STATUS_WIFI_SECURE_LINK_EXCHANGE_FAILED;
- }
- return status;
-}
-
-/****************************************************************************
- * @fn sl_status_t sl_wfx_host_verify_pub_key(sl_wfx_securelink_exchange_pub_keys_ind_t *response_packet,
- const uint8_t *sl_mac_key,
- uint8_t *sl_host_pub_key)
- * @brief
- * verify host public key
- * @param[in] response_packet:
- * @param[in] sl_mac_key:
- * @param[in] sl_host_pub_key:
- * @return returns SL_STATUS_OK if successful,
- * SL_STATUS_FAIL otherwise
- *****************************************************************************/
-sl_status_t sl_wfx_host_verify_pub_key(sl_wfx_securelink_exchange_pub_keys_ind_t * response_packet, const uint8_t * sl_mac_key,
- uint8_t * sl_host_pub_key)
-{
- sl_status_t status = SL_STATUS_OK;
- uint8_t shared_key_digest[KEY_DIGEST_SIZE];
-
- if (xSemaphoreTake(wfx_securelink_rx_mutex, portMAX_DELAY) != pdTRUE)
- {
- return SL_STATUS_WIFI_SECURE_LINK_EXCHANGE_FAILED;
- }
-
- // Compute the Hash and verify the public key/hashing
- status = mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA512), sl_mac_key, SL_WFX_NCP_PUB_KEY_SIZE,
- response_packet->body.ncp_pub_key, SL_WFX_NCP_PUB_KEY_SIZE, temp_key_location);
- SL_WFX_ERROR_CHECK(status);
-
- // Calculate session key if public key/SHA512 digest matches
- if (memcmp(temp_key_location, response_packet->body.ncp_pub_key_mac, SL_WFX_HOST_PUB_KEY_MAC_SIZE) != MEMCMP_FAIL)
- {
- status = SL_STATUS_WIFI_SECURE_LINK_EXCHANGE_FAILED;
- goto error_handler;
- }
-
-#if SL_WFX_SLK_CURVE25519
- SL_WFX_UNUSED_PARAMETER(sl_host_pub_key);
-
- mbedtls_mpi_lset(&mbedtls_host_context.Qp.Z, MPI_SET);
-
- // Read Ineo public key
- reverse_bytes(response_packet->body.ncp_pub_key, SL_WFX_NCP_PUB_KEY_SIZE);
- mbedtls_mpi_read_binary(&mbedtls_host_context.Qp.X, response_packet->body.ncp_pub_key, SL_WFX_NCP_PUB_KEY_SIZE);
-
- // Calculate shared secret
- if (mbedtls_ecdh_compute_shared(&mbedtls_host_context.grp, &mbedtls_host_context.z, &mbedtls_host_context.Qp,
- &mbedtls_host_context.d, mbedtls_ctr_drbg_random,
- &host_drbg_context) != SUCCESS_STATUS_WIFI_SECURE_LINK_EXCHANGE)
- {
- status = SL_STATUS_WIFI_SECURE_LINK_EXCHANGE_FAILED;
- goto error_handler;
- }
-
- // Generate session key
- mbedtls_mpi_write_binary(&mbedtls_host_context.z, temp_key_location, SL_WFX_HOST_PUB_KEY_SIZE);
- reverse_bytes(temp_key_location, SL_WFX_HOST_PUB_KEY_SIZE);
- mbedtls_sha256(temp_key_location, SL_WFX_HOST_PUB_KEY_SIZE, shared_key_digest, SHA224_0);
-#else
- uint8_t hmac_input[HMAC_SIZE] = { 0 };
- char label[LABLE_LEN] = "SecureLink!KeyDerivation";
-
- memset((uint16_t *) &hmac_input[0], (uint16_t) sl_wfx_htole16(1), MEMSET_LEN);
- memcpy((uint8_t *) &hmac_input[2], (uint8_t *) label, LABLE_LEN);
- memcpy((uint8_t *) &hmac_input[26], sl_host_pub_key, SL_WFX_NCP_PUB_KEY_SIZE);
- memcpy((uint8_t *) &hmac_input[58], (uint8_t *) response_packet->body.ncp_pub_key, SL_WFX_NCP_PUB_KEY_SIZE);
- memset((uint16_t *) &hmac_input[90], (uint16_t) sl_wfx_htole16(128), 1);
-
- // Generate SHA256 digest of hmac_input
- status = mbedtls_md_hmac(mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), sl_mac_key, SL_WFX_HOST_PUB_KEY_SIZE,
- (uint8_t *) hmac_input, HMAC_SIZE, shared_key_digest);
-#endif
-
- memcpy(sl_wfx_context->secure_link_session_key, shared_key_digest,
- SL_WFX_SECURE_LINK_SESSION_KEY_LENGTH); // Use the lower 16 bytes of the sha256
- sl_wfx_context->secure_link_nonce.hp_packet_count = 0;
- sl_wfx_context->secure_link_nonce.rx_packet_count = 0;
- sl_wfx_context->secure_link_nonce.tx_packet_count = 0;
-
-error_handler:
- if (xSemaphoreGive(wfx_securelink_rx_mutex) != pdTRUE)
- {
- printf("ERROR: sl_wfx_securelink_rx_mutex. unable to post.\n");
- }
- return status;
-}
-
-/****************************************************************************
- * @fn sl_status_t sl_wfx_host_free_crypto_context(void)
- * @brief
- * Free host crypto context
- * @param[in] None
- * @return returns SL_STATUS_OK
- *****************************************************************************/
-sl_status_t sl_wfx_host_free_crypto_context(void)
-{
-#if SL_WFX_SLK_CURVE25519
- mbedtls_ecdh_free(&mbedtls_host_context);
- mbedtls_ctr_drbg_free(&host_drbg_context);
-#endif
- mbedtls_entropy_free(&entropy);
-
- return SL_STATUS_OK;
-}
-
-/********************************************************************************
- * @fn sl_status_t sl_wfx_host_decode_secure_link_data(uint8_t *buffer, uint32_t length, uint8_t *session_key)
- * @brief
- * Decode receive data
- * Length excludes size of CCM tag and secure link header
- * @param[in] buffer:
- * @param[in] length:
- * @param[in] session_key:
- * @return returns SL_STATUS_OK if successful,
- * SL_STATUS_FAIL otherwise
- ********************************************************************************/
-sl_status_t sl_wfx_host_decode_secure_link_data(uint8_t * buffer, uint32_t length, uint8_t * session_key)
-{
- mbedtls_ccm_context ccm_context;
- sl_status_t status = SL_STATUS_SECURITY_DECRYPT_ERROR;
- int crypto_status;
- sl_wfx_nonce_t nonce = { 0, 0, 0 };
-
- if (xSemaphoreTake(wfx_securelink_rx_mutex, portMAX_DELAY) != pdTRUE)
- {
- return SL_STATUS_FAIL;
- }
-
- // Nonce for decryption should have TX and HP counters 0, only use RX counter
- nonce.rx_packet_count = sl_wfx_context->secure_link_nonce.rx_packet_count;
-
- // Init context
- mbedtls_ccm_init(&ccm_context);
-
- // Set the crypto key
- crypto_status = mbedtls_ccm_setkey(&ccm_context, MBEDTLS_CIPHER_ID_AES, session_key, SL_WFX_SECURE_LINK_SESSION_KEY_BIT_COUNT);
- SL_WFX_ERROR_CHECK(crypto_status);
-
- // Decrypt the data
- if (!mbedtls_ccm_auth_decrypt(&ccm_context, length, (uint8_t *) &nonce, SL_WFX_SECURE_LINK_NONCE_SIZE_BYTES, NULL,
- ADDRESS_LENGTH, (uint8_t *) buffer, (uint8_t *) buffer, (uint8_t *) buffer + length,
- SL_WFX_SECURE_LINK_CCM_TAG_SIZE))
- {
- status = SL_STATUS_OK;
- }
-
-error_handler:
- mbedtls_ccm_free(&ccm_context);
- if (xSemaphoreGive(wfx_securelink_rx_mutex) != pdTRUE)
- {
- printf("ERROR: sl_wfx_securelink_rx_mutex. unable to post.\n");
- }
- return status;
-}
-
-/*********************************************************************
- * @fn sl_status_t sl_wfx_host_encode_secure_link_data(sl_wfx_generic_message_t *buffer,
- uint32_t data_length,
- uint8_t *session_key,
- uint8_t *nonce)
- * @brief
- * Encode transmit data
- * Length excludes size of CCM tag and secure link header
- * @param[in] buffer:
- * @param[in] data_length:
- * @param[in] session_key:
- * @param[in] nonce:
- * @return returns SL_STATUS_OK if successful,
- * SL_STATUS_FAIL otherwise
-*************************************************************************/
-sl_status_t sl_wfx_host_encode_secure_link_data(sl_wfx_generic_message_t * buffer, uint32_t data_length, uint8_t * session_key,
- uint8_t * nonce)
-{
- mbedtls_ccm_context ccm_context;
- sl_status_t status = SL_STATUS_FAIL;
-
- mbedtls_ccm_init(&ccm_context);
- if (mbedtls_ccm_setkey(&ccm_context, MBEDTLS_CIPHER_ID_AES, session_key, SL_WFX_SECURE_LINK_SESSION_KEY_BIT_COUNT) ==
- CCM_STATUS_SUCCESS)
- {
- mbedtls_ccm_encrypt_and_tag(&ccm_context, data_length, nonce, SL_WFX_SECURE_LINK_NONCE_SIZE_BYTES, NULL, ADDRESS_LENGTH,
- (uint8_t *) &buffer->header.id, (uint8_t *) &buffer->header.id,
- (uint8_t *) &buffer->header.id + data_length, SL_WFX_SECURE_LINK_CCM_TAG_SIZE);
- status = SL_STATUS_OK;
- }
-
- mbedtls_ccm_free(&ccm_context);
-
- return status;
-}
-
-/****************************************************************************
- * @fn sl_status_t sl_wfx_host_schedule_secure_link_renegotiation(void)
- * @brief
- * Called when the driver needs to schedule secure link renegotiation
- * @param[in] None
- * @returns Returns SL_STATUS_OK if successful,
- * SL_STATUS_FAIL otherwise
- *****************************************************************************/
-sl_status_t sl_wfx_host_schedule_secure_link_renegotiation(void)
-{
- // call sl_wfx_secure_link_renegotiate_session_key() as soon as it makes sense for the host to do so
- xTaskNotifyGive(wfx_securelink_task);
- return SL_STATUS_OK;
-}
-
-/****************************************************************************
- * @fn static inline void reverse_bytes(uint8_t *src, uint8_t length)
- * @brief
- * reverse the bytes
- * @param[in] src: source
- * @param[in] length:
- * @returns None
- *****************************************************************************/
-static inline void reverse_bytes(uint8_t * src, uint8_t length)
-{
- uint8_t * lo = src;
- uint8_t * hi = src + length - 1;
- uint8_t swap;
-
- while (lo < hi)
- {
- swap = *lo;
- *lo++ = *hi;
- *hi-- = swap;
- }
-}
-
-/********************************************************************************************************
- ********************************************************************************************************
- * DEPENDENCIES & AVAIL CHECK(S)
- ********************************************************************************************************
- *******************************************************************************************************/
-
-#endif // SL_WFX_USE_SECURE_LINK
diff --git a/examples/platform/silabs/efr32/wf200/sl_wfx_securelink_task.c b/examples/platform/silabs/efr32/wf200/sl_wfx_securelink_task.c
deleted file mode 100644
index 28ffdda..0000000
--- a/examples/platform/silabs/efr32/wf200/sl_wfx_securelink_task.c
+++ /dev/null
@@ -1,85 +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.
- */
-
-#ifdef SL_WFX_USE_SECURE_LINK
-#include "secure_link/sl_wfx_secure_link.h"
-
-#include "FreeRTOS.h"
-#include "queue.h"
-#include "semphr.h"
-#include "task.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-// Securelink Task Configurations
-#define WFX_SECURELINK_TASK_PRIO 1u
-#define WFX_SECURELINK_TASK_STK_SIZE 512u
-
-TaskHandle_t secureLinkTaskHandle;
-SemaphoreHandle_t s_xSLSemaphore;
-StackType_t secureLinkStack[WFX_SECURELINK_TASK_STK_SIZE];
-StaticTask_t secureLinkTaskStruct;
-
-StaticSemaphore_t xSlMutexBuffer;
-
-/*********************************************************************
- * @fn static void prvSecureLinkTask(void *p_arg)
- * @brief
- * The task that implements the Secure Link renegotiation with WFX.
- * @param[in] p_arg:
- * @return None
- *************************************************************************/
-static void prvSecureLinkTask(void * p_arg)
-{
- sl_status_t result;
- (void) p_arg;
-
- /* Create a mutex used for making Secure Link renegotiations atomic */
- s_xSLSemaphore = xSemaphoreCreateMutexStatic(&xSlMutexBuffer);
-
- for (;;)
- {
- /* Wait for a key renegotiation request */
- ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
-
- result = sl_wfx_secure_link_renegotiate_session_key();
- if (result != SL_STATUS_OK)
- {
- printf("session key negotiation error %lu\n", result);
- }
- }
-}
-
-/****************************************************************************
- * @fn void wfx_securelink_task_start(void)
- * @brief
- * Creates WFX securelink key renegotiation task.
- * @param[in] None
- * @return None
- ******************************************************************************/
-void wfx_securelink_task_start(void)
-{
- secureLinkTaskHandle = xTaskCreateStatic(prvSecureLinkTask, "secureLinkTask", WFX_SECURELINK_TASK_STK_SIZE, NULL,
- WFX_SECURELINK_TASK_PRIO, secureLinkStack, &secureLinkTaskStruct);
- if (secureLinkTaskHandle == NULL)
- {
- printf("Failed to create WFX secureLinkTask");
- }
-}
-
-#endif
diff --git a/examples/platform/silabs/efr32/wf200/wf200.gni b/examples/platform/silabs/efr32/wf200/wf200.gni
index f904f74..c7ebbb8 100644
--- a/examples/platform/silabs/efr32/wf200/wf200.gni
+++ b/examples/platform/silabs/efr32/wf200/wf200.gni
@@ -1,12 +1,30 @@
+# Copyright (c) 2024 Project CHIP Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("${silabs_sdk_build_root}/efr32_sdk.gni")
-wf200_plat_incs = [ "${examples_plat_dir}/wf200" ]
+wf200_plat_incs = [
+ "${examples_plat_dir}/wf200",
+ "${silabs_common_plat_dir}/wifi",
+]
+
wf200_plat_src = [
- "${silabs_common_plat_dir}/wifi/wfx_notify.cpp",
"${examples_plat_dir}/wf200/sl_wfx_task.c",
"${examples_plat_dir}/wf200/wf200_init.c",
"${examples_plat_dir}/wf200/efr_spi.c",
- "${examples_plat_dir}/wf200/host_if.cpp",
+ "${examples_plat_dir}/wf200/Wf200WifiInterface.cpp",
+ "${silabs_common_plat_dir}/wifi/WifiInterfaceAbstraction.cpp",
]
diff --git a/examples/platform/silabs/wifi/wfx_rsi_host.cpp b/examples/platform/silabs/wifi/WifiInterfaceAbstraction.cpp
similarity index 64%
rename from examples/platform/silabs/wifi/wfx_rsi_host.cpp
rename to examples/platform/silabs/wifi/WifiInterfaceAbstraction.cpp
index 3263d88..0a21244 100644
--- a/examples/platform/silabs/wifi/wfx_rsi_host.cpp
+++ b/examples/platform/silabs/wifi/WifiInterfaceAbstraction.cpp
@@ -17,30 +17,38 @@
// SL MATTER WI-FI INTERFACE
+#include "WifiInterfaceAbstraction.h"
+#include "silabs_utils.h"
+#include "wfx_host_events.h"
+#include <app/icd/server/ICDServerConfig.h>
+#include <lib/support/CHIPMem.h>
+#include <lib/support/CHIPMemString.h>
+#include <lib/support/CodeUtils.h>
+#include <lib/support/logging/CHIPLogging.h>
+#include <platform/CHIPDeviceLayer.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "FreeRTOS.h"
-#include "event_groups.h"
-#include "task.h"
+using namespace chip;
+using namespace chip::DeviceLayer;
-#include <lib/support/CHIPMem.h>
-#include <lib/support/CHIPMemString.h>
-#include <lib/support/CodeUtils.h>
-#include <lib/support/logging/CHIPLogging.h>
+namespace {
-#include "wfx_host_events.h"
-#include "wfx_rsi.h"
+constexpr uint8_t kWlanMinRetryIntervalsInSec = 1;
+constexpr uint8_t kWlanMaxRetryIntervalsInSec = 60;
+constexpr uint8_t kWlanRetryIntervalInSec = 5;
+uint8_t retryInterval = kWlanMinRetryIntervalsInSec;
+osTimerId_t sRetryTimer;
-#include <platform/CHIPDeviceLayer.h>
-
+// TODO: Remove this when the full abstraction is implemented
+#ifdef RS911X_WIFI
// Thread for the WLAN RSI
-static osThreadId_t sWlanThread;
+osThreadId_t sWlanThread;
constexpr uint32_t kWlanTaskSize = 2048;
-static uint8_t wlanStack[kWlanTaskSize];
-static osThread_t sWlanTaskControlBlock;
+uint8_t wlanStack[kWlanTaskSize];
+osThread_t sWlanTaskControlBlock;
constexpr osThreadAttr_t kWlanTaskAttr = { .name = "wlan_rsi",
.attr_bits = osThreadDetached,
.cb_mem = &sWlanTaskControlBlock,
@@ -48,7 +56,27 @@
.stack_mem = wlanStack,
.stack_size = kWlanTaskSize,
.priority = osPriorityAboveNormal7 };
+#endif // RS911X_WIFI
+/*
+ * Notifications to the upper-layer
+ * All done in the context of the RSI/WiFi task (rsi_if.c)
+ */
+void RetryConnectionTimerHandler(void * arg)
+{
+#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
+ wfx_rsi_power_save(RSI_ACTIVE, HIGH_PERFORMANCE);
+#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
+ if (wfx_connect_to_ap() != SL_STATUS_OK)
+ {
+ ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
+ }
+}
+
+} // namespace
+
+// TODO: Remove this when the full abstraction is implemented
+#ifdef RS911X_WIFI
/*********************************************************************
* @fn sl_status_t wfx_wifi_start(void)
* @brief
@@ -397,3 +425,172 @@
ChipLogError(DeviceLayer, "cannot cancel scan");
}
#endif /* SL_WFX_CONFIG_SCAN */
+#endif // RS911X_WIFI
+
+/***********************************************************************************
+ * @fn sl_matter_wifi_task_started(void)
+ * @brief
+ * Wifi device started notification
+ * @param[in]: None
+ * @return None
+ *************************************************************************************/
+void sl_matter_wifi_task_started(void)
+{
+ sl_wfx_startup_ind_t evt;
+ sl_wfx_mac_address_t mac;
+
+ // Creating a timer which will be used to retry connection with AP
+ sRetryTimer = osTimerNew(RetryConnectionTimerHandler, osTimerOnce, NULL, NULL);
+ VerifyOrReturn(sRetryTimer != NULL);
+
+ memset(&evt, 0, sizeof(evt));
+ evt.header.id = SL_WFX_STARTUP_IND_ID;
+ evt.header.length = sizeof evt;
+ evt.body.status = 0;
+ wfx_get_wifi_mac_addr(SL_WFX_STA_INTERFACE, &mac);
+ memcpy(&evt.body.mac_addr[0], &mac.octet[0], MAC_ADDRESS_FIRST_OCTET);
+
+ PlatformMgrImpl().HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt);
+}
+
+/***********************************************************************************
+ * @fn void wfx_connected_notify(int32_t status, sl_wfx_mac_address_t *ap)
+ * @brief
+ * For now we are not notifying anything other than AP Mac -
+ * Other stuff such as DTIM etc. may be required for later
+ * @param[in] status:
+ * @param[in] ap: access point
+ * @return None
+ *************************************************************************************/
+void wfx_connected_notify(int32_t status, sl_wfx_mac_address_t * ap)
+{
+ sl_wfx_connect_ind_t evt;
+
+ VerifyOrReturn(status == SUCCESS_STATUS);
+
+ memset(&evt, 0, sizeof(evt));
+ evt.header.id = SL_WFX_CONNECT_IND_ID;
+ evt.header.length = sizeof evt;
+
+#ifdef RS911X_WIFI
+ evt.body.channel = wfx_rsi.ap_chan;
+#endif
+ memcpy(&evt.body.mac[0], &ap->octet[0], MAC_ADDRESS_FIRST_OCTET);
+
+ PlatformMgrImpl().HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt);
+}
+
+/**************************************************************************************
+ * @fn void wfx_disconnected_notify(int32_t status)
+ * @brief
+ * notification of disconnection
+ * @param[in] status:
+ * @return None
+ ********************************************************************************************/
+void wfx_disconnected_notify(int32_t status)
+{
+ sl_wfx_disconnect_ind_t evt;
+
+ memset(&evt, 0, sizeof(evt));
+ evt.header.id = SL_WFX_DISCONNECT_IND_ID;
+ evt.header.length = sizeof evt;
+ evt.body.reason = status;
+ PlatformMgrImpl().HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt);
+}
+
+/**************************************************************************************
+ * @fn void wfx_ipv6_notify(int got_ip)
+ * @brief
+ * notification of ipv6
+ * @param[in] got_ip:
+ * @return None
+ ********************************************************************************************/
+void wfx_ipv6_notify(int got_ip)
+{
+ sl_wfx_generic_message_t eventData;
+
+ memset(&eventData, 0, sizeof(eventData));
+ eventData.header.id = got_ip ? IP_EVENT_GOT_IP6 : IP_EVENT_STA_LOST_IP;
+ eventData.header.length = sizeof(eventData.header);
+ PlatformMgrImpl().HandleWFXSystemEvent(IP_EVENT, &eventData);
+}
+
+/**************************************************************************************
+ * @fn void wfx_ip_changed_notify(int got_ip)
+ * @brief
+ * notification of ip change
+ * @param[in] got_ip:
+ * @return None
+ ********************************************************************************************/
+void wfx_ip_changed_notify(int got_ip)
+{
+ sl_wfx_generic_message_t eventData;
+
+ memset(&eventData, 0, sizeof(eventData));
+ eventData.header.id = got_ip ? IP_EVENT_STA_GOT_IP : IP_EVENT_STA_LOST_IP;
+ eventData.header.length = sizeof(eventData.header);
+ PlatformMgrImpl().HandleWFXSystemEvent(IP_EVENT, &eventData);
+}
+
+/**************************************************************************************
+ * @fn void wfx_retry_connection(uint16_t retryAttempt)
+ * @brief
+ * During commissioning, we retry to join the network MAX_JOIN_RETRIES_COUNT times.
+ * If DUT is disconnected from the AP or device is power cycled, then retry connection
+ * with AP continously after a certain time interval.
+ * @param[in] retryAttempt
+ * @return None
+ ********************************************************************************************/
+void wfx_retry_connection(uint16_t retryAttempt)
+{
+ // During commissioning, we retry to join the network MAX_JOIN_RETRIES_COUNT
+ if (/*BaseApplication::sAppDelegate.isCommissioningInProgress()*/ true)
+ {
+ if (retryAttempt < MAX_JOIN_RETRIES_COUNT)
+ {
+ ChipLogProgress(DeviceLayer, "wfx_retry_connection : Next attempt after %d Seconds", kWlanRetryIntervalInSec);
+ if (osTimerStart(sRetryTimer, pdMS_TO_TICKS(CONVERT_SEC_TO_MS(kWlanRetryIntervalInSec))) != osOK)
+ {
+ ChipLogProgress(DeviceLayer, "Failed to start retry timer");
+ // Sending the join command if retry timer failed to start
+ if (wfx_connect_to_ap() != SL_STATUS_OK)
+ {
+ ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
+ }
+ return;
+ }
+ }
+ else
+ {
+ ChipLogProgress(DeviceLayer, "Connect failed after max %d tries", retryAttempt);
+ }
+ }
+ else
+ {
+ /* After disconnection or power cycle the DUT
+ * At the telescopic time interval device try to reconnect with AP, upto WLAN_MAX_RETRY_TIMER_MS intervals
+ * are telescopic. If interval exceed WLAN_MAX_RETRY_TIMER_MS then it will try to reconnect at
+ * WLAN_MAX_RETRY_TIMER_MS intervals.
+ */
+ if (retryInterval > kWlanMaxRetryIntervalsInSec)
+ {
+ retryInterval = kWlanMaxRetryIntervalsInSec;
+ }
+ if (osTimerStart(sRetryTimer, pdMS_TO_TICKS(CONVERT_SEC_TO_MS(retryInterval))) != osOK)
+ {
+ ChipLogProgress(DeviceLayer, "Failed to start retry timer");
+ // Sending the join command if retry timer failed to start
+ if (wfx_connect_to_ap() != SL_STATUS_OK)
+ {
+ ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
+ }
+ return;
+ }
+#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
+ wfx_rsi_power_save(RSI_SLEEP_MODE_8, STANDBY_POWER_SAVE_WITH_RAM_RETENTION);
+#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
+ ChipLogProgress(DeviceLayer, "wfx_retry_connection : Next attempt after %d Seconds", retryInterval);
+ retryInterval += retryInterval;
+ return;
+ }
+}
diff --git a/examples/platform/silabs/wfx_rsi.h b/examples/platform/silabs/wifi/WifiInterfaceAbstraction.h
similarity index 97%
rename from examples/platform/silabs/wfx_rsi.h
rename to examples/platform/silabs/wifi/WifiInterfaceAbstraction.h
index 4ef6bd2..a26ead2 100644
--- a/examples/platform/silabs/wfx_rsi.h
+++ b/examples/platform/silabs/wifi/WifiInterfaceAbstraction.h
@@ -18,14 +18,9 @@
#include <app/icd/server/ICDServerConfig.h>
#include <cmsis_os2.h>
-#include <event_groups.h>
#include <sl_cmsis_os2_common.h>
#include <wfx_host_events.h>
-#ifndef RSI_BLE_ENABLE
-#define RSI_BLE_ENABLE (1)
-#endif
-
/*
* Interface to RSI Sapis
*/
diff --git a/examples/platform/silabs/wifi/wfx_notify.cpp b/examples/platform/silabs/wifi/wfx_notify.cpp
deleted file mode 100644
index fe097a6..0000000
--- a/examples/platform/silabs/wifi/wfx_notify.cpp
+++ /dev/null
@@ -1,228 +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 "AppConfig.h"
-#include "BaseApplication.h"
-#include <app/icd/server/ICDServerConfig.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "FreeRTOS.h"
-#include "event_groups.h"
-#include "silabs_utils.h"
-#include "task.h"
-#include "wfx_host_events.h"
-
-#ifdef RS911X_WIFI
-#include "wfx_rsi.h"
-#endif
-
-#include <platform/CHIPDeviceLayer.h>
-
-using namespace ::chip;
-using namespace ::chip::DeviceLayer;
-
-namespace {
-constexpr uint8_t kWlanMinRetryIntervalsInSec = 1;
-constexpr uint8_t kWlanMaxRetryIntervalsInSec = 60;
-constexpr uint8_t kWlanRetryIntervalInSec = 5;
-uint8_t retryInterval = kWlanMinRetryIntervalsInSec;
-osTimerId_t sRetryTimer;
-} // namespace
-/*
- * Notifications to the upper-layer
- * All done in the context of the RSI/WiFi task (rsi_if.c)
- */
-
-static void RetryConnectionTimerHandler(void * arg)
-{
-#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
- wfx_rsi_power_save(RSI_ACTIVE, HIGH_PERFORMANCE);
-#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
- if (wfx_connect_to_ap() != SL_STATUS_OK)
- {
- ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
- }
-}
-/***********************************************************************************
- * @fn sl_matter_wifi_task_started(void)
- * @brief
- * Wifi device started notification
- * @param[in]: None
- * @return None
- *************************************************************************************/
-void sl_matter_wifi_task_started(void)
-{
- sl_wfx_startup_ind_t evt;
- sl_wfx_mac_address_t mac;
-
- // Creating a timer which will be used to retry connection with AP
- sRetryTimer = osTimerNew(RetryConnectionTimerHandler, osTimerOnce, NULL, NULL);
- VerifyOrReturn(sRetryTimer != NULL);
-
- memset(&evt, 0, sizeof(evt));
- evt.header.id = SL_WFX_STARTUP_IND_ID;
- evt.header.length = sizeof evt;
- evt.body.status = 0;
- wfx_get_wifi_mac_addr(SL_WFX_STA_INTERFACE, &mac);
- memcpy(&evt.body.mac_addr[0], &mac.octet[0], MAC_ADDRESS_FIRST_OCTET);
-
- PlatformMgrImpl().HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt);
-}
-
-/***********************************************************************************
- * @fn void wfx_connected_notify(int32_t status, sl_wfx_mac_address_t *ap)
- * @brief
- * For now we are not notifying anything other than AP Mac -
- * Other stuff such as DTIM etc. may be required for later
- * @param[in] status:
- * @param[in] ap: access point
- * @return None
- *************************************************************************************/
-void wfx_connected_notify(int32_t status, sl_wfx_mac_address_t * ap)
-{
- sl_wfx_connect_ind_t evt;
-
- VerifyOrReturn(status == SUCCESS_STATUS);
-
- memset(&evt, 0, sizeof(evt));
- evt.header.id = SL_WFX_CONNECT_IND_ID;
- evt.header.length = sizeof evt;
-
-#ifdef RS911X_WIFI
- evt.body.channel = wfx_rsi.ap_chan;
-#endif
- memcpy(&evt.body.mac[0], &ap->octet[0], MAC_ADDRESS_FIRST_OCTET);
-
- PlatformMgrImpl().HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt);
-}
-
-/**************************************************************************************
- * @fn void wfx_disconnected_notify(int32_t status)
- * @brief
- * notification of disconnection
- * @param[in] status:
- * @return None
- ********************************************************************************************/
-void wfx_disconnected_notify(int32_t status)
-{
- sl_wfx_disconnect_ind_t evt;
-
- memset(&evt, 0, sizeof(evt));
- evt.header.id = SL_WFX_DISCONNECT_IND_ID;
- evt.header.length = sizeof evt;
- evt.body.reason = status;
- PlatformMgrImpl().HandleWFXSystemEvent(WIFI_EVENT, (sl_wfx_generic_message_t *) &evt);
-}
-
-/**************************************************************************************
- * @fn void wfx_ipv6_notify(int got_ip)
- * @brief
- * notification of ipv6
- * @param[in] got_ip:
- * @return None
- ********************************************************************************************/
-void wfx_ipv6_notify(int got_ip)
-{
- sl_wfx_generic_message_t eventData;
-
- memset(&eventData, 0, sizeof(eventData));
- eventData.header.id = got_ip ? IP_EVENT_GOT_IP6 : IP_EVENT_STA_LOST_IP;
- eventData.header.length = sizeof(eventData.header);
- PlatformMgrImpl().HandleWFXSystemEvent(IP_EVENT, &eventData);
-}
-
-/**************************************************************************************
- * @fn void wfx_ip_changed_notify(int got_ip)
- * @brief
- * notification of ip change
- * @param[in] got_ip:
- * @return None
- ********************************************************************************************/
-void wfx_ip_changed_notify(int got_ip)
-{
- sl_wfx_generic_message_t eventData;
-
- memset(&eventData, 0, sizeof(eventData));
- eventData.header.id = got_ip ? IP_EVENT_STA_GOT_IP : IP_EVENT_STA_LOST_IP;
- eventData.header.length = sizeof(eventData.header);
- PlatformMgrImpl().HandleWFXSystemEvent(IP_EVENT, &eventData);
-}
-
-/**************************************************************************************
- * @fn void wfx_retry_connection(uint16_t retryAttempt)
- * @brief
- * During commissioning, we retry to join the network MAX_JOIN_RETRIES_COUNT times.
- * If DUT is disconnected from the AP or device is power cycled, then retry connection
- * with AP continously after a certain time interval.
- * @param[in] retryAttempt
- * @return None
- ********************************************************************************************/
-void wfx_retry_connection(uint16_t retryAttempt)
-{
- // During commissioning, we retry to join the network MAX_JOIN_RETRIES_COUNT
- if (BaseApplication::sAppDelegate.isCommissioningInProgress())
- {
- if (retryAttempt < MAX_JOIN_RETRIES_COUNT)
- {
- ChipLogProgress(DeviceLayer, "wfx_retry_connection : Next attempt after %d Seconds", kWlanRetryIntervalInSec);
- if (osTimerStart(sRetryTimer, pdMS_TO_TICKS(CONVERT_SEC_TO_MS(kWlanRetryIntervalInSec))) != osOK)
- {
- ChipLogProgress(DeviceLayer, "Failed to start retry timer");
- // Sending the join command if retry timer failed to start
- if (wfx_connect_to_ap() != SL_STATUS_OK)
- {
- ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
- }
- return;
- }
- }
- else
- {
- ChipLogProgress(DeviceLayer, "Connect failed after max %d tries", retryAttempt);
- }
- }
- else
- {
- /* After disconnection or power cycle the DUT
- * At the telescopic time interval device try to reconnect with AP, upto WLAN_MAX_RETRY_TIMER_MS intervals
- * are telescopic. If interval exceed WLAN_MAX_RETRY_TIMER_MS then it will try to reconnect at
- * WLAN_MAX_RETRY_TIMER_MS intervals.
- */
- if (retryInterval > kWlanMaxRetryIntervalsInSec)
- {
- retryInterval = kWlanMaxRetryIntervalsInSec;
- }
- if (osTimerStart(sRetryTimer, pdMS_TO_TICKS(CONVERT_SEC_TO_MS(retryInterval))) != osOK)
- {
- ChipLogProgress(DeviceLayer, "Failed to start retry timer");
- // Sending the join command if retry timer failed to start
- if (wfx_connect_to_ap() != SL_STATUS_OK)
- {
- ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
- }
- return;
- }
-#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
- wfx_rsi_power_save(RSI_SLEEP_MODE_8, STANDBY_POWER_SAVE_WITH_RAM_RETENTION);
-#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
- ChipLogProgress(DeviceLayer, "wfx_retry_connection : Next attempt after %d Seconds", retryInterval);
- retryInterval += retryInterval;
- return;
- }
-}
diff --git a/src/platform/silabs/rs911x/wfx_sl_ble_init.h b/src/platform/silabs/rs911x/wfx_sl_ble_init.h
index 5435167..7fd9fc9 100644
--- a/src/platform/silabs/rs911x/wfx_sl_ble_init.h
+++ b/src/platform/silabs/rs911x/wfx_sl_ble_init.h
@@ -22,14 +22,10 @@
*/
#pragma once
-/**
- * Include files
- * */
// BLE include file to refer BLE APIs
#include "ble_config.h"
#include "cmsis_os2.h"
#include "wfx_host_events.h"
-#include "wfx_rsi.h"
#include <rsi_ble.h>
#include <rsi_ble_apis.h>
#include <rsi_ble_common_config.h>