fix(bluetooth): await sleep
This commit is contained in:
parent
619550cf61
commit
28c3c7c456
1 changed files with 6 additions and 3 deletions
|
|
@ -82,7 +82,9 @@ async fn start_listening(
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
_ = tokio::time::sleep(Duration::from_millis(
|
_ = tokio::time::sleep(Duration::from_millis(
|
||||||
2_u64.saturating_pow(retry_count),
|
2_u64.saturating_pow(retry_count),
|
||||||
));
|
))
|
||||||
|
.await;
|
||||||
|
|
||||||
return State::Ready(retry_count.saturating_add(1));
|
return State::Ready(retry_count.saturating_add(1));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -92,7 +94,8 @@ async fn start_listening(
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
_ = tokio::time::sleep(Duration::from_millis(
|
_ = tokio::time::sleep(Duration::from_millis(
|
||||||
2_u64.saturating_pow(retry_count),
|
2_u64.saturating_pow(retry_count),
|
||||||
));
|
))
|
||||||
|
.await;
|
||||||
return State::Ready(retry_count.saturating_add(1));
|
return State::Ready(retry_count.saturating_add(1));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -551,7 +554,7 @@ impl BluerSessionState {
|
||||||
let _handle: JoinHandle<anyhow::Result<()>> = spawn(async move {
|
let _handle: JoinHandle<anyhow::Result<()>> = spawn(async move {
|
||||||
let mut status = adapter_clone.is_powered().await.unwrap_or_default();
|
let mut status = adapter_clone.is_powered().await.unwrap_or_default();
|
||||||
loop {
|
loop {
|
||||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
_ = tokio::time::sleep(Duration::from_secs(5)).await;
|
||||||
let new_status = adapter_clone.is_powered().await.unwrap_or_default();
|
let new_status = adapter_clone.is_powered().await.unwrap_or_default();
|
||||||
if new_status != status {
|
if new_status != status {
|
||||||
status = new_status;
|
status = new_status;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue