Skip to content

Commit 4c50b36

Browse files
[SL-UP] Allowing DUT to sleep after commissioning (#214)
1 parent 1ad42b2 commit 4c50b36

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

examples/platform/silabs/BaseApplication.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ void BaseApplicationDelegate::OnCommissioningSessionStarted()
201201

202202
#if SL_WIFI && CHIP_CONFIG_ENABLE_ICD_SERVER
203203
WifiSleepManager::GetInstance().HandleCommissioningSessionStarted();
204+
// Setting the device to high power mode during commissioning
205+
WifiSleepManager::GetInstance().RequestHighPerformance();
204206
#endif // SL_WIFI && CHIP_CONFIG_ENABLE_ICD_SERVER
205207
}
206208

@@ -210,6 +212,19 @@ void BaseApplicationDelegate::OnCommissioningSessionStopped()
210212

211213
#if SL_WIFI && CHIP_CONFIG_ENABLE_ICD_SERVER
212214
WifiSleepManager::GetInstance().HandleCommissioningSessionStopped();
215+
// Removing the high power mode request on session stopped
216+
WifiSleepManager::GetInstance().RemoveHighPerformanceRequest();
217+
#endif // SL_WIFI && CHIP_CONFIG_ENABLE_ICD_SERVER
218+
}
219+
220+
void BaseApplicationDelegate::OnCommissioningSessionEstablishmentError(CHIP_ERROR err)
221+
{
222+
isComissioningStarted = false;
223+
224+
#if SL_WIFI && CHIP_CONFIG_ENABLE_ICD_SERVER
225+
WifiSleepManager::GetInstance().HandleCommissioningSessionStopped();
226+
// Removing the high power mode request on failed commissioning
227+
WifiSleepManager::GetInstance().RemoveHighPerformanceRequest();
213228
#endif // SL_WIFI && CHIP_CONFIG_ENABLE_ICD_SERVER
214229
}
215230

@@ -240,6 +255,7 @@ void BaseApplicationDelegate::OnCommissioningWindowClosed()
240255
#endif // QR_CODE_ENABLED
241256
#endif // DISPLAY_ENABLED
242257
}
258+
243259
}
244260

245261
void BaseApplicationDelegate::OnFabricCommitted(const FabricTable & fabricTable, FabricIndex fabricIndex)
@@ -946,6 +962,8 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
946962

947963
case DeviceEventType::kCommissioningComplete: {
948964
#if SL_WIFI && CHIP_CONFIG_ENABLE_ICD_SERVER
965+
// DUT is commissioned, removing the High Performance request
966+
WifiSleepManager::GetInstance().RemoveHighPerformanceRequest();
949967
WifiSleepManager::GetInstance().VerifyAndTransitionToLowPowerMode(WifiSleepManager::PowerEvent::kCommissioningComplete);
950968
#endif // SL_WIFI && CHIP_CONFIG_ENABLE_ICD_SERVER
951969

examples/platform/silabs/BaseApplication.h

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class BaseApplicationDelegate : public AppDelegate, public chip::FabricTable::De
7373
bool isComissioningStarted = false;
7474
void OnCommissioningSessionStarted() override;
7575
void OnCommissioningSessionStopped() override;
76+
void OnCommissioningSessionEstablishmentError(CHIP_ERROR err) override;
7677
void OnCommissioningWindowClosed() override;
7778
void OnCommissioningWindowOpened() override;
7879

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

-6
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,6 @@ sl_status_t JoinWifiNetwork(void)
462462

463463
if (status == SL_STATUS_OK)
464464
{
465-
#if CHIP_CONFIG_ENABLE_ICD_SERVER
466-
// TODO: We need a way to identify if this was a retry or a first attempt connect to avoid removing a req that was not ours
467-
// Remove High performance request that might have been added during the retry process
468-
chip::DeviceLayer::Silabs::WifiSleepManager::GetInstance().RemoveHighPerformanceRequest();
469-
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
470-
471465
WifiEvent event = WifiEvent::kStationConnect;
472466
sl_matter_wifi_post_event(event);
473467
return status;

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ CHIP_ERROR WifiSleepManager::VerifyAndTransitionToLowPowerMode(PowerEvent event)
160160

161161
if (mIsCommissioningInProgress)
162162
{
163-
return ConfigureDTIMBasedSleep();
163+
// During commissioning, don't let the device to go to sleep
164+
// This is needed to interrupt the sleep and retry to join the network
165+
return CHIP_NO_ERROR;
164166
}
165167

166168
// TODO: Clean this up when the Wi-Fi interface re-work is finished

0 commit comments

Comments
 (0)