Add auto move, rework state machine
This commit is contained in:
@ -29,15 +29,24 @@ use async_channel::Sender;
|
||||
use log::*; //{trace, debug, info, warn, error}
|
||||
|
||||
#[derive(Command)]
|
||||
pub enum Menu<'a> {
|
||||
pub enum Menu{//<'a> {
|
||||
/// Simulate the PIC controller sending aus n Up character
|
||||
PicRecvUp,
|
||||
PicRecvUp {
|
||||
/// 0 for not pressed, 1 for pressed
|
||||
data: u8,
|
||||
},
|
||||
|
||||
/// Simulate the PIC controller sending us a Down character
|
||||
PicRecvDown,
|
||||
PicRecvDown {
|
||||
/// 0 for not pressed, 1 for pressed
|
||||
data: u8,
|
||||
},
|
||||
|
||||
/// Simulate the PIC controller sending us a Stop character
|
||||
PicRecvStop,
|
||||
PicRecvStop {
|
||||
/// 0 for not pressed, 1 for pressed
|
||||
data: u8,
|
||||
},
|
||||
|
||||
/// Simulate the PIC controller sending a "pair" button press
|
||||
PicRecvPair,
|
||||
@ -73,9 +82,9 @@ pub enum Menu<'a> {
|
||||
BluetoothBottomLimit { data: u8 },
|
||||
|
||||
/// Send a bluetooth characteristic: Wifi SSID
|
||||
BluetoothWifiSsid { ssid: &'a str },
|
||||
//BluetoothWifiSsid { ssid: &'a str },
|
||||
/// Send a bluetooth characteristic: Wifi Password
|
||||
BluetoothWifiPassword { wifipass: &'a str },
|
||||
//BluetoothWifiPassword { wifipass: &'a str },
|
||||
|
||||
/// Change log level (None: 0, .. Tracing: 5)
|
||||
Log { level: u8 },
|
||||
@ -85,28 +94,31 @@ pub enum Menu<'a> {
|
||||
|
||||
/// Erase BLE Bonding information
|
||||
ClearBleBonds,
|
||||
|
||||
/// Whatever misc. output I need
|
||||
Misc,
|
||||
|
||||
}
|
||||
|
||||
pub fn process_menu(
|
||||
cli: &mut CliHandle<'_, SimpleWriter, Infallible>,
|
||||
command: Menu<'_>,
|
||||
command: Menu,//<'_>,
|
||||
dispatch: &Sender<Commands>,
|
||||
) -> Result<(), Infallible> {
|
||||
match command {
|
||||
// We ignore sending errors throughout because the Cli interface is only for
|
||||
// testing and debugging.
|
||||
Menu::PicRecvUp => {
|
||||
Menu::PicRecvUp {data} => {
|
||||
cli.writer().write_str("Sending PicButtonUp Received command")?;
|
||||
let _ = dispatch.send_blocking(Commands::PicRecvUp);
|
||||
let _ = dispatch.send_blocking(Commands::PicRecvUp{data});
|
||||
}
|
||||
Menu::PicRecvDown => {
|
||||
Menu::PicRecvDown{data} => {
|
||||
cli.writer().write_str("Sending PicButtonDown command")?;
|
||||
let _ = dispatch.send_blocking(Commands::PicRecvDown);
|
||||
let _ = dispatch.send_blocking(Commands::PicRecvDown{data});
|
||||
}
|
||||
Menu::PicRecvStop => {
|
||||
Menu::PicRecvStop{data} => {
|
||||
cli.writer().write_str("Sending PicButtonStop command")?;
|
||||
let _ = dispatch.send_blocking(Commands::PicRecvStop);
|
||||
let _ = dispatch.send_blocking(Commands::PicRecvStop{data});
|
||||
}
|
||||
Menu::PicRecvPair => {
|
||||
cli.writer().write_str("Sending PIC command and timer reset (the job of the pair button driver, once PIC interface exists)")?; //TODO: PIC get this.
|
||||
@ -125,7 +137,7 @@ pub fn process_menu(
|
||||
Menu::BluetoothStop { data } => {
|
||||
cli.writer()
|
||||
.write_str("SendingBluetoothStop")?;
|
||||
let _ = dispatch.send_blocking(Commands::BluetoothStop { _data: data });
|
||||
let _ = dispatch.send_blocking(Commands::BluetoothStop { data: data });
|
||||
}
|
||||
Menu::BluetoothLearn { data } => {
|
||||
cli.writer()
|
||||
@ -147,7 +159,7 @@ pub fn process_menu(
|
||||
.write_str("TODO: simulate bluetooth characteristic change")?;
|
||||
let _ = data;
|
||||
}
|
||||
Menu::BluetoothWifiSsid { ssid } => {
|
||||
/*Menu::BluetoothWifiSsid { ssid } => {
|
||||
cli.writer()
|
||||
.write_str("TODO: simulate bluetooth characteristic change")?;
|
||||
let _ = ssid;
|
||||
@ -156,7 +168,7 @@ pub fn process_menu(
|
||||
cli.writer()
|
||||
.write_str("TODO: simulate bluetooth characteristic change {}")?;
|
||||
let _ = wifipass;
|
||||
}
|
||||
}*/
|
||||
Menu::Log { level } => {
|
||||
match level {
|
||||
0 => {
|
||||
@ -194,6 +206,9 @@ pub fn process_menu(
|
||||
Menu::ClearBleBonds => {
|
||||
let _ = dispatch.send_blocking(Commands::EraseBleBonds);
|
||||
}
|
||||
Menu::Misc => {
|
||||
println!("string {}, arc string {}, enum value {}, discriminant {}", std::mem::size_of::<String>(), std::mem::size_of::<std::sync::Arc<String>>(), std::mem::size_of::<Menu>(), std::mem::size_of::<std::mem::Discriminant<Menu>>());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user