Skip to content

Commit 507074b

Browse files
krish2718rlubos
authored andcommitted
modules: hostap: Fix the disconnect wait timeout
The timeout should be 5s, not 50s. Fix and rename the variables to better reflect their meaning. Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 4e8f034 commit 507074b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modules/hostap/src/supp_api.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ static inline struct wpa_supplicant *get_wpa_s_handle(const struct device *dev)
7575
return z_wpas_get_handle_by_ifname(dev->name);
7676
}
7777

78+
#define WPA_SUPP_STATE_POLLING_MS 10
7879
static int wait_for_disconnect_complete(const struct device *dev)
7980
{
8081
int ret = 0;
81-
int timeout = 0;
82+
int attempts = 0;
8283
struct wpa_supplicant *wpa_s = get_wpa_s_handle(dev);
84+
unsigned int max_attempts = DISCONNECT_TIMEOUT_MS / WPA_SUPP_STATE_POLLING_MS;
8385

8486
if (!wpa_s) {
8587
ret = -ENODEV;
@@ -88,13 +90,12 @@ static int wait_for_disconnect_complete(const struct device *dev)
8890
}
8991

9092
while (wpa_s->wpa_state != WPA_DISCONNECTED) {
91-
if (timeout > DISCONNECT_TIMEOUT_MS) {
93+
if (attempts++ > max_attempts) {
9294
ret = -ETIMEDOUT;
9395
wpa_printf(MSG_WARNING, "Failed to disconnect from network");
9496
break;
9597
}
96-
k_sleep(K_MSEC(10));
97-
timeout++;
98+
k_sleep(K_MSEC(WPA_SUPP_STATE_POLLING_MS));
9899
}
99100
out:
100101
return ret;

0 commit comments

Comments
 (0)