feat: add BLE watchdog constants and connection event

pull/3/head
lambda 1 week ago
parent 3f48886f5c
commit c7e1b3d9fb
No known key found for this signature in database
GPG Key ID: CF45A8EE158BBCB6

@ -6,6 +6,7 @@ mod telemetry;
mod commands; mod commands;
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
use std::time::Duration;
use futures::StreamExt; use futures::StreamExt;
use serde::Serialize; use serde::Serialize;
@ -35,6 +36,20 @@ struct BatteryEvent {
percent: u8, 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] #[tauri::command]
async fn init(app: AppHandle) -> Result<(), String> { async fn init(app: AppHandle) -> Result<(), String> {
let repo = scan_and_classify(&app).await.map_err(|e| e.to_string())?; let repo = scan_and_classify(&app).await.map_err(|e| e.to_string())?;

Loading…
Cancel
Save