e-bike-tracker-device/src/modem.rs

30 lines
667 B
Rust
Raw Normal View History

2022-06-11 16:49:16 +02:00
use std;
2022-06-10 01:32:52 +02:00
pub struct Modem {
2022-06-11 16:49:16 +02:00
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)
}
2022-06-10 01:32:52 +02:00
}