From 71c017641a0094fe9ac5f0cdbe19daeb92611a42 Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 27 Jan 2022 04:07:22 +0800 Subject: [PATCH] fix up some debug messages and other minor nits --- services/com/src/main.rs | 2 +- services/root-keys/src/main.rs | 2 - services/shellchat/src/cmds/ssid.rs | 68 +++++------------------------ 3 files changed, 11 insertions(+), 61 deletions(-) diff --git a/services/com/src/main.rs b/services/com/src/main.rs index c607f7d8c..7e76cf714 100644 --- a/services/com/src/main.rs +++ b/services/com/src/main.rs @@ -798,7 +798,7 @@ fn xmain() -> ! { const WF200_PASS_LEN: usize = 64; let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) }; let pass = buffer.to_original::, _>().unwrap(); - info!("WlanSetPass: {}", pass); + info!("WlanSetPass *ssssh!*"); let mut str_ser = StringSer::::new(); match str_ser.encode(&pass.to_str()) { Ok(tx_words) => { diff --git a/services/root-keys/src/main.rs b/services/root-keys/src/main.rs index 55db25454..583bf13b6 100644 --- a/services/root-keys/src/main.rs +++ b/services/root-keys/src/main.rs @@ -318,8 +318,6 @@ fn xmain() -> ! { gam::menu_matic(menu_items, crate::ROOTKEY_MENU_NAME, None); let mut policy_followup_action: Option = None; } - // this is the basic default policy of high-security keys -- they stick around until the next suspend - keys.update_policy(Some(PasswordRetentionPolicy::EraseOnSuspend)); // create our very own password modal -- so that critical passwords aren't being shuffled between servers left and right let mut password_action = TextEntry { diff --git a/services/shellchat/src/cmds/ssid.rs b/services/shellchat/src/cmds/ssid.rs index 77eec8e62..5c330b49f 100644 --- a/services/shellchat/src/cmds/ssid.rs +++ b/services/shellchat/src/cmds/ssid.rs @@ -1,17 +1,8 @@ use crate::{ShellCmdApi, CommonEnv}; use xous_ipc::String; -use com::Com; -use ticktimer_server::Ticktimer; use core::fmt::Write; -use xous::{Message, ScalarMessage, MessageEnvelope}; -use num_traits::*; - -#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)] -enum ScanResult { - Ok, - Timeout, -} +use xous::MessageEnvelope; #[derive(Debug)] pub struct Ssid { @@ -41,34 +32,14 @@ impl<'a> ShellCmdApi<'a> for Ssid { if let Some(sub_cmd) = tokens.next() { match sub_cmd { "scan" => { - env.com.set_ssid_scanning(true).expect("couldn't turn on SSID scanning"); - let _ = std::thread::spawn({ - let cb_id = self.cb_id.expect("should have been initialized by this point"); - move || { - let ticktimer = Ticktimer::new().expect("Couldn't connect to Ticktimer"); - let xns = xous_names::XousNames::new().unwrap(); - let callback_conn = xns.request_connection_blocking(crate::SERVER_NAME_SHELLCHAT).unwrap(); - let com = Com::new(&xns).unwrap(); - let mut responded = false; - for _ in 0..15 { - if com.ssid_scan_updated().unwrap() { - // just send a bogus message - xous::send_message(callback_conn, Message::Scalar(ScalarMessage{ - id: cb_id as usize, arg1: ScanResult::Ok.to_usize().unwrap(), arg2: 0, arg3: 0, arg4: 0, - })).unwrap(); - responded = true; - break; - } - ticktimer.sleep_ms(2_000).unwrap(); - } - if !responded { - xous::send_message(callback_conn, Message::Scalar(ScalarMessage{ - id: cb_id as usize, arg1: ScanResult::Ok.to_usize().unwrap(), arg2: 0, arg3: 0, arg4: 0, - })).unwrap(); - } + // SSID scanning is automatically initiated by the connection manager + let ssid_list = env.com.ssid_fetch_as_list().unwrap(); + write!(ret, "RSSI in dBm:\n").unwrap(); + for (rssi, name) in ssid_list { + if name.len() > 0 { + write!(ret, "-{} {}\n", rssi, &name).unwrap(); } - }); - write!(ret, "SSID scan initiated, please wait...").unwrap(); + } } _ => { write!(ret, "{}", helpstring).unwrap(); @@ -80,27 +51,8 @@ impl<'a> ShellCmdApi<'a> for Ssid { Ok(Some(ret)) } - fn callback(&mut self, msg: &MessageEnvelope, env: &mut CommonEnv) -> Result>, xous::Error> { - let mut ret = String::<1024>::new(); - log::trace!("fetching SSID"); - xous::msg_scalar_unpack!(msg, arg1, _arg2, _arg3, _arg4, { - match FromPrimitive::from_usize(arg1) { - Some(ScanResult::Ok) => { - let ssid_list = env.com.ssid_fetch_as_list().unwrap(); - write!(ret, "RSSI in dBm:\n").unwrap(); - for (rssi, name) in ssid_list { - if name.len() > 0 { - write!(ret, "-{} {}\n", rssi, &name).unwrap(); - } - } - } - Some(ScanResult::Timeout) => { - write!(ret, "SSID scan timed out").unwrap(); - } - _ => log::error!("Unknown callback received by ssid scan") - } - - }); + fn callback(&mut self, _msg: &MessageEnvelope, _env: &mut CommonEnv) -> Result>, xous::Error> { + let ret = String::<1024>::new(); Ok(Some(ret)) } }