fix wifi async fn disconnect hanging if not connected when called (#2392)
* fix wifi async fn disconnect hanging if not connected when called * update changelog * clarify comment * add pr number to changelog
This commit is contained in:
parent
5f6ca8d252
commit
1de2483609
@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Fixed
|
||||
|
||||
- Fixed a possible crash when parsing results from a radius server (#2380)
|
||||
- Fixed `async fn WifiController::disconnect` hanging forever when awaited if not connected when called (#2392).
|
||||
|
||||
### Removed
|
||||
|
||||
|
||||
@ -3366,6 +3366,13 @@ mod asynch {
|
||||
/// Async version of [`crate::wifi::WifiController`]'s `Disconnect`
|
||||
/// method
|
||||
pub async fn disconnect(&mut self) -> Result<(), WifiError> {
|
||||
// If not connected, this will do nothing.
|
||||
// It will also wait forever for a `StaDisconnected` event that will never come.
|
||||
// Return early instead of hanging.
|
||||
if !matches!(self.is_connected(), Ok(true)) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Self::clear_events(WifiEvent::StaDisconnected);
|
||||
crate::wifi::WifiController::disconnect_impl(self)?;
|
||||
WifiEventFuture::new(WifiEvent::StaDisconnected).await;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user