[][src]Trait atat::prelude::_atat_AtatCmd

pub trait _atat_AtatCmd {
    type CommandLen: ArrayLength<u8>;
    type Response: AtatResp;
    pub fn as_bytes(&self) -> Vec<u8, Self::CommandLen>;
pub fn parse(&self, resp: &[u8]) -> Result<Self::Response, Error>; pub fn can_abort(&self) -> bool { ... }
pub fn max_timeout_ms(&self) -> u32 { ... }
pub fn force_receive_state(&self) -> bool { ... } }

This trait needs to be implemented for every command type.

It can also be derived by the atat_derive crate.

Example:

use atat::{AtatCmd, AtatResp, Error};
use core::fmt::Write;
use heapless::Vec;

pub struct SetGreetingText<'a> {
    pub text: &'a str,
}

pub struct NoResponse;

impl AtatResp for NoResponse {};

impl<'a> AtatCmd for SetGreetingText<'a> {
    type CommandLen = heapless::consts::U64;
    type Response = NoResponse;

    fn as_bytes(&self) -> Vec<u8, Self::CommandLen> {
        let mut buf: Vec<u8, Self::CommandLen> = Vec::new();
        write!(buf, "AT+CSGT={}", self.text);
        buf
    }

    fn parse(&self, resp: &[u8]) -> Result<Self::Response, Error> {
        Ok(NoResponse)
    }
}

Associated Types

type CommandLen: ArrayLength<u8>[src]

The max length of the command.

Example: For the command "AT+RST" you would specify

type CommandLen = heapless::consts::U6;

type Response: AtatResp[src]

The type of the response. Must implement the AtatResp trait.

Loading content...

Required methods

pub fn as_bytes(&self) -> Vec<u8, Self::CommandLen>[src]

Return the command as a heapless Vec of bytes.

pub fn parse(&self, resp: &[u8]) -> Result<Self::Response, Error>[src]

Parse the response into a Self::Response instance.

Loading content...

Provided methods

pub fn can_abort(&self) -> bool[src]

Whether or not this command can be aborted.

pub fn max_timeout_ms(&self) -> u32[src]

The max timeout in milliseconds.

pub fn force_receive_state(&self) -> bool[src]

Force the ingress manager into receive state immediately after sending the command.

Loading content...

Implementors

Loading content...