@@ -70,12 +70,17 @@ extern "C" {
70
70
#include < platform/silabs/wifi/SiWx/ncp/sl_board_configuration.h>
71
71
#endif
72
72
73
- #if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
73
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
74
+ #include < app/icd/server/ICDConfigurationData.h> // nogncheck
75
+ #include < platform/silabs/wifi/icd/WifiSleepManager.h>
76
+
77
+ #if SLI_SI91X_MCU_INTERFACE // SoC Only
74
78
#include " rsi_rom_power_save.h"
75
79
#include " sl_gpio_board.h"
76
80
#include " sl_si91x_driver_gpio.h"
77
81
#include " sl_si91x_power_manager.h"
78
- #endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
82
+ #endif // SLI_SI91X_MCU_INTERFACE
83
+ #endif // CHIP_CONFIG_ENABLE_ICD_SERVER
79
84
80
85
// TODO : Temporary work-around for wifi-init failure in 917NCP and 917SOC ACX module boards.
81
86
// Can be removed after Wiseconnect fixes region code for all ACX module boards.
@@ -89,10 +94,9 @@ WfxRsi_t wfx_rsi;
89
94
90
95
namespace {
91
96
92
- #if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
93
- // TODO: should be removed once we are getting the press interrupt for button 0 with sleep
94
- bool btn0_pressed = false ;
95
- #endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
97
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
98
+ constexpr uint32_t kTimeToFullBeaconReception = 5000 ; // 5 seconds
99
+ #endif // CHIP_CONFIG_ENABLE_ICD_SERVER
96
100
97
101
wfx_wifi_scan_ext_t temp_reset;
98
102
@@ -374,8 +378,8 @@ sl_status_t SetWifiConfigurations()
374
378
sl_status_t status = SL_STATUS_OK;
375
379
376
380
#if CHIP_CONFIG_ENABLE_ICD_SERVER
377
- // Setting the listen interval to 0 which will set it to DTIM interval
378
- sl_wifi_listen_interval_t sleep_interval = { . listen_interval = 0 };
381
+ sl_wifi_listen_interval_t sleep_interval = { . listen_interval =
382
+ chip::ICDConfigurationData::GetInstance (). GetSlowPollingInterval (). count () };
379
383
status = sl_wifi_set_listen_interval (SL_WIFI_CLIENT_INTERFACE, sleep_interval);
380
384
VerifyOrReturnError (status == SL_STATUS_OK, status,
381
385
ChipLogError (DeviceLayer, " sl_wifi_set_listen_interval failed: 0x%lx" , status));
@@ -384,6 +388,10 @@ sl_status_t SetWifiConfigurations()
384
388
status = sl_wifi_set_advanced_client_configuration (SL_WIFI_CLIENT_INTERFACE, &client_config);
385
389
VerifyOrReturnError (status == SL_STATUS_OK, status,
386
390
ChipLogError (DeviceLayer, " sl_wifi_set_advanced_client_configuration failed: 0x%lx" , status));
391
+
392
+ status = sl_si91x_set_join_configuration (
393
+ SL_WIFI_CLIENT_INTERFACE, (SL_SI91X_JOIN_FEAT_LISTEN_INTERVAL_VALID | SL_SI91X_JOIN_FEAT_PS_CMD_LISTEN_INTERVAL_VALID));
394
+ VerifyOrReturnError (status == SL_STATUS_OK, status);
387
395
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
388
396
389
397
if (wfx_rsi.sec .passkey_length != 0 )
@@ -472,10 +480,21 @@ sl_status_t JoinWifiNetwork(void)
472
480
status = sl_wifi_set_join_callback (JoinCallback, nullptr );
473
481
VerifyOrReturnError (status == SL_STATUS_OK, status);
474
482
483
+ // To avoid IOP issues, it is recommended to enable high-performance mode before joining the network.
484
+ // TODO: Remove this once the IOP issue related to power save mode switching is fixed in the Wi-Fi SDK.
485
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
486
+ chip::DeviceLayer::Silabs::WifiSleepManager::GetInstance ().RequestHighPerformance ();
487
+ #endif // CHIP_CONFIG_ENABLE_ICD_SERVER
488
+
475
489
status = sl_net_up ((sl_net_interface_t ) SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID);
476
490
477
491
if (status == SL_STATUS_OK || status == SL_STATUS_IN_PROGRESS)
478
492
{
493
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
494
+ // Remove High performance request that might have been added during the connect/retry process
495
+ chip::DeviceLayer::Silabs::WifiSleepManager::GetInstance ().RemoveHighPerformanceRequest ();
496
+ #endif // CHIP_CONFIG_ENABLE_ICD_SERVER
497
+
479
498
WifiPlatformEvent event = WifiPlatformEvent::kStationConnect ;
480
499
PostWifiPlatformEvent (event);
481
500
return status;
@@ -791,6 +810,42 @@ void MatterWifiTask(void * arg)
791
810
}
792
811
}
793
812
813
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
814
+ CHIP_ERROR ConfigurePowerSave (rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state,
815
+ uint32_t listenInterval)
816
+ {
817
+ int32_t error = rsi_bt_power_save_profile (sl_si91x_ble_state, RSI_MAX_PSP);
818
+ VerifyOrReturnError (error == RSI_SUCCESS, CHIP_ERROR_INTERNAL,
819
+ ChipLogError (DeviceLayer, " rsi_bt_power_save_profile failed: %ld" , error));
820
+
821
+ sl_wifi_performance_profile_t wifi_profile = { .profile = sl_si91x_wifi_state,
822
+ // TODO: Performance profile fails if not alligned with DTIM
823
+ .dtim_aligned_type = SL_SI91X_ALIGN_WITH_DTIM_BEACON,
824
+ // TODO: Different types need to be fixed in the Wi-Fi SDK
825
+ .listen_interval = static_cast <uint16_t >(listenInterval) };
826
+
827
+ sl_status_t status = sl_wifi_set_performance_profile (&wifi_profile);
828
+ VerifyOrReturnError (status == SL_STATUS_OK, CHIP_ERROR_INTERNAL,
829
+ ChipLogError (DeviceLayer, " sl_wifi_set_performance_profile failed: 0x%lx" , status));
830
+
831
+ return CHIP_NO_ERROR;
832
+ }
833
+
834
+ CHIP_ERROR ConfigureBroadcastFilter (bool enableBroadcastFilter)
835
+ {
836
+ sl_status_t status = SL_STATUS_OK;
837
+
838
+ uint16_t beaconDropThreshold = (enableBroadcastFilter) ? kTimeToFullBeaconReception : 0 ;
839
+ uint8_t filterBcastInTim = (enableBroadcastFilter) ? 1 : 0 ;
840
+
841
+ status = sl_wifi_filter_broadcast (beaconDropThreshold, filterBcastInTim, 1 /* valid till next update*/ );
842
+ VerifyOrReturnError (status == SL_STATUS_OK, CHIP_ERROR_INTERNAL,
843
+ ChipLogError (DeviceLayer, " sl_wifi_filter_broadcast failed: 0x%lx" , static_cast <uint32_t >(status)));
844
+
845
+ return CHIP_NO_ERROR;
846
+ }
847
+ #endif // CHIP_CONFIG_ENABLE_ICD_SERVER
848
+
794
849
#if CHIP_DEVICE_CONFIG_ENABLE_IPV4
795
850
/* *******************************************************************************************
796
851
* @fn void wfx_dhcp_got_ipv4(uint32_t ip)
@@ -816,35 +871,3 @@ void wfx_dhcp_got_ipv4(uint32_t ip)
816
871
NotifyIPv4Change (true );
817
872
}
818
873
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
819
-
820
- #if SL_ICD_ENABLED
821
- /* ********************************************************************
822
- * @fn sl_status_t wfx_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t
823
- sl_si91x_wifi_state)
824
- * @brief
825
- * Implements the power save in sleepy application
826
- * @param[in] sl_si91x_ble_state : State to set for the BLE
827
- sl_si91x_wifi_state : State to set for the WiFi
828
- * @return SL_STATUS_OK if successful,
829
- * SL_STATUS_FAIL otherwise
830
- ***********************************************************************/
831
- 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)
832
- {
833
- int32_t error = rsi_bt_power_save_profile (sl_si91x_ble_state, 0 );
834
- if (error != RSI_SUCCESS)
835
- {
836
- ChipLogError (DeviceLayer, " rsi_bt_power_save_profile failed: %ld" , error);
837
- return SL_STATUS_FAIL;
838
- }
839
-
840
- sl_wifi_performance_profile_t wifi_profile = { .profile = sl_si91x_wifi_state };
841
- sl_status_t status = sl_wifi_set_performance_profile (&wifi_profile);
842
- if (status != SL_STATUS_OK)
843
- {
844
- ChipLogError (DeviceLayer, " sl_wifi_set_performance_profile failed: 0x%lx" , static_cast <uint32_t >(status));
845
- return status;
846
- }
847
-
848
- return SL_STATUS_OK;
849
- }
850
- #endif
0 commit comments