mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
net: add method to turn on wifi without scanning
This commit is contained in:
parent
82c31e760b
commit
073110c737
3 changed files with 49 additions and 4 deletions
|
|
@ -26,6 +26,7 @@ pub(crate) enum ConnectionManagerOpcode {
|
||||||
Stop,
|
Stop,
|
||||||
DisconnectAndStop,
|
DisconnectAndStop,
|
||||||
WifiOnAndRun,
|
WifiOnAndRun,
|
||||||
|
WifiOn,
|
||||||
SubscribeWifiStats,
|
SubscribeWifiStats,
|
||||||
UnsubWifiStats,
|
UnsubWifiStats,
|
||||||
FetchSsidList,
|
FetchSsidList,
|
||||||
|
|
@ -511,6 +512,31 @@ pub(crate) fn connection_manager(sid: xous::SID, activity_interval: Arc<AtomicU3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
Some(ConnectionManagerOpcode::WifiOn) => msg_scalar_unpack!(msg, _, _, _, _, {
|
||||||
|
com.wlan_set_on().expect("couldn't turn on wifi");
|
||||||
|
wifi_state = WifiState::Disconnected;
|
||||||
|
ssid_list.clear();
|
||||||
|
com.set_ssid_scanning(false).unwrap();
|
||||||
|
scan_state = SsidScanState::Idle;
|
||||||
|
intervals_without_activity = 0;
|
||||||
|
scan_count = 0;
|
||||||
|
// this will force the UI to transition from 'WiFi Off' -> 'Not connected'
|
||||||
|
wifi_stats_cache = WlanStatus {
|
||||||
|
ssid: None,
|
||||||
|
link_state: com_rs_ref::LinkState::Disconnected,
|
||||||
|
ipv4: com::Ipv4Conf::default(),
|
||||||
|
};
|
||||||
|
log::debug!("stats update: {:?}", wifi_stats_cache);
|
||||||
|
for &sub in status_subscribers.keys() {
|
||||||
|
let buf = Buffer::into_buf(com::WlanStatusIpc::from_status(wifi_stats_cache)).or(Err(xous::Error::InternalError)).unwrap();
|
||||||
|
buf.send(sub, WifiStateCallback::Update.to_u32().unwrap()).or(Err(xous::Error::InternalError)).unwrap();
|
||||||
|
}
|
||||||
|
if !run.swap(true, Ordering::SeqCst) {
|
||||||
|
if !pumping.load(Ordering::SeqCst) { // avoid having multiple pump messages being sent if a user tries to rapidly toggle the run/stop switch
|
||||||
|
send_message(run_cid, Message::new_scalar(PumpOp::Pump.to_usize().unwrap(), 0, 0, 0, 0)).expect("couldn't kick off next poll");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
Some(ConnectionManagerOpcode::DisconnectAndStop) => {
|
Some(ConnectionManagerOpcode::DisconnectAndStop) => {
|
||||||
run.store(false, Ordering::SeqCst);
|
run.store(false, Ordering::SeqCst);
|
||||||
wifi_state = WifiState::Off;
|
wifi_state = WifiState::Off;
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,11 @@ impl NetManager {
|
||||||
Message::new_scalar(Opcode::ConnMgrStartStop.to_usize().unwrap(), 3, 0,0, 0)
|
Message::new_scalar(Opcode::ConnMgrStartStop.to_usize().unwrap(), 3, 0,0, 0)
|
||||||
).map(|_| ())
|
).map(|_| ())
|
||||||
}
|
}
|
||||||
|
pub fn connection_manager_wifi_on(&self) -> Result<(), xous::Error> {
|
||||||
|
send_message(self.netconn.conn(),
|
||||||
|
Message::new_scalar(Opcode::ConnMgrStartStop.to_usize().unwrap(), 4, 0,0, 0)
|
||||||
|
).map(|_| ())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
impl Drop for NetManager {
|
impl Drop for NetManager {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
|
|
||||||
|
|
@ -2103,7 +2103,7 @@ fn main() -> ! {
|
||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.expect("couldn't send stop message");
|
.expect("couldn't send scan stop message");
|
||||||
} else if code == 1 {
|
} else if code == 1 {
|
||||||
send_message(
|
send_message(
|
||||||
cm_cid,
|
cm_cid,
|
||||||
|
|
@ -2117,7 +2117,7 @@ fn main() -> ! {
|
||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.expect("couldn't send stop message");
|
.expect("couldn't send scan run message");
|
||||||
} else if code == 2 {
|
} else if code == 2 {
|
||||||
send_message(
|
send_message(
|
||||||
cm_cid,
|
cm_cid,
|
||||||
|
|
@ -2131,7 +2131,7 @@ fn main() -> ! {
|
||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.expect("couldn't send disconnect and stop message");
|
.expect("couldn't send wifi disconnect and stop message");
|
||||||
} else if code == 3 {
|
} else if code == 3 {
|
||||||
send_message(
|
send_message(
|
||||||
cm_cid,
|
cm_cid,
|
||||||
|
|
@ -2145,7 +2145,21 @@ fn main() -> ! {
|
||||||
0,
|
0,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.expect("couldn't send disconnect and stop message");
|
.expect("couldn't send wifi on and run message");
|
||||||
|
} else if code == 4 {
|
||||||
|
send_message(
|
||||||
|
cm_cid,
|
||||||
|
Message::new_scalar(
|
||||||
|
connection_manager::ConnectionManagerOpcode::WifiOn
|
||||||
|
.to_usize()
|
||||||
|
.unwrap(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.expect("couldn't send wifi on message");
|
||||||
} else {
|
} else {
|
||||||
log::error!("Got incorrect start/stop code: {}", code);
|
log::error!("Got incorrect start/stop code: {}", code);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue