From 076551580ccff9173296e8f79be2a38bdfe7b045 Mon Sep 17 00:00:00 2001 From: Anthony Grondin <104731965+AnthonyGrondin@users.noreply.github.com> Date: Mon, 22 May 2023 02:52:41 -0400 Subject: [PATCH] fix(esp-wifi): Update is_started() implementation (#180) The old implementation of is_started() returns `Ok(true)` is the sta or ap is enabled, which is true before wifi_start() has been called. This results in the function returning true, before `start()` has been called. --- esp-wifi/src/wifi/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/esp-wifi/src/wifi/mod.rs b/esp-wifi/src/wifi/mod.rs index 6db28a7418e..e1bf0babc89 100644 --- a/esp-wifi/src/wifi/mod.rs +++ b/esp-wifi/src/wifi/mod.rs @@ -1212,7 +1212,12 @@ impl embedded_svc::wifi::Wifi for WifiController<'_> { } fn is_started(&self) -> Result { - Ok(self.is_sta_enabled()? || self.is_ap_enabled()?) + match crate::wifi::get_wifi_state() { + crate::wifi::WifiState::Invalid => Ok(false), + // We assume that wifi has been started in every other states + _ => Ok(true) + } + } fn is_connected(&self) -> Result {