Modem

Struct Modem 

Source
pub struct Modem<'a, AtCl, const N: usize, const L: usize> { /* private fields */ }
Expand description

A handle to the modem, providing access to AT command operations and URC subscription handling.

Implementations§

Source§

impl<'a, AtCl, const N: usize, const L: usize> Modem<'a, AtCl, N, L>
where AtCl: AtatClient,

Source

pub fn new(client: AtCl, urc_chan: &'a UrcChannel<Urc, N, L>) -> Self

Constructs a new Modem instance with a client, URC channel, and shared state.

§Arguments
  • client: An AT command client for communicating with the modem.
  • urc_chan: A reference to the URC channel used to receive asynchronous modem messages.

This method does not initialize the modem; call begin to do so.

Source

pub fn urc_handler(&self) -> UrcHandler<'a, N, L>

Creates a new URC handler associated with this modem.

The URC handler will subscribe to unsolicited messages from the modem and process them, updating shared state where necessary. The user must run the UrcHandler to begin handling messages.

§Panics

Panics if the subscription to the URC channel fails (e.g., buffer full or uninitialized).

Source

pub async fn send<Cmd: AtatCmd>( &mut self, cmd: &Cmd, ) -> Result<Cmd::Response, Error>

Source

pub async fn begin(&mut self) -> Result<(), Error>

Initializes the modem by sending basic configuration commands.

This method must be called once before other modem operations are invoked. It is safe to call multiple times; subsequent calls will be no-ops.

  • Enables numeric CME error reporting.
  • Enables network registration URC reporting.
Source

pub async fn get_operation_mode(&mut self) -> Result<RAT, Error>

Source

pub async fn set_opeartion_mode(&mut self, mode: RAT) -> Result<(), Error>

Source

pub async fn ping(&mut self) -> Result<(), Error>

Source

pub async fn define_pdp_context(&mut self) -> Result<(), Error>

Source

pub async fn set_op_state(&mut self, mode: FunctionalMode) -> Result<(), Error>

Source

pub fn get_network_registration_state(&self) -> NetworkRegistrationState

Source§

impl<'sub, AtCl, const N: usize, const L: usize> Modem<'sub, AtCl, N, L>
where AtCl: AtatClient,

Source

pub async fn lte_connect(&mut self) -> Result<(), Error>

Connect to the LTE network.

This function will connect the modem to the LTE network. This function will block until the modem is attached.

Source

pub async fn lte_disconnect(&mut self) -> Result<(), Error>

Disconnect from the LTE network.

This function will disconnect the modem from the LTE network and block until the network is actually disconnected. After the network is disconnected the GNSS subsystem can be used.

Source§

impl<'sub, AtCl, const N: usize, const L: usize> Modem<'sub, AtCl, N, L>
where AtCl: AtatClient,

Source

pub async fn mqtt_configure( &mut self, client_id: &str, auth: Option<MqttAuth>, ) -> Result<(), Error>

Source

pub async fn mqtt_connect(&mut self, host: &str) -> Result<(), Error>

Source

pub async fn mqtt_send( &mut self, topic: &str, qos: Qos, data: &[u8], ) -> Result<(), Error>

Source

pub async fn mqtt_disconnect(&mut self) -> Result<(), Error>

Source§

impl<'sub, AtCl, const N: usize, const L: usize> Modem<'sub, AtCl, N, L>
where AtCl: AtatClient,

Source

pub async fn nvm_write( &mut self, data_type: DataType, index: u8, data: &[u8], ) -> Result<(), Error>

Source§

impl<'sub, AtCl, const N: usize, const L: usize> Modem<'sub, AtCl, N, L>
where AtCl: AtatClient,

Source

pub async fn configure_tls_profile( &mut self, sp_id: u8, ca_cert_id: u8, client_cert_id: u8, client_private_key_id: u8, ) -> Result<(), Error>

Configures TLS/SSL security profile for use with e.g. MQTT.

Certificates first need to be written to NVM (boot persistent).

Auto Trait Implementations§

§

impl<'a, AtCl, const N: usize, const L: usize> Freeze for Modem<'a, AtCl, N, L>
where AtCl: Freeze,

§

impl<'a, AtCl, const N: usize, const L: usize> !RefUnwindSafe for Modem<'a, AtCl, N, L>

§

impl<'a, AtCl, const N: usize, const L: usize> !Send for Modem<'a, AtCl, N, L>

§

impl<'a, AtCl, const N: usize, const L: usize> !Sync for Modem<'a, AtCl, N, L>

§

impl<'a, AtCl, const N: usize, const L: usize> Unpin for Modem<'a, AtCl, N, L>
where AtCl: Unpin,

§

impl<'a, AtCl, const N: usize, const L: usize> !UnwindSafe for Modem<'a, AtCl, N, L>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.