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:
Easyoakland 2024-10-23 21:29:00 +00:00 committed by GitHub
parent 5f6ca8d252
commit 1de2483609
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -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

View File

@ -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;