Skip to content

Commit 8f46fe1

Browse files
committed
fix: do not retry bluetooth connection if adapter not found at startup
1 parent cfb16b1 commit 8f46fe1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/bluetooth.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ const FKM_UUID: uuid::Uuid = uuid::Uuid::from_u128(0x3ee59312_20bc_4c38_9e23_e78
66
const SET_WIFI_UUID: uuid::Uuid = uuid::Uuid::from_u128(0xe2ed1fc5_0d2e_4c2d_a0a7_31e38431cc0c);
77

88
pub async fn start_bluetooth_task() -> Result<()> {
9+
let manager = Manager::new().await?;
10+
if manager.adapters().await.is_err() {
11+
tracing::error!("No bluetooth adapter found!");
12+
return Ok(());
13+
}
14+
915
tokio::task::spawn(async move {
1016
loop {
1117
if let Err(e) = bluetooth_task().await {
@@ -21,11 +27,7 @@ pub async fn start_bluetooth_task() -> Result<()> {
2127

2228
async fn bluetooth_task() -> Result<()> {
2329
let manager = Manager::new().await?;
24-
25-
// silently fail bluetooth task if no bluetooth adapter found / bluez service not found
26-
if manager.adapters().await.is_err() {
27-
return Ok(());
28-
}
30+
manager.adapters().await?;
2931

3032
let adapter = manager
3133
.adapters()

0 commit comments

Comments
 (0)