// === Constants ============================================================== const MAX_COMMAND_SIZE: usize = 64; // in bytes; we want to test wifi ssid which // can be 32 bytes. const MAX_HISTORY_SIZE: usize = 128; // in bytes const SLEEP_TIME_MS: u64 = 10; // should be > 1/CONFIG_FREERTOS_HZ in sdkconfig // currently this is 1ms, which is also about as // long as it would take uart buffers to overflow // at maximum rate. But this is intended for // human input only. It's noticeably laggy at 50. // ============================================================================ use ::{ anyhow::Result, embedded_cli::{ cli::{CliBuilder, CliHandle}, Command, }, esp_idf_svc::timer::EspTaskTimerService, std::{ convert::Infallible, io::{stdin, stdout, Read, Write}, //time::Duration, // could also use core::time::Duration? }, core::time::Duration, }; use async_channel::Sender; use log::*; //{trace, debug, info, warn, error} use gem_remotes_lib::{ Button, Commands }; #[derive(Command)] pub enum Menu{//<'a> { /// Send a bluetooth characteristic: Up BluetoothUp { /// 0 for not pressed, 1 for pressed data: u8, }, /// Send a bluetooth characteristic: Down BluetoothDown { /// 0 for not pressed, 1 for pressed data: u8, }, /// Send a bluetooth characteristic: Stop BluetoothStop { /// 0 for not pressed, 1 for pressed data: u8, }, /// Send a bluetooth characteristic: Learn BluetoothLearn { /// 0 for not pressed, 1 for pressed data: u8, }, /// Send a bluetooth characteristic: Auto BluetoothAuto { /// 0 for not pressed, 1 for pressed data: u8, }, /// Send a bluetooth characteristic: Limits BluetoothTopLimit { data: u8 }, /// Send a bluetooth characteristic: Limits BluetoothBottomLimit { data: u8 }, /// Send a bluetooth characteristic: Wifi SSID //BluetoothWifiSsid { ssid: &'a str }, /// Send a bluetooth characteristic: Wifi Password //BluetoothWifiPassword { wifipass: &'a str }, /// Change log level (None: 0, .. Tracing: 5) Log { level: u8 }, /// Abort (resets microcontroller) Abort, /// Erase BLE Bonding information ClearBleBonds, /// Whatever misc. output I need Misc, } fn input_to_button(i: u8) -> Option