Trait atat::AtatCmd[][src]

pub trait AtatCmd<const LEN: usize> {
    type Response: AtatResp;
    type Error: FromStr;

    const CAN_ABORT: bool;
    const MAX_TIMEOUT_MS: u32;
    const FORCE_RECEIVE_STATE: bool;
    const EXPECTS_RESPONSE_CODE: bool;

    fn as_bytes(&self) -> Vec<u8, LEN>;
fn parse(
        &self,
        resp: Result<&[u8], InternalError>
    ) -> Result<Self::Response, Error<Self::Error>>; }
Expand description

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, InternalError, GenericError};
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<64> for SetGreetingText<'a> {
    type Response = NoResponse;
    type Error = GenericError;

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

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

Associated Types

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

The type of the error.

Associated Constants

Whether or not this command can be aborted.

The max timeout in milliseconds.

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

Force client to look for a response. Empty slice is then passed to parse by client. Implemented to enhance expandability fo ATAT

Required methods

Return the command as a heapless Vec of bytes.

Parse the response into a Self::Response or Error<Self::Error> instance.

Implementations on Foreign Types

Implementors