Skip to content

Commit 18e76d8

Browse files
rosahay-silabsCopilotrestyled-commits
authored
[SL-ONLY] Adds check for power state change for invoking low-level power save APIs (#589)
Co-authored-by: Copilot <[email protected]> Co-authored-by: Restyled.io <[email protected]>
1 parent 668916e commit 18e76d8

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ sl_si91x_performance_profile_t ConvertPowerSaveConfiguration(PowerSaveInterface:
460460
profile = HIGH_PERFORMANCE;
461461
break;
462462
case PowerSaveInterface::PowerSaveConfiguration::kConnectedSleep:
463+
case PowerSaveInterface::PowerSaveConfiguration::kLIConnectedSleep:
463464
profile = ASSOCIATED_POWER_SAVE;
464465
break;
465466
case PowerSaveInterface::PowerSaveConfiguration::kDeepSleep:
@@ -837,6 +838,9 @@ sl_status_t WifiInterfaceImpl::TriggerPlatformWifiDisconnection()
837838
#if CHIP_CONFIG_ENABLE_ICD_SERVER
838839
CHIP_ERROR WifiInterfaceImpl::ConfigurePowerSave(PowerSaveInterface::PowerSaveConfiguration configuration, uint32_t listenInterval)
839840
{
841+
// Power save configuration is already set, nothing to do
842+
VerifyOrReturnValue(mCurrentPowerSaveConfiguration != configuration, CHIP_NO_ERROR);
843+
840844
int32_t error = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP);
841845
VerifyOrReturnError(error == RSI_SUCCESS, CHIP_ERROR_INTERNAL,
842846
ChipLogError(DeviceLayer, "rsi_bt_power_save_profile failed: %ld", error));
@@ -851,6 +855,7 @@ CHIP_ERROR WifiInterfaceImpl::ConfigurePowerSave(PowerSaveInterface::PowerSaveCo
851855
VerifyOrReturnError(status == SL_STATUS_OK, CHIP_ERROR_INTERNAL,
852856
ChipLogError(DeviceLayer, "sl_wifi_set_performance_profile failed: 0x%lx", status));
853857

858+
mCurrentPowerSaveConfiguration = configuration;
854859
return CHIP_NO_ERROR;
855860
}
856861

src/platform/silabs/wifi/icd/PowerSaveInterface.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ class PowerSaveInterface
3434

3535
enum class PowerSaveConfiguration : uint8_t
3636
{
37-
kHighPerformance = 0,
38-
kDeepSleep = 1,
39-
kConnectedSleep = 2,
37+
kHighPerformance = 0,
38+
kDeepSleep = 1,
39+
kConnectedSleep = 2,
40+
kLIConnectedSleep = 3,
4041
};
4142

4243
/**
@@ -66,6 +67,11 @@ class PowerSaveInterface
6667
* or if it is a non-supported configuration
6768
*/
6869
virtual CHIP_ERROR ConfigureBroadcastFilter(bool enableBroadcastFilter) { return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; }
70+
71+
protected:
72+
// Default power save configuration is High Performance as the device starts in high power mode and low power modes need to be
73+
// explicitly configured
74+
PowerSaveConfiguration mCurrentPowerSaveConfiguration = PowerSaveConfiguration::kHighPerformance;
6975
};
7076

7177
} // namespace Silabs

src/platform/silabs/wifi/icd/WifiSleepManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ CHIP_ERROR WifiSleepManager::ConfigureLIBasedSleep()
162162

163163
// Allowing the device to go to sleep must be the last actions to avoid configuration failures.
164164
ReturnLogErrorOnFailure(
165-
mPowerSaveInterface->ConfigurePowerSave(PowerSaveInterface::PowerSaveConfiguration::kConnectedSleep,
165+
mPowerSaveInterface->ConfigurePowerSave(PowerSaveInterface::PowerSaveConfiguration::kLIConnectedSleep,
166166
chip::ICDConfigurationData::GetInstance().GetSlowPollingInterval().count()));
167167

168168
return CHIP_NO_ERROR;

0 commit comments

Comments
 (0)