reorder functions
This commit is contained in:
24
src/main.rs
24
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<Mutex<SmallVec<[mpsc::Sender<()>; 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<Option<process::Child>> = RefCell::new(None)
|
||||
}
|
||||
@@ -60,6 +48,18 @@ async fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
fn button_pressed(_level: Level,
|
||||
clients: &Arc<Mutex<SmallVec<[mpsc::Sender<()>; 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<Mutex<SmallVec<[mpsc::Sender<()>; CHANNEL_VEC_SIZE]>>>) {
|
||||
// GET /
|
||||
let root = warp::path::end()
|
||||
|
||||
Reference in New Issue
Block a user