diff --git a/crates/ble-server/src/main.rs b/crates/ble-server/src/main.rs index 5b5b2b1..09bc03a 100644 --- a/crates/ble-server/src/main.rs +++ b/crates/ble-server/src/main.rs @@ -6,7 +6,7 @@ use std::error::Error; use std::str::FromStr; use std::thread; use std::time::Duration; -use tokio::time; +use tokio::time::{self, sleep}; use uuid::Uuid; #[tokio::main] @@ -43,13 +43,13 @@ async fn main() -> Result<(), Box> { println!("Characteristics: {:#?}", chars); let light = chars.iter().find(|c| c.uuid == characteristic).unwrap(); - - handle - .write(light, &[0x00], WriteType::WithoutResponse) - .await - .unwrap(); - - println!("LED"); + while true { + handle + .write(light, &[0x00], WriteType::WithoutResponse) + .await + .unwrap(); + sleep(Duration::new(2, 0)).await; + } handle.disconnect().await.unwrap();