diff --git a/gem-remotes-esp32/src/dispatch.rs b/gem-remotes-esp32/src/dispatch.rs index 465b0d7..1a18258 100644 --- a/gem-remotes-esp32/src/dispatch.rs +++ b/gem-remotes-esp32/src/dispatch.rs @@ -21,7 +21,7 @@ pub struct Dispatch { impl Dispatch { pub fn new() -> Dispatch { - let (s, r) = unbounded(); + let (s, r) = unbounded(); //This should always be unbounded, because some callbacks have to send_blocking to it, and if the thread blocks, other tasks can't empty the queue! let mut hmap = HashMap::new(); hmap.reserve(Commands::COUNT); Dispatch { callbacks: hmap, recv: r, endpoint: s} @@ -29,7 +29,7 @@ impl Dispatch { /// Get a channel receiver that will get callbacks for all commands in the listen_for vec. pub fn get_callback_channel(&mut self, listen_for: &Vec) -> RecvQ { - let (send, rec) = unbounded(); + let (send, rec) = unbounded(); // TODO: these could be bounded instead, as these calls are all non-blocking. for cmd in listen_for { let callback_list = self.callbacks.get_mut(&discriminant(&cmd)); match callback_list { @@ -48,9 +48,6 @@ impl Dispatch { rec } - //TODO: Make a discriminant version of this function that takes a vec of discriminants - //TODO: Most of these channels could be fixed size instead unbound; probably only the incomming channel needs to be large. - /// Get a channel sender that will send commands to this dispatcher pub fn get_cmd_channel(&mut self) -> SendQ { self.endpoint.clone() diff --git a/gem-remotes-esp32/src/test_console.rs b/gem-remotes-esp32/src/test_console.rs index 6d11340..0dc3e44 100644 --- a/gem-remotes-esp32/src/test_console.rs +++ b/gem-remotes-esp32/src/test_console.rs @@ -75,6 +75,9 @@ pub enum Menu<'a> { BluetoothWifiPassword { wifipass: &'a str }, Log { level: u8 }, + + /// Abort (resets microcontroller) + Abort, } @@ -176,6 +179,7 @@ pub fn process_menu( debug!("debug test"); trace!("trace test"); } + Menu::Abort => {panic!("CLI user requested abort");} } Ok(()) } @@ -224,8 +228,8 @@ pub async fn start_cli(dispatch: Sender) -> anyhow::Result<()> { } Err(e) => match e.kind() { std::io::ErrorKind::WouldBlock => {} // This is expected if there is no input - _ => {warn!("Error waiting for input: {}", e)} + _ => {warn!("Error waiting for CLI input: {}", e)} } - }; + } } }