From 5ef7126edee364529d98beee80f88d60b2ee883e Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 27 Jan 2022 14:02:28 +0800 Subject: [PATCH] add better handling for wfx HIF err condition --- Cargo.lock | 2 +- imports/com_rs-ref/Cargo.toml | 2 +- services/com/src/api.rs | 3 +++ services/net/src/connection_manager.rs | 15 ++++++++++++--- services/net/src/main.rs | 1 + 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 316ed73a5..3621ff43d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -477,7 +477,7 @@ dependencies = [ [[package]] name = "com_rs" version = "0.1.0" -source = "git+https://github.com/betrusted-io/com_rs.git?rev=7df87fd4914eb3d2f74bf630aa0b828123368fce#7df87fd4914eb3d2f74bf630aa0b828123368fce" +source = "git+https://github.com/betrusted-io/com_rs.git?rev=f7c46612a4181e3d33ec6c5fc90740062d2d9832#f7c46612a4181e3d33ec6c5fc90740062d2d9832" [[package]] name = "com_rs-ref" diff --git a/imports/com_rs-ref/Cargo.toml b/imports/com_rs-ref/Cargo.toml index 080d7dc07..4a1be6c2c 100644 --- a/imports/com_rs-ref/Cargo.toml +++ b/imports/com_rs-ref/Cargo.toml @@ -7,7 +7,7 @@ description = "com_rs import package" # Dependency policy: fully specify dependencies to the minor version number [dependencies] -com_rs = { git = "https://github.com/betrusted-io/com_rs.git", rev = "7df87fd4914eb3d2f74bf630aa0b828123368fce" } +com_rs = { git = "https://github.com/betrusted-io/com_rs.git", rev = "f7c46612a4181e3d33ec6c5fc90740062d2d9832" } #com_rs = { path = "../../../betrusted-ec/sw/com_rs" } diff --git a/services/com/src/api.rs b/services/com/src/api.rs index 09c02879c..ec1e6633e 100644 --- a/services/com/src/api.rs +++ b/services/com/src/api.rs @@ -309,6 +309,7 @@ pub enum ComIntSources { WlanRxErr, Disconnect, Connect, + WfxErr, Invalid, } impl From for ComIntSources { @@ -323,6 +324,7 @@ impl From for ComIntSources { com_rs_ref::INT_WLAN_RX_ERROR => ComIntSources::WlanRxErr, com_rs_ref::INT_WLAN_DISCONNECT => ComIntSources::Disconnect, com_rs_ref::INT_WLAN_CONNECT_EVENT => ComIntSources::Connect, + com_rs_ref::INT_WLAN_WFX_ERR => ComIntSources::WfxErr, _ => ComIntSources::Invalid, } } @@ -339,6 +341,7 @@ impl From for u16 { ComIntSources::WlanRxErr => com_rs_ref::INT_WLAN_RX_ERROR, ComIntSources::Connect => com_rs_ref::INT_WLAN_CONNECT_EVENT, ComIntSources::Disconnect => com_rs_ref::INT_WLAN_DISCONNECT, + ComIntSources::WfxErr => com_rs_ref::INT_WLAN_WFX_ERR, ComIntSources::Invalid => 0, } } diff --git a/services/net/src/connection_manager.rs b/services/net/src/connection_manager.rs index 7516473c5..7bc3cbd3c 100644 --- a/services/net/src/connection_manager.rs +++ b/services/net/src/connection_manager.rs @@ -16,7 +16,7 @@ use crate::ComIntSources; const BOOT_POLL_INTERVAL_MS: usize = 3_758; // a slightly faster poll during boot so we acquire wifi faster once PDDB is mounted /// this is shared externally so other functions (e.g. in status bar) that want to query the net manager know how long to back off, otherwise the status query will block #[allow(dead_code)] -const POLL_INTERVAL_MS: usize = 10_151; // stagger slightly off of an integer-seconds interval to even out loads. impacts rssi update frequency. +const POLL_INTERVAL_MS: usize = 7_151; // stagger slightly off of an integer-seconds interval to even out loads. impacts rssi update frequency. const INTERVALS_BEFORE_RETRY: usize = 3; // how many poll intervals we'll wait before we give up and try a new AP #[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)] @@ -199,8 +199,10 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc { + log::info!("{:?}", source); wifi_state = match ConnectResult::decode_u16(raw_arg as u16) { ConnectResult::Success => { com.set_ssid_scanning(false).unwrap(); @@ -218,12 +220,14 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc { + log::info!("{:?}", source); ssid_list.clear(); // clear the ssid list because a likely cause of disconnect is we've moved out of range com.set_ssid_scanning(true).unwrap(); scan_state = SsidScanState::Scanning; wifi_state = WifiState::Disconnected; }, ComIntSources::WlanSsidScanUpdate => { + log::info!("{:?}", source); // aggressively pre-fetch results so we can connect as soon as we see an SSID match com.ssid_fetch_as_list() { Ok(slist) => { @@ -233,9 +237,9 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc continue, } - log::debug!("ssid scan update"); }, ComIntSources::WlanSsidScanFinished => { + log::info!("{:?}", source); match com.ssid_fetch_as_list() { Ok(slist) => { for (_rssi, ssid) in slist.iter() { @@ -247,6 +251,7 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc { + log::info!("{:?}", source); activity_interval.store(0, Ordering::SeqCst); wifi_state = WifiState::Connected; log::debug!("comint new wifi state: {:?}", wifi_state); @@ -259,6 +264,10 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc { + log::info!("{:?}", source); + wifi_state = WifiState::Error; + } _ => {} } mask_bit <<= 1; diff --git a/services/net/src/main.rs b/services/net/src/main.rs index 06b925cc0..087d2a486 100644 --- a/services/net/src/main.rs +++ b/services/net/src/main.rs @@ -111,6 +111,7 @@ fn xmain() -> ! { com_int_list.push(ComIntSources::Disconnect); com_int_list.push(ComIntSources::WlanSsidScanUpdate); com_int_list.push(ComIntSources::WlanSsidScanFinished); + com_int_list.push(ComIntSources::WfxErr); com.ints_enable(&com_int_list); com_int_list.clear(); com.ints_get_active(&mut com_int_list);