Skip to content

Commit 26e59b6

Browse files
chirag-silabsrestyled-commitsmkardous-silabs
authored
[Silabs] [WiFi] Fixing the retry logic for the WiFi Devices (#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 <84793247+mkardous-silabs@users.noreply.github.com> * addressing the review comments * Restyled by whitespace * Restyled by clang-format * fixing the build * fixing the efr32 build --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com>
1 parent f01ec93 commit 26e59b6

File tree

16 files changed

+131
-416
lines changed

16 files changed

+131
-416
lines changed

examples/platform/silabs/BaseApplication.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ void BaseApplicationDelegate::OnCommissioningWindowClosed()
190190
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
191191
if (BaseApplication::GetProvisionStatus())
192192
{
193+
// After the device is provisioned and the commissioning passed
194+
// resetting the isCommissioningStarted to false
195+
isComissioningStarted = false;
193196
#ifdef DISPLAY_ENABLED
194197
#ifdef QR_CODE_ENABLED
195198
SilabsLCD::Screen_e screen;

examples/platform/silabs/BaseApplication.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@
6565

6666
class BaseApplicationDelegate : public AppDelegate, public chip::FabricTable::Delegate
6767
{
68+
public:
69+
bool isCommissioningInProgress() { return isComissioningStarted; }
70+
6871
private:
6972
// AppDelegate
70-
bool isComissioningStarted;
73+
bool isComissioningStarted = false;
7174
void OnCommissioningSessionStarted() override;
7275
void OnCommissioningSessionStopped() override;
7376
void OnCommissioningWindowClosed() override;

examples/platform/silabs/SiWx917/BUILD.gn

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ declare_args() {
5050

5151
# Sanity check
5252
assert(chip_enable_wifi)
53-
54-
silabs_common_plat_dir = "${chip_root}/examples/platform/silabs"
5553
silabs_plat_si91x_wifi_dir = "${chip_root}/src/platform/silabs/SiWx917/wifi"
5654
import("${silabs_common_plat_dir}/args.gni")
5755

@@ -193,10 +191,10 @@ source_set("siwx917-common") {
193191
"${silabs_common_plat_dir}/SoftwareFaultReports.cpp",
194192
"${silabs_common_plat_dir}/silabs_utils.cpp",
195193
"${silabs_common_plat_dir}/syscalls_stubs.cpp",
194+
"${silabs_common_plat_dir}/wifi/wfx_notify.cpp",
196195
"${silabs_plat_si91x_wifi_dir}/dhcp_client.cpp",
197196
"${silabs_plat_si91x_wifi_dir}/ethernetif.cpp",
198197
"${silabs_plat_si91x_wifi_dir}/lwip_netif.cpp",
199-
"${silabs_plat_si91x_wifi_dir}/wfx_notify.cpp",
200198
"SiWx917/sl_wifi_if.cpp",
201199
"SiWx917/wfx_rsi_host.cpp",
202200
]

examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp

+4-18
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ bool hasNotifiedIPV4 = false;
101101
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
102102
bool hasNotifiedWifiConnectivity = false;
103103

104-
/* Declare a flag to differentiate between after boot-up first IP connection or reconnection */
105-
bool is_wifi_disconnection_event = false;
106-
107-
/* Declare a variable to hold connection time intervals */
108-
uint32_t retryInterval = WLAN_MIN_RETRY_TIMER_MS;
109104
volatile bool scan_results_complete = false;
110105
volatile bool bg_scan_results_complete = false;
111106
extern osSemaphoreId_t sl_rs_ble_init_sem;
@@ -247,12 +242,7 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
247242
callback_status = *(sl_status_t *) result;
248243
ChipLogError(DeviceLayer, "join_callback_handler: failed: 0x%lx", static_cast<uint32_t>(callback_status));
249244
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTED);
250-
wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++);
251-
if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
252-
{
253-
WfxEvent.eventType = WFX_EVT_STA_START_JOIN;
254-
WfxPostEvent(&WfxEvent);
255-
}
245+
wfx_retry_connection(++wfx_rsi.join_retries);
256246
return SL_STATUS_FAIL;
257247
}
258248
/*
@@ -264,10 +254,7 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
264254
WfxEvent.eventType = WFX_EVT_STA_CONN;
265255
WfxPostEvent(&WfxEvent);
266256
wfx_rsi.join_retries = 0;
267-
retryInterval = WLAN_MIN_RETRY_TIMER_MS;
268-
// Once the join passes setting the disconnection event to true to differentiate between the first connection and reconnection
269-
is_wifi_disconnection_event = true;
270-
callback_status = SL_STATUS_OK;
257+
callback_status = SL_STATUS_OK;
271258
return SL_STATUS_OK;
272259
}
273260

@@ -693,12 +680,11 @@ static sl_status_t wfx_rsi_do_join(void)
693680

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

698685
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED);
699686
ChipLogProgress(DeviceLayer, "wfx_rsi_do_join: retry attempt %d", wfx_rsi.join_retries);
700-
wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries);
701-
wfx_rsi.join_retries++;
687+
wfx_retry_connection(++wfx_rsi.join_retries);
702688
event.eventType = WFX_EVT_STA_START_JOIN;
703689
WfxPostEvent(&event);
704690
return status;

examples/platform/silabs/efr32/BUILD.gn

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ declare_args() {
4848
sl_test_event_trigger_enable_key = "00112233445566778899AABBCCDDEEFF"
4949
}
5050

51-
silabs_common_plat_dir = "${chip_root}/examples/platform/silabs"
52-
5351
import("${silabs_common_plat_dir}/args.gni")
5452

5553
# Sanity check

examples/platform/silabs/efr32/rs911x/rs9117.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ rs911x_src_plat = [
88
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c",
99
"${examples_plat_dir}/rs911x/hal/sl_si91x_ncp_utility.c",
1010
"${examples_plat_dir}/rs911x/hal/efx32_ncp_host.c",
11-
"${silabs_plat_efr32_wifi_dir}/wfx_notify.cpp",
11+
"${silabs_common_plat_dir}/wifi/wfx_notify.cpp",
1212
]
1313

1414
rs9117_inc_plat = [

examples/platform/silabs/efr32/rs911x/rs911x.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ rs911x_src_plat = [
99
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_ioports.c",
1010
"${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_timer.c",
1111
"${examples_plat_dir}/rs911x/hal/efx_spi.c",
12-
"${silabs_plat_efr32_wifi_dir}/wfx_notify.cpp",
12+
"${silabs_common_plat_dir}/wifi/wfx_notify.cpp",
1313
]
1414

1515
#

0 commit comments

Comments
 (0)