From ac8e90dbc1fd6a0b49fb332be1c6dec3bec01338 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Wed, 26 Apr 2023 15:16:40 +0530 Subject: [PATCH] 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