mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
chat implement wifi connect modal
This commit is contained in:
parent
e1f1ac427b
commit
9254163e5a
3 changed files with 55 additions and 28 deletions
|
|
@ -26,10 +26,6 @@ Use another device such as a mobile or PC to:
|
|||
* https://spec.matrix.org/latest/#room-structure
|
||||
* Join the room
|
||||
|
||||
Before switching to mtxchat app on Precursor, ensure that:
|
||||
* the PDDB is mounted
|
||||
* WiFi is connected.
|
||||
|
||||
|
||||
## Functionality
|
||||
|
||||
|
|
@ -62,17 +58,8 @@ The `mtxchat` servers is set to receive:
|
|||
|
||||
## Troubleshooting
|
||||
|
||||
Prequisites: it is essential that the PDDB is mounted and WiFi is
|
||||
connected before running mtxcli. You can verify these in Shellchat
|
||||
with `net ping 1.1.1.1`.
|
||||
If you see the message `WARNING: clock not set` that is likely because the Precursor real time clock needs to be set (e.g. if the battery has been completely discharged). Please go to the menu **Preferences | Set Timezone** to set the time zone (and update the time via NTP).
|
||||
|
||||
If you see the message `WARNING: clock not set` that is likely because
|
||||
the Precursor real time clock needs to be set (e.g. if the battery
|
||||
has been completely discharged). Please go to the menu
|
||||
**Preferences | Set Timezone** to set the time zone
|
||||
(and update the time via NTP).
|
||||
|
||||
If you see the message `authentication failed` it might be because
|
||||
the `user` and `password` variables are not set properly.
|
||||
If you see the message `authentication failed` it might be because the `user` and `password` variables are not set properly.
|
||||
Alternatively it could be because TLS certificate validation
|
||||
has failed because the clock has not been set (see above).
|
||||
|
|
|
|||
|
|
@ -219,11 +219,11 @@
|
|||
"zh": "WiFi connected *EN*"
|
||||
},
|
||||
"mtxchat.wifi.warning": {
|
||||
"en": "WARNING: WiFi not connected",
|
||||
"en-tts": "WARNING: WiFi not connected",
|
||||
"fr": "AVERTISSEMENT: WiFi pas connecté",
|
||||
"ja": "WARNING: WiFi not connected *EN*",
|
||||
"zh": "WARNING: WiFi not connected *EN*"
|
||||
"en": "WiFi not connected. Entering read-only mode",
|
||||
"en-tts": "WiFi not connected Entering read-only mode",
|
||||
"fr": "WiFi pas connecté",
|
||||
"ja": "WiFi not connected. Entering read-only mode *EN*",
|
||||
"zh": "WiFi not connected. Entering read-only mode *EN*"
|
||||
},
|
||||
"mtxchat.close.item": {
|
||||
"en": "Close menu",
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ const DOMAIN_MATRIX: &str = "matrix.org";
|
|||
|
||||
const EMPTY: &str = "";
|
||||
const MTX_LONG_TIMEOUT: i32 = 60000; // ms
|
||||
const WIFI_TIMEOUT: u32 = 10; // seconds
|
||||
|
||||
pub const CLOCK_NOT_SET_ID: usize = 1;
|
||||
pub const PDDB_NOT_MOUNTED_ID: usize = 2;
|
||||
|
|
@ -230,7 +231,7 @@ impl<'a> MtxChat<'a> {
|
|||
|
||||
pub fn connect(&mut self) -> bool {
|
||||
log::info!("Attempting connect to Matrix server");
|
||||
if self.wifi_connected() {
|
||||
if self.wifi() {
|
||||
if self.login() {
|
||||
if let Some(room) = self.get_room_id() {
|
||||
self.dialogue_set(Some(room.as_str()));
|
||||
|
|
@ -527,7 +528,7 @@ impl<'a> MtxChat<'a> {
|
|||
if since.len() > 0 {
|
||||
self.set_debug(SINCE_KEY, since);
|
||||
// don't re-start listening if there was an error
|
||||
if self.logged_in && self.wifi_connected() {
|
||||
if self.logged_in && self.wifi() {
|
||||
self.listen();
|
||||
}
|
||||
}
|
||||
|
|
@ -564,15 +565,54 @@ impl<'a> MtxChat<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn wifi_connected(&self) -> bool {
|
||||
// returns true is wifi is connected
|
||||
//
|
||||
// If wifi is not connected then a modal offers to "Connect to wifi?"
|
||||
// and tries for 10 seconds before representing.
|
||||
//
|
||||
pub fn wifi(&self) -> bool {
|
||||
if HOSTED_MODE {
|
||||
true
|
||||
} else {
|
||||
match self.netmgr.get_ipv4_config() {
|
||||
Some(conf) => conf.dhcp == com_rs::DhcpState::Bound,
|
||||
None => false,
|
||||
return true;
|
||||
}
|
||||
|
||||
if let Some(conf) = self.netmgr.get_ipv4_config() {
|
||||
if conf.dhcp == com_rs::DhcpState::Bound {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
while self.wifi_try_modal() {
|
||||
self.netmgr.connection_manager_wifi_on_and_run().unwrap();
|
||||
self.modals
|
||||
.start_progress("Connecting ...", 0, 10, 0)
|
||||
.expect("no progress bar");
|
||||
let tt = ticktimer_server::Ticktimer::new().unwrap();
|
||||
for wait in 0..WIFI_TIMEOUT {
|
||||
tt.sleep_ms(1000).unwrap();
|
||||
self.modals
|
||||
.update_progress(wait)
|
||||
.expect("no progress update");
|
||||
if let Some(conf) = self.netmgr.get_ipv4_config() {
|
||||
if conf.dhcp == com_rs::DhcpState::Bound {
|
||||
self.modals.finish_progress().expect("failed progress finish");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
// returns true if "Connect to WiFi?" yes option is chosen
|
||||
//
|
||||
fn wifi_try_modal (&self) -> bool {
|
||||
self.modals.add_list_item("yes").expect("failed radio yes");
|
||||
self.modals.add_list_item("no").expect("failed radio no");
|
||||
self.modals.get_radiobutton("Connect to WiFi?").expect("failed radiobutton modal");
|
||||
match self.modals.get_radio_index() {
|
||||
Ok(button) => button == 0,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue