File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff 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
7879static 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 }
99100out :
100101 return ret ;
You can’t perform that action at this time.
0 commit comments