Skip to content

Commit

Permalink
fix(esp-wifi): Update is_started() implementation (esp-rs#180)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AnthonyGrondin authored and bjoernQ committed May 24, 2024
1 parent 4f17136 commit 97ee8b1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion esp-wifi/src/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,12 @@ impl embedded_svc::wifi::Wifi for WifiController<'_> {
}

fn is_started(&self) -> Result<bool, Self::Error> {
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<bool, Self::Error> {
Expand Down

0 comments on commit 97ee8b1

Please sign in to comment.