dummy gprs connect with error handling
This commit is contained in:
parent
985ec56e2a
commit
fbe132295e
2 changed files with 29 additions and 3 deletions
28
src/modem.rs
28
src/modem.rs
|
@ -1,3 +1,29 @@
|
|||
use std;
|
||||
|
||||
pub struct Modem {
|
||||
// TODO: connect to GPRS
|
||||
is_connected: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ModemConnectionError;
|
||||
|
||||
impl std::fmt::Display for ModemConnectionError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "gprs connection error")
|
||||
}
|
||||
}
|
||||
|
||||
type ModemConnection = Result<Modem, ModemConnectionError>;
|
||||
|
||||
impl Modem {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
is_connected: false,
|
||||
}
|
||||
}
|
||||
pub fn connect_to_gprs_ap(mut self, apn: &str, username: &str, password: &str)-> ModemConnection {
|
||||
// TODO: set AT command for connecting to gprs
|
||||
self.is_connected = true;
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue