Skip to content

Commit 925e30c

Browse files
mkardous-silabsrestyled-commits
authored andcommitted
[Silabs] General updates and fixes for the Silabs Wi-Fi platforms (#36628)
* [SL-UP] Remove two algo design for the wifi retry mechanism (#103) * [SL-UP] Rename ot interval to transport interval (#108) * [SL-UP] Delete unnecessary double abstraction for the wiseconnect power save functions (#109) * [SL-UP] Update spi-multiplex header inclusion (#110) * [SL-UP] Fix Builds after Wi-Fi interface refactor (#111) * [SL-UP] Remove WF200 define duplication to avoid value conflicts at runtime (#126) * fix spacing * restyle * Fix define name * add missing function * Fix wf200 ICD build * Restyled by clang-format * Add debug config * Re added sem check --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 783350d commit 925e30c

File tree

27 files changed

+132
-209
lines changed

27 files changed

+132
-209
lines changed

examples/light-switch-app/silabs/openthread.gni

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ chip_subscription_timeout_resumption = false
3636
sl_use_subscription_syncing = true
3737

3838
# Openthread Configuration flags
39-
sl_ot_idle_interval_ms = 2100000 # 35 minutes Idle Intervals
40-
sl_ot_active_interval_ms = 1000 # 1000ms Active Intervals
39+
sl_transport_idle_interval_ms = 2100000 # 35 minutes Idle Intervals
40+
sl_transport_active_interval_ms = 1000 # 1000ms Active Intervals
4141

4242
# ICD Matter Configuration flags
4343
sl_idle_mode_duration_s = 1800 # 30min Idle Mode Duration

examples/lit-icd-app/silabs/openthread.gni

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ chip_enable_icd_lit = true
3737
chip_enable_icd_dsls = true
3838

3939
# Openthread Configuration flags
40-
sl_ot_idle_interval_ms = 3600000 # 60mins Idle Polling Interval
41-
sl_ot_active_interval_ms = 1000 # 1000ms Active Polling Interval
40+
sl_transport_idle_interval_ms = 3600000 # 60mins Idle Polling Interval
41+
sl_transport_active_interval_ms = 1000 # 1000ms Active Polling Interval
4242

4343
# ICD Matter Configuration flags
4444
sl_idle_mode_duration_s = 3600 # 60min Idle Mode Duration

examples/lock-app/silabs/openthread.gni

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ chip_subscription_timeout_resumption = false
3333
sl_use_subscription_syncing = true
3434

3535
# Openthread Configuration flags
36-
sl_ot_idle_interval_ms = 5000 # 5s Idle Intervals
37-
sl_ot_active_interval_ms = 500 # 500ms Active Intervals
36+
sl_transport_idle_interval_ms = 5000 # 5s Idle Intervals
37+
sl_transport_active_interval_ms = 500 # 500ms Active Intervals
3838

3939
# ICD Matter Configuration flags
4040
sl_idle_mode_duration_s = 600 # 10min Idle Mode Duration

examples/platform/silabs/efr32/project_include/OpenThreadConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 0
4141

4242
// In seconds
43-
#define SL_MLE_TIMEOUT_s (SL_OT_IDLE_INTERVAL / 1000)
43+
#define SL_MLE_TIMEOUT_s (SL_TRANSPORT_IDLE_INTERVAL / 1000)
4444

4545
// Timeout after 2 missed checkin or 4 mins if sleep interval is too short.
4646
#define OPENTHREAD_CONFIG_MLE_CHILD_TIMEOUT_DEFAULT ((SL_MLE_TIMEOUT_s < 120) ? 240 : ((SL_MLE_TIMEOUT_s * 2) + 1))

examples/platform/silabs/uart.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extern "C" {
5353
#endif
5454
#include "sl_uartdrv_instances.h"
5555
#if SL_WIFI
56-
#include "spi_multiplex.h"
56+
#include <platform/silabs/wifi/wf200/platform/spi_multiplex.h>
5757
#endif // SL_WIFI
5858
#ifdef SL_CATALOG_UARTDRV_EUSART_PRESENT
5959
#include "sl_uartdrv_eusart_vcom_config.h"

examples/refrigerator-app/silabs/src/RefrigeratorUI.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
#include "lcd.h"
2727
#include <lib/support/logging/CHIPLogging.h>
2828

29-
#if SL_WIFI && !defined(SLI_SI91X_MCU_INTERFACE)
3029
// Only needed for wifi NCP devices
31-
#include "spi_multiplex.h"
32-
#endif // SL_WIFI
30+
#if SL_WIFI && !defined(SLI_SI91X_MCU_INTERFACE)
31+
#include <platform/silabs/wifi/wf200/platform/spi_multiplex.h>
32+
#endif // SL_WIFI && !defined(SLI_SI91X_MCU_INTERFACE)
3333

3434
// LCD line define
3535
constexpr uint8_t kTempLcdInitialX = 30;

examples/smoke-co-alarm-app/silabs/openthread.gni

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ chip_icd_report_on_active_mode = true
3636
chip_enable_icd_lit = true
3737

3838
# Openthread Configuration flags
39-
sl_ot_idle_interval_ms = 3600000 # 60mins Idle Polling Interval
40-
sl_ot_active_interval_ms = 1000 # 1000ms Active Polling Interval
39+
sl_transport_idle_interval_ms = 3600000 # 60mins Idle Polling Interval
40+
sl_transport_active_interval_ms = 1000 # 1000ms Active Polling Interval
4141

4242
# ICD Matter Configuration flags
4343
sl_idle_mode_duration_s = 3600 # 60min Idle Mode Duration

examples/thermostat/silabs/src/ThermostatUI.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
#include "glib.h"
2626
#include "lcd.h"
2727

28-
#if SL_WIFI && !defined(SLI_SI91X_MCU_INTERFACE)
2928
// Only needed for wifi NCP devices
30-
#include "spi_multiplex.h"
31-
#endif // SL_WIFI
29+
#if SL_WIFI && !defined(SLI_SI91X_MCU_INTERFACE)
30+
#include <platform/silabs/wifi/wf200/platform/spi_multiplex.h>
31+
#endif // SL_WIFI && !defined(SLI_SI91X_MCU_INTERFACE)
3232

3333
// LCD line define
3434
constexpr uint8_t kTempLcdInitialX = 30;

examples/window-app/silabs/openthread.gni

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ chip_subscription_timeout_resumption = false
3333
sl_use_subscription_syncing = true
3434

3535
# Openthread Configuration flags
36-
sl_ot_idle_interval_ms = 1000 # 1s Idle Intervals
37-
sl_ot_active_interval_ms = 500 # 500ms Active Intervals
36+
sl_transport_idle_interval_ms = 1000 # 1s Idle Intervals
37+
sl_transport_active_interval_ms = 500 # 500ms Active Intervals
3838

3939
# ICD Matter Configuration flags
4040
sl_idle_mode_duration_s = 600 # 10min Idle Mode Duration

src/platform/silabs/CHIPDevicePlatformConfig.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@
169169

170170
#if SL_ICD_ENABLED
171171
#ifndef CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL
172-
#define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(SL_OT_IDLE_INTERVAL)
172+
#define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(SL_TRANSPORT_IDLE_INTERVAL)
173173
#endif // CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL
174174

175175
#ifndef CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL
176-
#define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(SL_OT_ACTIVE_INTERVAL)
176+
#define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(SL_TRANSPORT_ACTIVE_INTERVAL)
177177
#endif // CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL
178178
#endif // SL_ICD_ENABLED

src/platform/silabs/SiWx917/SiWxPlatformInterface.h

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919

2020
#include <app/icd/server/ICDServerConfig.h>
2121

22+
namespace {
23+
#ifdef ENABLE_CHIP_SHELL
24+
bool ps_requirement_added = false;
25+
#endif // ENABLE_CHIP_SHELL
26+
} // namespace
27+
2228
#ifdef __cplusplus
2329
extern "C" {
2430
#endif
@@ -27,6 +33,7 @@ extern "C" {
2733
#include "sl_si91x_button.h"
2834
#include "sl_si91x_button_pin_config.h"
2935
#include "sl_si91x_driver_gpio.h"
36+
#include "sl_si91x_power_manager.h"
3037

3138
/**
3239
* @brief invoked when button press event is received when in sleep

src/platform/silabs/multi-ota/OTACustomProcessor.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222

2323
#include <app/clusters/ota-requestor/OTARequestorInterface.h>
2424

25+
#if SL_WIFI
26+
#include <platform/silabs/wifi/wf200/platform/spi_multiplex.h>
27+
#endif // SL_WIFI
28+
2529
extern "C" {
2630
#include "btl_interface.h"
2731
#include "sl_core.h"
28-
#if SL_WIFI
29-
#include "spi_multiplex.h"
30-
#endif // SL_WIFI
3132
}
3233

3334
/// No error, operation OK

src/platform/silabs/multi-ota/OTAFirmwareProcessor.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222

2323
#include <app/clusters/ota-requestor/OTARequestorInterface.h>
2424

25+
#if SL_WIFI
26+
#include <platform/silabs/wifi/wf200/platform/spi_multiplex.h>
27+
#endif // SL_WIFI
28+
2529
extern "C" {
2630
#include "btl_interface.h"
2731
#include "sl_core.h"
28-
#if SL_WIFI
29-
#include "spi_multiplex.h"
30-
#endif // SL_WIFI
3132
}
3233

3334
/// No error, operation OK

src/platform/silabs/multi-ota/OTAMultiImageProcessorImpl.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ using namespace ::chip::DeviceLayer::Internal;
3030

3131
static chip::OTAMultiImageProcessorImpl gImageProcessor;
3232

33+
#if SL_WIFI
34+
#include <platform/silabs/wifi/wf200/platform/spi_multiplex.h>
35+
#endif // SL_WIFI
36+
3337
extern "C" {
3438
#include "btl_interface.h"
3539
#include "sl_core.h"
36-
#if SL_WIFI
37-
#include "spi_multiplex.h"
38-
#endif // SL_WIFI
3940
}
4041

4142
namespace chip {

src/platform/silabs/wifi/BUILD.gn

+11-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ declare_args() {
3131

3232
#default Wifi Password
3333
chip_default_wifi_psk = ""
34+
35+
# Argument to enable LwIP debug logs
36+
sl_enable_wifi_debug = false
3437
}
3538

3639
if (chip_enable_wifi && !wifi_soc) {
@@ -51,6 +54,12 @@ config("wifi-platform-config") {
5154
defines = []
5255
include_dirs = []
5356

57+
if (sl_enable_wifi_debug) {
58+
defines += [ "WIFI_DEBUG_ENABLED=1" ]
59+
} else {
60+
defines += [ "WIFI_DEBUG_ENABLED=0" ]
61+
}
62+
5463
if (use_rs9116) {
5564
# All the stuff from wiseconnect
5665
include_dirs += rs911x_inc_plat
@@ -65,6 +74,7 @@ config("wifi-platform-config") {
6574
"SL_WIFI_SSID=\"${chip_default_wifi_ssid}\"",
6675
]
6776
}
77+
6878
if (chip_default_wifi_psk != "") {
6979
assert(chip_default_wifi_ssid != "",
7080
"ssid can't be null if psk is provided")
@@ -120,8 +130,6 @@ source_set("wifi-platform") {
120130

121131
# All the stuff from wiseconnect
122132
sources += rs9117_src_sapi
123-
124-
#add compilation flags for rs991x build. This will be addressed directly in wiseconnect sdk in the next version release of that sdk
125133
} else if (use_wf200) {
126134
sources += wf200_plat_src
127135
}
@@ -142,6 +150,7 @@ source_set("wifi-platform") {
142150
if (use_wf200 || use_rs9116) {
143151
sources += [
144152
"${silabs_platform_dir}/wifi/lwip-support/dhcp_client.cpp",
153+
"${silabs_platform_dir}/wifi/lwip-support/dhcp_client.h",
145154
"${silabs_platform_dir}/wifi/lwip-support/ethernetif.cpp",
146155
"${silabs_platform_dir}/wifi/lwip-support/ethernetif.h",
147156
"${silabs_platform_dir}/wifi/lwip-support/lwip_netif.cpp",

src/platform/silabs/wifi/SiWx/WifiInterface.cpp

+17-37
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ namespace {
9393
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
9494
// TODO: should be removed once we are getting the press interrupt for button 0 with sleep
9595
bool btn0_pressed = false;
96-
#ifdef ENABLE_CHIP_SHELL
97-
bool ps_requirement_added = false;
98-
#endif // ENABLE_CHIP_SHELL
9996
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
10097

10198
bool hasNotifiedWifiConnectivity = false;
@@ -550,37 +547,6 @@ int32_t sl_wifi_platform_disconnect(void)
550547
return sl_net_down((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE);
551548
}
552549

553-
/******************************************************************
554-
* @fn wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state)
555-
* @brief
556-
* Setting the RS911x in DTIM sleep based mode
557-
*
558-
* @param[in] sl_si91x_ble_state : State to set for the BLE
559-
* @param[in] sl_si91x_wifi_state : State to set for the WiFi
560-
* @return
561-
* None
562-
*********************************************************************/
563-
int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state)
564-
{
565-
int32_t status;
566-
567-
status = rsi_bt_power_save_profile(sl_si91x_ble_state, 0);
568-
if (status != RSI_SUCCESS)
569-
{
570-
ChipLogError(DeviceLayer, "rsi_bt_power_save_profile failed: 0x%lx", static_cast<uint32_t>(status));
571-
return status;
572-
}
573-
sl_wifi_performance_profile_t wifi_profile = { .profile = sl_si91x_wifi_state };
574-
status = sl_wifi_set_performance_profile(&wifi_profile);
575-
if (status != RSI_SUCCESS)
576-
{
577-
ChipLogError(DeviceLayer, "sl_wifi_set_performance_profile failed: 0x%lx", static_cast<uint32_t>(status));
578-
return status;
579-
}
580-
581-
return status;
582-
}
583-
584550
sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result)
585551
{
586552
SL_WIFI_ARGS_CHECK_NULL_POINTER(scan_result);
@@ -897,9 +863,23 @@ void wfx_dhcp_got_ipv4(uint32_t ip)
897863
* @return SL_STATUS_OK if successful,
898864
* SL_STATUS_FAIL otherwise
899865
***********************************************************************/
900-
sl_status_t wfx_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state,
901-
sl_si91x_performance_profile_t sl_si91x_wifi_state) // TODO : Figure out why the extern C is necessary
866+
sl_status_t wfx_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state)
902867
{
903-
return (wfx_rsi_power_save(sl_si91x_ble_state, sl_si91x_wifi_state) ? SL_STATUS_FAIL : SL_STATUS_OK);
868+
int32_t error = rsi_bt_power_save_profile(sl_si91x_ble_state, 0);
869+
if (error != RSI_SUCCESS)
870+
{
871+
ChipLogError(DeviceLayer, "rsi_bt_power_save_profile failed: %ld", error);
872+
return SL_STATUS_FAIL;
873+
}
874+
875+
sl_wifi_performance_profile_t wifi_profile = { .profile = sl_si91x_wifi_state };
876+
sl_status_t status = sl_wifi_set_performance_profile(&wifi_profile);
877+
if (status != SL_STATUS_OK)
878+
{
879+
ChipLogError(DeviceLayer, "sl_wifi_set_performance_profile failed: 0x%lx", static_cast<uint32_t>(status));
880+
return status;
881+
}
882+
883+
return SL_STATUS_OK;
904884
}
905885
#endif

src/platform/silabs/wifi/WifiInterfaceAbstraction.cpp

+13-45
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ namespace {
4141

4242
constexpr uint8_t kWlanMinRetryIntervalsInSec = 1;
4343
constexpr uint8_t kWlanMaxRetryIntervalsInSec = 60;
44-
constexpr uint8_t kWlanRetryIntervalInSec = 5;
4544
uint8_t retryInterval = kWlanMinRetryIntervalsInSec;
4645
osTimerId_t sRetryTimer;
4746

@@ -52,7 +51,7 @@ osTimerId_t sRetryTimer;
5251
void RetryConnectionTimerHandler(void * arg)
5352
{
5453
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
55-
wfx_rsi_power_save(RSI_ACTIVE, HIGH_PERFORMANCE);
54+
wfx_power_save(RSI_ACTIVE, HIGH_PERFORMANCE);
5655
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
5756
if (wfx_connect_to_ap() != SL_STATUS_OK)
5857
{
@@ -178,54 +177,23 @@ void wfx_ip_changed_notify(int got_ip)
178177
*************************************************************************************/
179178
void wfx_retry_connection(uint16_t retryAttempt)
180179
{
181-
// During commissioning, we retry to join the network MAX_JOIN_RETRIES_COUNT
182-
if (/*BaseApplication::sAppDelegate.isCommissioningInProgress()*/ true)
180+
if (retryInterval > kWlanMaxRetryIntervalsInSec)
183181
{
184-
if (retryAttempt < MAX_JOIN_RETRIES_COUNT)
185-
{
186-
ChipLogProgress(DeviceLayer, "wfx_retry_connection : Next attempt after %d Seconds", kWlanRetryIntervalInSec);
187-
if (osTimerStart(sRetryTimer, pdMS_TO_TICKS(CONVERT_SEC_TO_MS(kWlanRetryIntervalInSec))) != osOK)
188-
{
189-
ChipLogProgress(DeviceLayer, "Failed to start retry timer");
190-
// Sending the join command if retry timer failed to start
191-
if (wfx_connect_to_ap() != SL_STATUS_OK)
192-
{
193-
ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
194-
}
195-
return;
196-
}
197-
}
198-
else
199-
{
200-
ChipLogProgress(DeviceLayer, "Connect failed after max %d tries", retryAttempt);
201-
}
182+
retryInterval = kWlanMaxRetryIntervalsInSec;
202183
}
203-
else
184+
if (osTimerStart(sRetryTimer, pdMS_TO_TICKS(CONVERT_SEC_TO_MS(retryInterval))) != osOK)
204185
{
205-
/* After disconnection or power cycle the DUT
206-
* At the telescopic time interval device try to reconnect with AP, upto WLAN_MAX_RETRY_TIMER_MS intervals
207-
* are telescopic. If interval exceed WLAN_MAX_RETRY_TIMER_MS then it will try to reconnect at
208-
* WLAN_MAX_RETRY_TIMER_MS intervals.
209-
*/
210-
if (retryInterval > kWlanMaxRetryIntervalsInSec)
211-
{
212-
retryInterval = kWlanMaxRetryIntervalsInSec;
213-
}
214-
if (osTimerStart(sRetryTimer, pdMS_TO_TICKS(CONVERT_SEC_TO_MS(retryInterval))) != osOK)
186+
ChipLogProgress(DeviceLayer, "Failed to start retry timer");
187+
// Sending the join command if retry timer failed to start
188+
if (wfx_connect_to_ap() != SL_STATUS_OK)
215189
{
216-
ChipLogProgress(DeviceLayer, "Failed to start retry timer");
217-
// Sending the join command if retry timer failed to start
218-
if (wfx_connect_to_ap() != SL_STATUS_OK)
219-
{
220-
ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
221-
}
222-
return;
190+
ChipLogError(DeviceLayer, "wfx_connect_to_ap() failed.");
223191
}
224-
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
225-
wfx_rsi_power_save(RSI_SLEEP_MODE_8, STANDBY_POWER_SAVE_WITH_RAM_RETENTION);
226-
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
227-
ChipLogProgress(DeviceLayer, "wfx_retry_connection : Next attempt after %d Seconds", retryInterval);
228-
retryInterval += retryInterval;
229192
return;
230193
}
194+
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
195+
wfx_power_save(RSI_SLEEP_MODE_8, STANDBY_POWER_SAVE_WITH_RAM_RETENTION);
196+
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
197+
ChipLogProgress(DeviceLayer, "wfx_retry_connection : Next attempt after %d Seconds", retryInterval);
198+
retryInterval += retryInterval;
231199
}

0 commit comments

Comments
 (0)