Skip to content

Commit

Permalink
[Silabs] [WiFi] Fixing the retry logic for the WiFi Devices (project-…
Browse files Browse the repository at this point in the history
…chip#34225)

* Modifying the retry logic for the wifi devices

* Baseapplication.cpp modification of the delegate fix

* Restyled by clang-format

* removing the soc and sleepy condition

* Restyled by clang-format

* Restyled by gn

* moving the variable to efr32_sdk.gni to make it available everywhere

* correcting the path of the 917 ncp file

* fixing the build for the 917 ncp

* addressing the review comments

* fixing the build and replacing the define

* removing the unused else case

* Update third_party/silabs/efr32_sdk.gni

Co-authored-by: mkardous-silabs <[email protected]>

* addressing the review comments

* Restyled by whitespace

* Restyled by clang-format

* fixing the build

* fixing the efr32 build

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: mkardous-silabs <[email protected]>
  • Loading branch information
3 people authored and PeterC1965 committed Aug 28, 2024
1 parent 7a217ae commit fe26d1f
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 416 deletions.
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 @@ -101,11 +101,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;
extern osSemaphoreId_t sl_rs_ble_init_sem;
Expand Down Expand Up @@ -247,12 +242,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 @@ -264,10 +254,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 @@ -693,12 +680,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

0 comments on commit fe26d1f

Please sign in to comment.