Skip to content

Commit 2000613

Browse files
chirag-silabsrestyled-commits
authored andcommitted
[Silabs] RS911x not going into power save upon power cycle (#26260)
* Calling power save at only position * stopping the ble advertisement after sta was connected * removing the condition for wf200 and keeping it only for rs9116 * addressing review comments * Restyled by clang-format * Restyled by gn * address review comments * Restyled by clang-format --------- Co-authored-by: Restyled.io <[email protected]>
1 parent ba83c40 commit 2000613

File tree

8 files changed

+75
-53
lines changed

8 files changed

+75
-53
lines changed

examples/platform/silabs/efr32/rs911x/rsi_if.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ int32_t wfx_rsi_disconnect()
181181
return status;
182182
}
183183

184+
#if CHIP_DEVICE_CONFIG_ENABLE_SED
184185
/******************************************************************
185186
* @fn wfx_rsi_power_save()
186187
* @brief
@@ -190,16 +191,29 @@ int32_t wfx_rsi_disconnect()
190191
* @return
191192
* None
192193
*********************************************************************/
193-
void wfx_rsi_power_save()
194+
int32_t wfx_rsi_power_save()
194195
{
195-
int32_t status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP);
196+
int32_t status;
197+
#ifdef RSI_BLE_ENABLE
198+
status = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP);
199+
if (status != RSI_SUCCESS)
200+
{
201+
SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status);
202+
return status;
203+
}
204+
#endif /* RSI_BLE_ENABLE */
205+
206+
status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP);
196207
if (status != RSI_SUCCESS)
197208
{
198209
SILABS_LOG("Powersave Config Failed, Error Code : 0x%lX", status);
199-
return;
210+
return status;
200211
}
201212
SILABS_LOG("Powersave Config Success");
213+
return status;
202214
}
215+
#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
216+
203217
/******************************************************************
204218
* @fn wfx_rsi_join_cb(uint16_t status, const uint8_t *buf, const uint16_t len)
205219
* @brief
@@ -596,13 +610,6 @@ void wfx_rsi_task(void * arg)
596610
{
597611
wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr);
598612
hasNotifiedIPV4 = true;
599-
#if CHIP_DEVICE_CONFIG_ENABLE_SED
600-
#ifndef RSI_BLE_ENABLE
601-
// enabling the power save mode for RS9116 if sleepy device is enabled
602-
// if BLE is used on the rs9116 then powersave config is done after ble disconnect event
603-
wfx_rsi_power_save();
604-
#endif /* RSI_BLE_ENABLE */
605-
#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
606613
if (!hasNotifiedWifiConnectivity)
607614
{
608615
wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac);
@@ -622,13 +629,6 @@ void wfx_rsi_task(void * arg)
622629
{
623630
wfx_ipv6_notify(GET_IPV6_SUCCESS);
624631
hasNotifiedIPV6 = true;
625-
#if CHIP_DEVICE_CONFIG_ENABLE_SED
626-
#ifndef RSI_BLE_ENABLE
627-
// enabling the power save mode for RS9116 if sleepy device is enabled
628-
// if BLE is used on the rs9116 then powersave config is done after ble disconnect event
629-
wfx_rsi_power_save();
630-
#endif /* RSI_BLE_ENABLE */
631-
#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
632632
if (!hasNotifiedWifiConnectivity)
633633
{
634634
wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac);

examples/platform/silabs/efr32/rs911x/wfx_rsi.h

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap);
9191
int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info);
9292
int32_t wfx_rsi_reset_count();
9393
int32_t wfx_rsi_disconnect();
94+
#if CHIP_DEVICE_CONFIG_ENABLE_SED
95+
int32_t wfx_rsi_power_save();
96+
#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
9497
#define SILABS_LOG(...) efr32Log(__VA_ARGS__);
9598

9699
#ifdef __cplusplus

examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c

+20
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "event_groups.h"
3131
#include "task.h"
3232

33+
#include "rsi_error.h"
3334
#include "wfx_host_events.h"
3435
#include "wfx_rsi.h"
3536

@@ -195,6 +196,25 @@ sl_status_t wfx_connect_to_ap(void)
195196
return SL_STATUS_OK;
196197
}
197198

199+
#if CHIP_DEVICE_CONFIG_ENABLE_SED
200+
/*********************************************************************
201+
* @fn sl_status_t wfx_power_save()
202+
* @brief
203+
* Implements the power save in sleepy application
204+
* @param[in] None
205+
* @return SL_STATUS_OK if successful,
206+
* SL_STATUS_FAIL otherwise
207+
***********************************************************************/
208+
sl_status_t wfx_power_save()
209+
{
210+
if (wfx_rsi_power_save() != RSI_ERROR_NONE)
211+
{
212+
return SL_STATUS_FAIL;
213+
}
214+
return SL_STATUS_OK;
215+
}
216+
#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
217+
198218
/*********************************************************************
199219
* @fn void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif)
200220
* @brief

src/platform/silabs/BLEManagerImpl.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
7272
void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId);
7373
void HandleTXCharCCCDWrite(rsi_ble_event_write_t * evt);
7474
void HandleSoftTimerEvent(void);
75-
CHIP_ERROR StartAdvertising(void);
7675
#else
7776
void HandleConnectEvent(volatile sl_bt_msg_t * evt);
7877
void HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt);
@@ -81,8 +80,9 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
8180
void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId);
8281
void HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt);
8382
void HandleSoftTimerEvent(volatile sl_bt_msg_t * evt);
84-
CHIP_ERROR StartAdvertising(void);
8583
#endif // RSI_BLE_ENABLE
84+
CHIP_ERROR StartAdvertising(void);
85+
CHIP_ERROR StopAdvertising(void);
8686

8787
#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
8888
#ifdef RSI_BLE_ENABLE
@@ -187,7 +187,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla
187187
CHIP_ERROR MapBLEError(int bleErr);
188188
void DriveBLEState(void);
189189
CHIP_ERROR ConfigureAdvertisingData(void);
190-
CHIP_ERROR StopAdvertising(void);
191190
#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
192191
CHIP_ERROR EncodeAdditionalDataTlv();
193192
#endif

src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,18 @@ void ConnectivityManagerImpl::OnStationConnected()
380380
event.Type = DeviceEventType::kWiFiConnectivityChange;
381381
event.WiFiConnectivityChange.Result = kConnectivity_Established;
382382
(void) PlatformMgr().PostEvent(&event);
383-
383+
// Setting the rs911x in the power save mode
384+
#if (CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI)
385+
// TODO: Remove stop advertising after BLEManagerImpl is fixed
386+
#if RSI_BLE_ENABLE
387+
chip::DeviceLayer::Internal::BLEManagerImpl().StopAdvertising();
388+
#endif /* RSI_BLE_ENABLE */
389+
sl_status_t err = wfx_power_save();
390+
if (err != SL_STATUS_OK)
391+
{
392+
ChipLogError(DeviceLayer, "Power save config for Wifi failed");
393+
}
394+
#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI */
384395
UpdateInternetConnectivityState();
385396
}
386397

src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp

+9-29
Original file line numberDiff line numberDiff line change
@@ -661,23 +661,21 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
661661
return CHIP_NO_ERROR; // err;
662662
}
663663

664-
// TODO:: Implementation need to be done.
665664
CHIP_ERROR BLEManagerImpl::StopAdvertising(void)
666665
{
667666
CHIP_ERROR err = CHIP_NO_ERROR;
668667
int32_t status = 0;
669-
if (mFlags.Has(Flags::kAdvertising))
668+
// TODO: add the below code in a condition if (mFlags.Has(Flags::kAdvertising))
669+
// Since DriveBLEState is not called the device is still advertising
670+
mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising);
671+
mFlags.Set(Flags::kFastAdvertisingEnabled, true);
672+
status = rsi_ble_stop_advertising();
673+
if (status != RSI_SUCCESS)
670674
{
671-
mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising);
672-
mFlags.Set(Flags::kFastAdvertisingEnabled, true);
673-
status = rsi_ble_stop_advertising();
674-
if (status != RSI_SUCCESS)
675-
{
676-
ChipLogProgress(DeviceLayer, "advertising failed to stop, with status = 0x%lx", status);
677-
}
678-
advertising_set_handle = 0xff;
679-
CancelBleAdvTimeoutTimer();
675+
ChipLogProgress(DeviceLayer, "advertising failed to stop, with status = 0x%lx", status);
680676
}
677+
advertising_set_handle = 0xff;
678+
CancelBleAdvTimeoutTimer();
681679

682680
// exit:
683681
return err;
@@ -723,24 +721,6 @@ void BLEManagerImpl::HandleConnectionCloseEvent(uint16_t reason)
723721

724722
ChipLogProgress(DeviceLayer, "Disconnect Event for handle : %d", connHandle);
725723

726-
#if CHIP_DEVICE_CONFIG_ENABLE_SED
727-
int32_t status;
728-
status = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP);
729-
if (status != RSI_SUCCESS)
730-
{
731-
SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status);
732-
return;
733-
}
734-
735-
status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP);
736-
if (status != RSI_SUCCESS)
737-
{
738-
SILABS_LOG("WLAN Powersave Config Failed, Error Code : 0x%lX", status);
739-
return;
740-
}
741-
SILABS_LOG("Powersave Config Success");
742-
#endif
743-
744724
if (RemoveConnection(connHandle))
745725
{
746726
ChipDeviceEvent event;

src/platform/silabs/efr32/wifi/wfx_host_events.h

+4
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ void wfx_ip_changed_notify(int got_ip);
352352
void wfx_ipv6_notify(int got_ip);
353353

354354
#ifdef RS911X_WIFI
355+
/* RSI Power Save */
356+
#if CHIP_DEVICE_CONFIG_ENABLE_SED
357+
sl_status_t wfx_power_save();
358+
#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */
355359
/* RSI for LWIP */
356360
void * wfx_rsi_alloc_pkt(void);
357361
void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off);

third_party/silabs/efr32_sdk.gni

+8-3
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,15 @@ template("efr32_sdk") {
338338
"SL_CATALOG_POWER_MANAGER_PRESENT",
339339
"SL_CATALOG_SLEEPTIMER_PRESENT",
340340
"SL_SLEEP_TIME_MS=${sleep_time_ms}",
341-
342-
# Used for wifi devices to get packet details
343-
"WIFI_DEBUG_ENABLED=1",
344341
]
342+
343+
if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) {
344+
defines += [
345+
# Used for wifi devices to get packet details
346+
# TODO: Remove this flag, once the communication is fixed
347+
"WIFI_DEBUG_ENABLED=1",
348+
]
349+
}
345350
}
346351

347352
if (chip_build_libshell) { # matter shell

0 commit comments

Comments
 (0)