diff --git a/services/net/src/connection_manager.rs b/services/net/src/connection_manager.rs index c879d0c5d..af7f98ffd 100644 --- a/services/net/src/connection_manager.rs +++ b/services/net/src/connection_manager.rs @@ -14,7 +14,9 @@ pub(crate) enum ConnectionManagerOpcode { Quit, } #[allow(dead_code)] -const POLL_INTERVAL_MS: usize = 10_151; // stagger slightly off of an integer-seconds interval to even out loads +const POLL_INTERVAL_MS: usize = 20_151; // stagger slightly off of an integer-seconds interval to even out loads +#[allow(dead_code)] +const BOOT_POLL_INTERVAL_MS: usize = 5_758; // a slightly faster poll during boot so we acquire wifi faster once PDDB is mounted pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc) { let tt = ticktimer_server::Ticktimer::new().unwrap(); @@ -36,25 +38,34 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc msg_scalar_unpack!(msg, poll_interval, _, _, _, { + Some(ConnectionManagerOpcode::Run) => msg_scalar_unpack!(msg, _, _, _, _, { if !run { run = true; - send_message(self_cid, Message::new_scalar(ConnectionManagerOpcode::Poll.to_usize().unwrap(), poll_interval, 0, 0, 0)).expect("couldn't kick off next poll"); + send_message(self_cid, Message::new_scalar(ConnectionManagerOpcode::Poll.to_usize().unwrap(), 0, 0, 0, 0)).expect("couldn't kick off next poll"); } }), - Some(ConnectionManagerOpcode::Poll) => msg_scalar_unpack!(msg, next_poll, _, _, _, { - if activity_interval.fetch_add(POLL_INTERVAL_MS as u32, Ordering::SeqCst) > POLL_INTERVAL_MS as u32 { + Some(ConnectionManagerOpcode::Poll) => msg_scalar_unpack!(msg, _, _, _, _, { + if activity_interval.fetch_add(current_interval as u32, Ordering::SeqCst) > current_interval as u32 { log::info!("wlan activity interval timeout"); // if the pddb isn't mounted, don't even bother checking -- we can't connect until we have a place to get keys if pddb.is_mounted() && rev_ok { + mounted = true; // the status check code is going to get refactored, so this is a "bare minimum" check let status = com.wlan_status().unwrap(); let config = netmgr.get_ipv4_config(); + if status.link_state == com_rs_ref::LinkState::WFXError { + com.wlan_leave().expect("couldn't issue leave command"); // this may not be received by the wf200, *but* it will also re-init the DHCP stack on the EC + netmgr.reset(); // this will clear our internal net state + // the wfx chip is wedged. kick it. This call has a built-in 2 second delay. + com.wifi_reset().expect("couldn't reset the wf200 chip"); + } let needs_reconnect = if status.link_state == com_rs_ref::LinkState::Connected { if let Some(config) = config { // check that the EC's view of the world is synchronized with our view @@ -102,8 +113,13 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc