From 373e0679acda1a36cca313cdfa9dc5325e0a24a5 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Tue, 18 Apr 2023 17:18:50 +0530 Subject: [PATCH 1/8] Calling power save at only position --- .../platform/silabs/efr32/rs911x/rsi_if.c | 26 ++++++++----------- .../platform/silabs/efr32/rs911x/wfx_rsi.h | 1 + .../silabs/efr32/rs911x/wfx_rsi_host.c | 4 +++ .../silabs/ConnectivityManagerImpl_WIFI.cpp | 4 ++- .../silabs/efr32/rs911x/BLEManagerImpl.cpp | 18 ------------- .../silabs/efr32/wifi/wfx_host_events.h | 1 + 6 files changed, 20 insertions(+), 34 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index 324f635f3015f0..b9870ff44a4ea6 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -192,7 +192,17 @@ int32_t wfx_rsi_disconnect() *********************************************************************/ void wfx_rsi_power_save() { - int32_t status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + int32_t status; +#ifdef RSI_BLE_ENABLE + status = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + if (status != RSI_SUCCESS) + { + SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status); + return; + } +#endif /* RSI_BLE_ENABLE */ + + status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); if (status != RSI_SUCCESS) { SILABS_LOG("Powersave Config Failed, Error Code : 0x%lX", status); @@ -596,13 +606,6 @@ void wfx_rsi_task(void * arg) { wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr); hasNotifiedIPV4 = true; -#if CHIP_DEVICE_CONFIG_ENABLE_SED -#ifndef RSI_BLE_ENABLE - // enabling the power save mode for RS9116 if sleepy device is enabled - // if BLE is used on the rs9116 then powersave config is done after ble disconnect event - wfx_rsi_power_save(); -#endif /* RSI_BLE_ENABLE */ -#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac); @@ -622,13 +625,6 @@ void wfx_rsi_task(void * arg) { wfx_ipv6_notify(GET_IPV6_SUCCESS); hasNotifiedIPV6 = true; -#if CHIP_DEVICE_CONFIG_ENABLE_SED -#ifndef RSI_BLE_ENABLE - // enabling the power save mode for RS9116 if sleepy device is enabled - // if BLE is used on the rs9116 then powersave config is done after ble disconnect event - wfx_rsi_power_save(); -#endif /* RSI_BLE_ENABLE */ -#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac); diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h index 846644f2ba7f55..bd3ab5680a867c 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h @@ -91,6 +91,7 @@ int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap); int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); int32_t wfx_rsi_reset_count(); int32_t wfx_rsi_disconnect(); +void wfx_rsi_power_save(); #define SILABS_LOG(...) efr32Log(__VA_ARGS__); #ifdef __cplusplus diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index 9f89a678dfce0a..0bc375de59913f 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -195,6 +195,10 @@ sl_status_t wfx_connect_to_ap(void) return SL_STATUS_OK; } +void wfx_power_save(){ + wfx_rsi_power_save(); +} + /********************************************************************* * @fn void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif) * @brief diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index edbff853f34e8f..d115187e90934b 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -380,7 +380,9 @@ void ConnectivityManagerImpl::OnStationConnected() event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Established; (void) PlatformMgr().PostEvent(&event); - +#if CHIP_DEVICE_CONFIG_ENABLE_SED + wfx_power_save(); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ UpdateInternetConnectivityState(); } diff --git a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp index f03e9d1356543c..e0e3e87635c190 100644 --- a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp @@ -723,24 +723,6 @@ void BLEManagerImpl::HandleConnectionCloseEvent(uint16_t reason) ChipLogProgress(DeviceLayer, "Disconnect Event for handle : %d", connHandle); -#if CHIP_DEVICE_CONFIG_ENABLE_SED - int32_t status; - status = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); - if (status != RSI_SUCCESS) - { - SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status); - return; - } - - status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); - if (status != RSI_SUCCESS) - { - SILABS_LOG("WLAN Powersave Config Failed, Error Code : 0x%lX", status); - return; - } - SILABS_LOG("Powersave Config Success"); -#endif - if (RemoveConnection(connHandle)) { ChipDeviceEvent event; diff --git a/src/platform/silabs/efr32/wifi/wfx_host_events.h b/src/platform/silabs/efr32/wifi/wfx_host_events.h index 1d41c750517c82..7aaf3178a69c26 100644 --- a/src/platform/silabs/efr32/wifi/wfx_host_events.h +++ b/src/platform/silabs/efr32/wifi/wfx_host_events.h @@ -316,6 +316,7 @@ bool wfx_is_sta_mode_enabled(void); int32_t wfx_get_ap_info(wfx_wifi_scan_result_t * ap); int32_t wfx_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); int32_t wfx_reset_counts(); +void wfx_power_save(); void wfx_clear_wifi_provision(void); sl_status_t wfx_connect_to_ap(void); From 23b23ecd9496124846bc8ac8b7576fd841bad05d Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Thu, 20 Apr 2023 11:28:13 +0530 Subject: [PATCH 2/8] stopping the ble advertisement after sta was connected --- .../platform/silabs/efr32/wf200/host_if.cpp | 21 +++++++++++-------- src/platform/silabs/BLEManagerImpl.h | 5 ++--- .../silabs/ConnectivityManagerImpl_WIFI.cpp | 2 ++ .../silabs/efr32/rs911x/BLEManagerImpl.cpp | 4 ++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/examples/platform/silabs/efr32/wf200/host_if.cpp b/examples/platform/silabs/efr32/wf200/host_if.cpp index 1d0f061e77d1bc..94aad7334bd6e4 100644 --- a/examples/platform/silabs/efr32/wf200/host_if.cpp +++ b/examples/platform/silabs/efr32/wf200/host_if.cpp @@ -602,15 +602,6 @@ static void wfx_events_task(void * p_arg) retryJoin = 0; retryInterval = WLAN_MIN_RETRY_TIMER_MS; wfx_lwip_set_sta_link_up(); -#ifdef SLEEP_ENABLED - if (!(wfx_get_wifi_state() & SL_WFX_AP_INTERFACE_UP)) - { - // Enable the power save - SILABS_LOG("WF200 going to DTIM based sleep"); - sl_wfx_set_power_mode(WFM_PM_MODE_DTIM, WFM_PM_POLL_FAST_PS, BEACON_1); - sl_wfx_enable_device_power_save(); - } -#endif // SLEEP_ENABLED } if (flags & SL_WFX_DISCONNECT) @@ -896,6 +887,18 @@ int32_t wfx_reset_counts() return -1; } +/************************************************************************ + * @brief + * reset the count + * @return returns -1 + **************************************************************************/ +void wfx_power_save() { + // Enable the power save + SILABS_LOG("WF200 going to DTIM based sleep"); + sl_wfx_set_power_mode(WFM_PM_MODE_DTIM, WFM_PM_POLL_FAST_PS, BEACON_1); + sl_wfx_enable_device_power_save(); +} + /************************************************************************* * @brief * I think that this is getting called before FreeRTOS threads are ready diff --git a/src/platform/silabs/BLEManagerImpl.h b/src/platform/silabs/BLEManagerImpl.h index 330aad5a1c4be6..da6ce3bb4e3002 100644 --- a/src/platform/silabs/BLEManagerImpl.h +++ b/src/platform/silabs/BLEManagerImpl.h @@ -72,7 +72,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId); void HandleTXCharCCCDWrite(rsi_ble_event_write_t * evt); void HandleSoftTimerEvent(void); - CHIP_ERROR StartAdvertising(void); #else void HandleConnectEvent(volatile sl_bt_msg_t * evt); void HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt); @@ -81,8 +80,9 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId); void HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt); void HandleSoftTimerEvent(volatile sl_bt_msg_t * evt); - CHIP_ERROR StartAdvertising(void); #endif // RSI_BLE_ENABLE + CHIP_ERROR StartAdvertising(void); + CHIP_ERROR StopAdvertising(void); #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING #ifdef RSI_BLE_ENABLE @@ -187,7 +187,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla CHIP_ERROR MapBLEError(int bleErr); void DriveBLEState(void); CHIP_ERROR ConfigureAdvertisingData(void); - CHIP_ERROR StopAdvertising(void); #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING CHIP_ERROR EncodeAdditionalDataTlv(); #endif diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index d115187e90934b..3ddccdc1c82406 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -380,7 +380,9 @@ void ConnectivityManagerImpl::OnStationConnected() event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Established; (void) PlatformMgr().PostEvent(&event); + // Setting the rs911x in the power save mode #if CHIP_DEVICE_CONFIG_ENABLE_SED + chip::DeviceLayer::Internal::BLEManagerImpl().StopAdvertising(); wfx_power_save(); #endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ UpdateInternetConnectivityState(); diff --git a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp index e0e3e87635c190..319a30e16b596b 100644 --- a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp @@ -661,12 +661,12 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) return CHIP_NO_ERROR; // err; } -// TODO:: Implementation need to be done. CHIP_ERROR BLEManagerImpl::StopAdvertising(void) { CHIP_ERROR err = CHIP_NO_ERROR; int32_t status = 0; - if (mFlags.Has(Flags::kAdvertising)) + // TODO: change this condition + if (1) { mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising); mFlags.Set(Flags::kFastAdvertisingEnabled, true); From ac8e90dbc1fd6a0b49fb332be1c6dec3bec01338 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Wed, 26 Apr 2023 15:16:40 +0530 Subject: [PATCH 3/8] removing the condition for wf200 and keeping it only for rs9116 --- .../platform/silabs/efr32/wf200/host_if.cpp | 21 ++++++++----------- .../silabs/ConnectivityManagerImpl_WIFI.cpp | 3 ++- .../silabs/efr32/rs911x/BLEManagerImpl.cpp | 20 ++++++++---------- .../silabs/efr32/wifi/wfx_host_events.h | 3 ++- third_party/silabs/efr32_sdk.gni | 8 +++++-- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/examples/platform/silabs/efr32/wf200/host_if.cpp b/examples/platform/silabs/efr32/wf200/host_if.cpp index 94aad7334bd6e4..1d0f061e77d1bc 100644 --- a/examples/platform/silabs/efr32/wf200/host_if.cpp +++ b/examples/platform/silabs/efr32/wf200/host_if.cpp @@ -602,6 +602,15 @@ static void wfx_events_task(void * p_arg) retryJoin = 0; retryInterval = WLAN_MIN_RETRY_TIMER_MS; wfx_lwip_set_sta_link_up(); +#ifdef SLEEP_ENABLED + if (!(wfx_get_wifi_state() & SL_WFX_AP_INTERFACE_UP)) + { + // Enable the power save + SILABS_LOG("WF200 going to DTIM based sleep"); + sl_wfx_set_power_mode(WFM_PM_MODE_DTIM, WFM_PM_POLL_FAST_PS, BEACON_1); + sl_wfx_enable_device_power_save(); + } +#endif // SLEEP_ENABLED } if (flags & SL_WFX_DISCONNECT) @@ -887,18 +896,6 @@ int32_t wfx_reset_counts() return -1; } -/************************************************************************ - * @brief - * reset the count - * @return returns -1 - **************************************************************************/ -void wfx_power_save() { - // Enable the power save - SILABS_LOG("WF200 going to DTIM based sleep"); - sl_wfx_set_power_mode(WFM_PM_MODE_DTIM, WFM_PM_POLL_FAST_PS, BEACON_1); - sl_wfx_enable_device_power_save(); -} - /************************************************************************* * @brief * I think that this is getting called before FreeRTOS threads are ready diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index 3ddccdc1c82406..959d337daec16e 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -381,7 +381,8 @@ void ConnectivityManagerImpl::OnStationConnected() event.WiFiConnectivityChange.Result = kConnectivity_Established; (void) PlatformMgr().PostEvent(&event); // Setting the rs911x in the power save mode -#if CHIP_DEVICE_CONFIG_ENABLE_SED +#if (CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI) + // TODO : Remove stop advertising after BLEManagerImpl is fixed chip::DeviceLayer::Internal::BLEManagerImpl().StopAdvertising(); wfx_power_save(); #endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ diff --git a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp index 319a30e16b596b..8126c628b6c36d 100644 --- a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp @@ -665,19 +665,17 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) { CHIP_ERROR err = CHIP_NO_ERROR; int32_t status = 0; - // TODO: change this condition - if (1) + // TODO: add the below code in a condition if (mFlags.Has(Flags::kAdvertising)) + // Since DriveBLEState is not called the device is still advertising advertising + mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising); + mFlags.Set(Flags::kFastAdvertisingEnabled, true); + status = rsi_ble_stop_advertising(); + if (status != RSI_SUCCESS) { - mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising); - mFlags.Set(Flags::kFastAdvertisingEnabled, true); - status = rsi_ble_stop_advertising(); - if (status != RSI_SUCCESS) - { - ChipLogProgress(DeviceLayer, "advertising failed to stop, with status = 0x%lx", status); - } - advertising_set_handle = 0xff; - CancelBleAdvTimeoutTimer(); + ChipLogProgress(DeviceLayer, "advertising failed to stop, with status = 0x%lx", status); } + advertising_set_handle = 0xff; + CancelBleAdvTimeoutTimer(); // exit: return err; diff --git a/src/platform/silabs/efr32/wifi/wfx_host_events.h b/src/platform/silabs/efr32/wifi/wfx_host_events.h index 7aaf3178a69c26..6cb88d33456b9f 100644 --- a/src/platform/silabs/efr32/wifi/wfx_host_events.h +++ b/src/platform/silabs/efr32/wifi/wfx_host_events.h @@ -316,7 +316,6 @@ bool wfx_is_sta_mode_enabled(void); int32_t wfx_get_ap_info(wfx_wifi_scan_result_t * ap); int32_t wfx_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); int32_t wfx_reset_counts(); -void wfx_power_save(); void wfx_clear_wifi_provision(void); sl_status_t wfx_connect_to_ap(void); @@ -353,6 +352,8 @@ void wfx_ip_changed_notify(int got_ip); void wfx_ipv6_notify(int got_ip); #ifdef RS911X_WIFI +/* RSI Power Save */ +void wfx_power_save(); /* RSI for LWIP */ void * wfx_rsi_alloc_pkt(void); void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off); diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 97de1caf125afe..59517d89080e04 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -338,10 +338,14 @@ template("efr32_sdk") { "SL_CATALOG_POWER_MANAGER_PRESENT", "SL_CATALOG_SLEEPTIMER_PRESENT", "SL_SLEEP_TIME_MS=${sleep_time_ms}", + ] + if(defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi){ + defines += [ # Used for wifi devices to get packet details - "WIFI_DEBUG_ENABLED=1", - ] + "WIFI_DEBUG_ENABLED=1", + ] + } } if (chip_build_libshell) { # matter shell From 62c584639c524a3c0f48514e8d609d2d65eb3cb0 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Wed, 26 Apr 2023 16:32:07 +0530 Subject: [PATCH 4/8] addressing review comments --- examples/platform/silabs/efr32/rs911x/rsi_if.c | 10 +++++++--- examples/platform/silabs/efr32/rs911x/wfx_rsi.h | 4 +++- .../platform/silabs/efr32/rs911x/wfx_rsi_host.c | 17 +++++++++++++++-- .../silabs/ConnectivityManagerImpl_WIFI.cpp | 9 +++++++-- .../silabs/efr32/wifi/wfx_host_events.h | 4 +++- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index b9870ff44a4ea6..dae7b0cd4f762e 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -181,6 +181,7 @@ int32_t wfx_rsi_disconnect() return status; } +#if CHIP_DEVICE_CONFIG_ENABLE_SED /****************************************************************** * @fn wfx_rsi_power_save() * @brief @@ -190,7 +191,7 @@ int32_t wfx_rsi_disconnect() * @return * None *********************************************************************/ -void wfx_rsi_power_save() +int32_t wfx_rsi_power_save() { int32_t status; #ifdef RSI_BLE_ENABLE @@ -198,7 +199,7 @@ void wfx_rsi_power_save() if (status != RSI_SUCCESS) { SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status); - return; + return status; } #endif /* RSI_BLE_ENABLE */ @@ -206,10 +207,13 @@ void wfx_rsi_power_save() if (status != RSI_SUCCESS) { SILABS_LOG("Powersave Config Failed, Error Code : 0x%lX", status); - return; + return status; } SILABS_LOG("Powersave Config Success"); + return status; } +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ + /****************************************************************** * @fn wfx_rsi_join_cb(uint16_t status, const uint8_t *buf, const uint16_t len) * @brief diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h index bd3ab5680a867c..7292970a11c011 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h @@ -91,7 +91,9 @@ int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap); int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); int32_t wfx_rsi_reset_count(); int32_t wfx_rsi_disconnect(); -void wfx_rsi_power_save(); +#if CHIP_DEVICE_CONFIG_ENABLE_SED +int32_t wfx_rsi_power_save(); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ #define SILABS_LOG(...) efr32Log(__VA_ARGS__); #ifdef __cplusplus diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index 0bc375de59913f..a020b395cfb432 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -195,9 +195,22 @@ sl_status_t wfx_connect_to_ap(void) return SL_STATUS_OK; } -void wfx_power_save(){ - wfx_rsi_power_save(); +#if CHIP_DEVICE_CONFIG_ENABLE_SED +/********************************************************************* + * @fn sl_status_t wfx_power_save() + * @brief + * Implements the power save in sleepy application + * @param[in] None + * @return SL_STATUS_OK if successful, + * SL_STATUS_FAIL otherwise + ***********************************************************************/ +sl_status_t wfx_power_save() { + if(wfx_rsi_power_save() != 0) { + return SL_STATUS_FAIL; + } + return SL_STATUS_OK; } +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ /********************************************************************* * @fn void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif) diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index 959d337daec16e..2b145b7050b2b9 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -383,9 +383,14 @@ void ConnectivityManagerImpl::OnStationConnected() // Setting the rs911x in the power save mode #if (CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI) // TODO : Remove stop advertising after BLEManagerImpl is fixed +#if RSI_BLE_ENABLE chip::DeviceLayer::Internal::BLEManagerImpl().StopAdvertising(); - wfx_power_save(); -#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ +#endif /* RSI_BLE_ENABLE */ + sl_status_t err = wfx_power_save(); + if(err != SL_STATUS_OK){ + ChipLogError(DeviceLayer,"Power save config for Wifi failed"); + } +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI */ UpdateInternetConnectivityState(); } diff --git a/src/platform/silabs/efr32/wifi/wfx_host_events.h b/src/platform/silabs/efr32/wifi/wfx_host_events.h index 6cb88d33456b9f..c0724b7237e808 100644 --- a/src/platform/silabs/efr32/wifi/wfx_host_events.h +++ b/src/platform/silabs/efr32/wifi/wfx_host_events.h @@ -353,7 +353,9 @@ void wfx_ipv6_notify(int got_ip); #ifdef RS911X_WIFI /* RSI Power Save */ -void wfx_power_save(); +#if CHIP_DEVICE_CONFIG_ENABLE_SED +sl_status_t wfx_power_save(); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ /* RSI for LWIP */ void * wfx_rsi_alloc_pkt(void); void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off); From cec52af446cc28d761e342dd151e76595ae28896 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 26 Apr 2023 11:02:40 +0000 Subject: [PATCH 5/8] Restyled by clang-format --- examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c | 6 ++++-- src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index a020b395cfb432..fd8ceefa7de4d8 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -204,8 +204,10 @@ sl_status_t wfx_connect_to_ap(void) * @return SL_STATUS_OK if successful, * SL_STATUS_FAIL otherwise ***********************************************************************/ -sl_status_t wfx_power_save() { - if(wfx_rsi_power_save() != 0) { +sl_status_t wfx_power_save() +{ + if (wfx_rsi_power_save() != 0) + { return SL_STATUS_FAIL; } return SL_STATUS_OK; diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index 2b145b7050b2b9..0fb1551c84312d 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -387,8 +387,9 @@ void ConnectivityManagerImpl::OnStationConnected() chip::DeviceLayer::Internal::BLEManagerImpl().StopAdvertising(); #endif /* RSI_BLE_ENABLE */ sl_status_t err = wfx_power_save(); - if(err != SL_STATUS_OK){ - ChipLogError(DeviceLayer,"Power save config for Wifi failed"); + if (err != SL_STATUS_OK) + { + ChipLogError(DeviceLayer, "Power save config for Wifi failed"); } #endif /* CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI */ UpdateInternetConnectivityState(); From 97a89ade1e24e0f9d584618abc7ef93f422fdb32 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 26 Apr 2023 11:02:41 +0000 Subject: [PATCH 6/8] Restyled by gn --- third_party/silabs/efr32_sdk.gni | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 59517d89080e04..b6febb03bd3eb0 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -340,9 +340,9 @@ template("efr32_sdk") { "SL_SLEEP_TIME_MS=${sleep_time_ms}", ] - if(defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi){ + if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) { defines += [ - # Used for wifi devices to get packet details + # Used for wifi devices to get packet details "WIFI_DEBUG_ENABLED=1", ] } From 4b2d147b297371e09da14da65c9295e3721521ec Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Wed, 26 Apr 2023 22:36:57 +0530 Subject: [PATCH 7/8] address review comments --- examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c | 3 ++- src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp | 2 +- src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp | 2 +- third_party/silabs/efr32_sdk.gni | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index fd8ceefa7de4d8..e39a23e5229552 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -32,6 +32,7 @@ #include "wfx_host_events.h" #include "wfx_rsi.h" +#include "rsi_error.h" /* wfxRsi Task will use as its stack */ StackType_t wfxRsiTaskStack[WFX_RSI_TASK_SZ] = { 0 }; @@ -206,7 +207,7 @@ sl_status_t wfx_connect_to_ap(void) ***********************************************************************/ sl_status_t wfx_power_save() { - if (wfx_rsi_power_save() != 0) + if (wfx_rsi_power_save() != RSI_ERROR_NONE) { return SL_STATUS_FAIL; } diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index 0fb1551c84312d..6b10b294b5ad02 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -382,7 +382,7 @@ void ConnectivityManagerImpl::OnStationConnected() (void) PlatformMgr().PostEvent(&event); // Setting the rs911x in the power save mode #if (CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI) - // TODO : Remove stop advertising after BLEManagerImpl is fixed + // TODO: Remove stop advertising after BLEManagerImpl is fixed #if RSI_BLE_ENABLE chip::DeviceLayer::Internal::BLEManagerImpl().StopAdvertising(); #endif /* RSI_BLE_ENABLE */ diff --git a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp index 8126c628b6c36d..4a910e0a29aae5 100644 --- a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp @@ -666,7 +666,7 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) CHIP_ERROR err = CHIP_NO_ERROR; int32_t status = 0; // TODO: add the below code in a condition if (mFlags.Has(Flags::kAdvertising)) - // Since DriveBLEState is not called the device is still advertising advertising + // Since DriveBLEState is not called the device is still advertising mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising); mFlags.Set(Flags::kFastAdvertisingEnabled, true); status = rsi_ble_stop_advertising(); diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index b6febb03bd3eb0..f84e257af916f5 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -343,6 +343,7 @@ template("efr32_sdk") { if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) { defines += [ # Used for wifi devices to get packet details + # TODO: Remove this flag, once the communication is fixed "WIFI_DEBUG_ENABLED=1", ] } From 0b16eb25ccd00ac408b3b3622b8001323c2ec6b1 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 26 Apr 2023 17:07:44 +0000 Subject: [PATCH 8/8] Restyled by clang-format --- examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index e39a23e5229552..0691c21670518a 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -30,9 +30,9 @@ #include "event_groups.h" #include "task.h" +#include "rsi_error.h" #include "wfx_host_events.h" #include "wfx_rsi.h" -#include "rsi_error.h" /* wfxRsi Task will use as its stack */ StackType_t wfxRsiTaskStack[WFX_RSI_TASK_SZ] = { 0 };