diff --git a/src/main.rs b/src/main.rs index 8b8ef4a..450b06b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,18 +17,6 @@ const OUTDOOR_CHIME_FILE: &str = "static/outdoor.mp3"; const BUTTON_PIN: u8 = 26; const CHANNEL_VEC_SIZE: usize = 32; -fn button_pressed(_level: Level, - clients: &Arc; CHANNEL_VEC_SIZE]>>>) { - info!("DOORBELL PRESS"); - clients.lock().unwrap().retain(|tx: &mut mpsc::Sender<()>| { - match tx.try_send(()) { - Ok(_) => true, - Err(mpsc::error::TrySendError::Full(_)) => true, // we just get some free debouncing - Err(mpsc::error::TrySendError::Closed(_)) => { info!("Event client disconnected"); false } - } - }); -} - thread_local! { static AUDIO_CHILD: RefCell> = RefCell::new(None) } @@ -60,6 +48,18 @@ async fn main() { } } +fn button_pressed(_level: Level, + clients: &Arc; CHANNEL_VEC_SIZE]>>>) { + info!("DOORBELL PRESS"); + clients.lock().unwrap().retain(|tx: &mut mpsc::Sender<()>| { + match tx.try_send(()) { + Ok(_) => true, + Err(mpsc::error::TrySendError::Full(_)) => true, // we just get some free debouncing + Err(mpsc::error::TrySendError::Closed(_)) => { info!("Event client disconnected"); false } + } + }); +} + async fn warp(clients: Arc; CHANNEL_VEC_SIZE]>>>) { // GET / let root = warp::path::end()