mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
e2e demo of pddb working now, we can store an ssid/password pair...finally.
This commit is contained in:
parent
7aa2c7b054
commit
dd18d94a03
3 changed files with 35 additions and 12 deletions
|
|
@ -740,7 +740,7 @@ fn xmain() -> ! {
|
||||||
let mut des = StringDes::<STR_64_WORDS, STR_64_U8_SIZE>::new();
|
let mut des = StringDes::<STR_64_WORDS, STR_64_U8_SIZE>::new();
|
||||||
match des.decode_u16(&rx_buf) {
|
match des.decode_u16(&rx_buf) {
|
||||||
Ok(status) => {
|
Ok(status) => {
|
||||||
info!("status: {}", status);
|
log::debug!("status: {}", status);
|
||||||
let status_str = String::<STR_64_U8_SIZE>::from_str(&status);
|
let status_str = String::<STR_64_U8_SIZE>::from_str(&status);
|
||||||
let _ = buffer.replace(status_str);
|
let _ = buffer.replace(status_str);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -406,7 +406,7 @@ struct TokenRecord {
|
||||||
#[xous::xous_main]
|
#[xous::xous_main]
|
||||||
fn xmain() -> ! {
|
fn xmain() -> ! {
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
log::set_max_level(log::LevelFilter::Debug);
|
log::set_max_level(log::LevelFilter::Info);
|
||||||
log::info!("my PID is {}", xous::process::id());
|
log::info!("my PID is {}", xous::process::id());
|
||||||
|
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
|
|
@ -830,6 +830,7 @@ fn xmain() -> ! {
|
||||||
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) };
|
||||||
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
let mut req = buffer.to_original::<PddbDictRequest, _>().unwrap();
|
||||||
if key_token.is_some() {
|
if key_token.is_some() {
|
||||||
|
log::debug!("key list already in progress");
|
||||||
req.code = PddbRequestCode::AccessDenied;
|
req.code = PddbRequestCode::AccessDenied;
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -842,17 +843,31 @@ fn xmain() -> ! {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let dict = req.dict.as_str().expect("dict utf-8 decode error");
|
let dict = req.dict.as_str().expect("dict utf-8 decode error");
|
||||||
|
log::debug!("counting keys in dict {} basis {:?}", dict, bname);
|
||||||
match basis_cache.key_list(&mut pddb_os, dict, bname) {
|
match basis_cache.key_list(&mut pddb_os, dict, bname) {
|
||||||
Ok(list) => {
|
Ok(list) => {
|
||||||
req.index = list.len() as u32;
|
log::debug!("count: {}", list.len());
|
||||||
for key in list {
|
if list.len() > 0 {
|
||||||
key_list.push(key);
|
req.index = list.len() as u32;
|
||||||
|
for key in list {
|
||||||
|
log::debug!("key list: {}", key);
|
||||||
|
key_list.push(key);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log::debug!("count is 0, resetting state");
|
||||||
|
// no keys to list, so reset the state
|
||||||
|
key_token = None;
|
||||||
|
key_list.clear();
|
||||||
}
|
}
|
||||||
req.code = PddbRequestCode::NoErr;
|
req.code = PddbRequestCode::NoErr;
|
||||||
}
|
}
|
||||||
Err(e) => match e.kind() {
|
Err(e) => {
|
||||||
std::io::ErrorKind::NotFound => req.code = PddbRequestCode::NotFound,
|
key_token = None;
|
||||||
_ => req.code = PddbRequestCode::InternalError,
|
key_list.clear();
|
||||||
|
match e.kind() {
|
||||||
|
std::io::ErrorKind::NotFound => req.code = PddbRequestCode::NotFound,
|
||||||
|
_ => req.code = PddbRequestCode::InternalError,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
|
|
@ -869,14 +884,17 @@ fn xmain() -> ! {
|
||||||
} else {
|
} else {
|
||||||
req.key = xous_ipc::String::<KEY_NAME_LEN>::from_str(&key_list[req.index as usize]);
|
req.key = xous_ipc::String::<KEY_NAME_LEN>::from_str(&key_list[req.index as usize]);
|
||||||
req.code = PddbRequestCode::NoErr;
|
req.code = PddbRequestCode::NoErr;
|
||||||
|
log::debug!("fetching key at index {}: {}", req.index, req.key);
|
||||||
// the last index requested must be the highest one!
|
// the last index requested must be the highest one!
|
||||||
if req.index == key_list.len() as u32 - 1 {
|
if req.index == key_list.len() as u32 - 1 {
|
||||||
|
log::debug!("last key, resetting state");
|
||||||
key_token = None;
|
key_token = None;
|
||||||
key_list.clear();
|
key_list.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
log::debug!("multiple concurrent requests detected, returning error");
|
||||||
req.code = PddbRequestCode::AccessDenied;
|
req.code = PddbRequestCode::AccessDenied;
|
||||||
}
|
}
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
|
|
@ -897,9 +915,14 @@ fn xmain() -> ! {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let list = basis_cache.dict_list(&mut pddb_os, bname);
|
let list = basis_cache.dict_list(&mut pddb_os, bname);
|
||||||
req.index = list.len() as u32;
|
if list.len() > 0 {
|
||||||
for dict in list {
|
req.index = list.len() as u32;
|
||||||
dict_list.push(dict);
|
for dict in list {
|
||||||
|
dict_list.push(dict);
|
||||||
|
}
|
||||||
|
} else { // no dicts to list, reset the state
|
||||||
|
dict_token = None;
|
||||||
|
dict_list.clear();
|
||||||
}
|
}
|
||||||
req.code = PddbRequestCode::NoErr;
|
req.code = PddbRequestCode::NoErr;
|
||||||
buffer.replace(req).unwrap();
|
buffer.replace(req).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ impl<'a> ShellCmdApi<'a> for Wlan {
|
||||||
env: &mut CommonEnv,
|
env: &mut CommonEnv,
|
||||||
) -> Result<Option<String<1024>>, xous::Error> {
|
) -> Result<Option<String<1024>>, xous::Error> {
|
||||||
let mut ret = String::<1024>::new();
|
let mut ret = String::<1024>::new();
|
||||||
let helpstring = "wlan [on] [off] [setssid ...] [setpass ...] [join] [leave] [status]";
|
let helpstring = "wlan [on] [off] [setssid ...] [setpass ...] [join] [leave] [status] [save]";
|
||||||
let mut show_help = false;
|
let mut show_help = false;
|
||||||
|
|
||||||
let mut tokens = args.as_str().unwrap().split(' ');
|
let mut tokens = args.as_str().unwrap().split(' ');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue