From c7e1b3d9fb4db87c88cbd92e2d1871db0d17aaa6 Mon Sep 17 00:00:00 2001 From: lambda Date: Mon, 26 Oct 2026 12:39:38 +0300 Subject: [PATCH] feat: add BLE watchdog constants and connection event --- src-tauri/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 243f6f9..25518c0 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -6,6 +6,7 @@ mod telemetry; mod commands; use std::sync::{Arc, Mutex, RwLock}; +use std::time::Duration; use futures::StreamExt; use serde::Serialize; @@ -35,6 +36,20 @@ struct BatteryEvent { percent: u8, } +// Watchdog: how long without telemetry before the connection is considered dead. +const WATCHDOG_STALE_TIMEOUT: Duration = Duration::from_secs(5); +// How many times to retry reconnect before giving up. +const RECONNECT_MAX_ATTEMPTS: u32 = 5; +// Base backoff between reconnect attempts. +const RECONNECT_BACKOFF: Duration = Duration::from_secs(2); + +#[derive(Clone, Serialize)] +struct ConnectionEvent { + device_id: String, + category: String, + status: &'static str, // "reconnecting" | "reconnected" | "gave_up" +} + #[tauri::command] async fn init(app: AppHandle) -> Result<(), String> { let repo = scan_and_classify(&app).await.map_err(|e| e.to_string())?;