Skip to content

Commit

Permalink
change apn settings to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
tarfu committed Jan 15, 2024
1 parent 1b9838e commit b6bfa7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ defmt = [

log = ["dep:log", "ublox-sockets?/log", "atat/log"]

automatic-apn = []

lara-r2 = []
lara-r6 = []
leon-g1 = []
Expand Down
30 changes: 5 additions & 25 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,7 @@ pub trait CellularConfig {
const HEX_MODE: bool = true;
const OPERATOR_FORMAT: OperatorFormat = OperatorFormat::Long;

const APN: APNInfo = APNInfo {
apn: Apn::Automatic,
user_name: None,
password: None,
};
const APN: Apn = Apn::None;

fn reset_pin(&mut self) -> Option<&mut Self::ResetPin>;
fn power_pin(&mut self) -> Option<&mut Self::PowerPin>;
Expand All @@ -96,30 +92,14 @@ pub enum OperatorFormat {

#[derive(Debug, Clone)]
pub enum Apn {
Given(String<100>),
None,
Given{ name: String<64>, username: Option<String<64>>, password: Option<String<64>>},
#[cfg(any(feature = "automatic-apn"))]
Automatic,
}

impl Default for Apn {
fn default() -> Self {
Self::Automatic
}
}

#[derive(Debug, Clone, Default)]
pub struct APNInfo {
pub apn: Apn,
pub user_name: Option<String<64>>,
pub password: Option<String<64>>,
}

impl APNInfo {
#[must_use]
pub fn new(apn: &str) -> Self {
Self {
apn: Apn::Given(String::try_from(apn).unwrap()),
user_name: None,
password: None,
}
Self::None
}
}

0 comments on commit b6bfa7c

Please sign in to comment.