fix up some debug messages and other minor nits

This commit is contained in:
bunnie 2022-01-27 04:07:22 +08:00
parent 4c4ca1577f
commit 71c017641a
3 changed files with 11 additions and 61 deletions

View file

@ -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::<String::<WF200_PASS_LEN>, _>().unwrap();
info!("WlanSetPass: {}", pass);
info!("WlanSetPass *ssssh!*");
let mut str_ser = StringSer::<STR_64_WORDS>::new();
match str_ser.encode(&pass.to_str()) {
Ok(tx_words) => {

View file

@ -318,8 +318,6 @@ fn xmain() -> ! {
gam::menu_matic(menu_items, crate::ROOTKEY_MENU_NAME, None);
let mut policy_followup_action: Option<usize> = 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 {

View file

@ -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<Option<String::<1024>>, 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<Option<String::<1024>>, xous::Error> {
let ret = String::<1024>::new();
Ok(Some(ret))
}
}