Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs] [WiFi] Fixing the retry logic for the WiFi Devices #34225

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ void BaseApplicationDelegate::OnCommissioningWindowClosed()
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
if (BaseApplication::GetProvisionStatus())
{
// After the device is provisioned and the commissioning passed
// resetting the isCommissioningStarted to false
isComissioningStarted = false;
#ifdef DISPLAY_ENABLED
#ifdef QR_CODE_ENABLED
SilabsLCD::Screen_e screen;
Expand Down
5 changes: 4 additions & 1 deletion examples/platform/silabs/BaseApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@

class BaseApplicationDelegate : public AppDelegate, public chip::FabricTable::Delegate
{
public:
bool isCommissioningInProgress() { return isComissioningStarted; }

private:
// AppDelegate
bool isComissioningStarted;
bool isComissioningStarted = false;
void OnCommissioningSessionStarted() override;
void OnCommissioningSessionStopped() override;
void OnCommissioningWindowClosed() override;
Expand Down
4 changes: 1 addition & 3 deletions examples/platform/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ declare_args() {

# Sanity check
assert(chip_enable_wifi)

silabs_common_plat_dir = "${chip_root}/examples/platform/silabs"
silabs_plat_si91x_wifi_dir = "${chip_root}/src/platform/silabs/SiWx917/wifi"
import("${silabs_common_plat_dir}/args.gni")

Expand Down Expand Up @@ -193,10 +191,10 @@ source_set("siwx917-common") {
"${silabs_common_plat_dir}/SoftwareFaultReports.cpp",
"${silabs_common_plat_dir}/silabs_utils.cpp",
"${silabs_common_plat_dir}/syscalls_stubs.cpp",
"${silabs_common_plat_dir}/wifi/wfx_notify.cpp",
"${silabs_plat_si91x_wifi_dir}/dhcp_client.cpp",
"${silabs_plat_si91x_wifi_dir}/ethernetif.cpp",
"${silabs_plat_si91x_wifi_dir}/lwip_netif.cpp",
"${silabs_plat_si91x_wifi_dir}/wfx_notify.cpp",
"SiWx917/sl_wifi_if.cpp",
"SiWx917/wfx_rsi_host.cpp",
]
Expand Down
22 changes: 4 additions & 18 deletions examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ bool hasNotifiedIPV4 = false;
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
bool hasNotifiedWifiConnectivity = false;

/* Declare a flag to differentiate between after boot-up first IP connection or reconnection */
bool is_wifi_disconnection_event = false;

/* Declare a variable to hold connection time intervals */
uint32_t retryInterval = WLAN_MIN_RETRY_TIMER_MS;
volatile bool scan_results_complete = false;
volatile bool bg_scan_results_complete = false;

Expand Down Expand Up @@ -259,12 +254,7 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
callback_status = *(sl_status_t *) result;
ChipLogError(DeviceLayer, "join_callback_handler: failed: 0x%lx", static_cast<uint32_t>(callback_status));
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTED);
wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++);
if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
{
WfxEvent.eventType = WFX_EVT_STA_START_JOIN;
WfxPostEvent(&WfxEvent);
}
wfx_retry_connection(++wfx_rsi.join_retries);
return SL_STATUS_FAIL;
}
/*
Expand All @@ -276,10 +266,7 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
WfxEvent.eventType = WFX_EVT_STA_CONN;
WfxPostEvent(&WfxEvent);
wfx_rsi.join_retries = 0;
retryInterval = WLAN_MIN_RETRY_TIMER_MS;
// Once the join passes setting the disconnection event to true to differentiate between the first connection and reconnection
is_wifi_disconnection_event = true;
callback_status = SL_STATUS_OK;
callback_status = SL_STATUS_OK;
return SL_STATUS_OK;
}

Expand Down Expand Up @@ -734,12 +721,11 @@ static sl_status_t wfx_rsi_do_join(void)

// failure only happens when the firmware returns an error
ChipLogError(DeviceLayer, "wfx_rsi_do_join: sl_wifi_connect failed: 0x%lx", static_cast<uint32_t>(status));
VerifyOrReturnError((is_wifi_disconnection_event || wfx_rsi.join_retries <= MAX_JOIN_RETRIES_COUNT), status);
VerifyOrReturnError((wfx_rsi.join_retries <= MAX_JOIN_RETRIES_COUNT), status);

wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED);
ChipLogProgress(DeviceLayer, "wfx_rsi_do_join: retry attempt %d", wfx_rsi.join_retries);
wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries);
wfx_rsi.join_retries++;
wfx_retry_connection(++wfx_rsi.join_retries);
event.eventType = WFX_EVT_STA_START_JOIN;
WfxPostEvent(&event);
return status;
Expand Down
2 changes: 0 additions & 2 deletions examples/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ declare_args() {
sl_test_event_trigger_enable_key = "00112233445566778899AABBCCDDEEFF"
}

silabs_common_plat_dir = "${chip_root}/examples/platform/silabs"

import("${silabs_common_plat_dir}/args.gni")

# Sanity check
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/efr32/rs911x/rs9117.gni
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rs911x_src_plat = [
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c",
"${examples_plat_dir}/rs911x/hal/sl_si91x_ncp_utility.c",
"${examples_plat_dir}/rs911x/hal/efx32_ncp_host.c",
"${silabs_plat_efr32_wifi_dir}/wfx_notify.cpp",
"${silabs_common_plat_dir}/wifi/wfx_notify.cpp",
]

rs9117_inc_plat = [
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/silabs/efr32/rs911x/rs911x.gni
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rs911x_src_plat = [
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_ioports.c",
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_timer.c",
"${examples_plat_dir}/rs911x/hal/efx_spi.c",
"${silabs_plat_efr32_wifi_dir}/wfx_notify.cpp",
"${silabs_common_plat_dir}/wifi/wfx_notify.cpp",
]

#
Expand Down
Loading
Loading