Skip to content

Commit

Permalink
add APNInfo to config as const
Browse files Browse the repository at this point in the history
  • Loading branch information
tarfu committed Jan 14, 2024
1 parent 458f6b3 commit 9ffae98
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use core::convert::Infallible;
use embedded_hal::digital::{ErrorType, InputPin, OutputPin, PinState};
use heapless::String;

pub struct NoPin;

Expand Down Expand Up @@ -75,6 +76,12 @@ 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,
};

fn reset_pin(&mut self) -> Option<&mut Self::ResetPin>;
fn power_pin(&mut self) -> Option<&mut Self::PowerPin>;
fn vint_pin(&mut self) -> Option<&mut Self::VintPin>;
Expand All @@ -86,3 +93,33 @@ pub enum OperatorFormat {
Short = 1,
Numeric = 2,
}

#[derive(Debug, Clone)]
pub enum Apn {
Given(String<100>),
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,
}
}
}

0 comments on commit 9ffae98

Please sign in to comment.