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

    const CAN_ABORT: bool;
    const MAX_TIMEOUT_MS: u32;
    const ATTEMPTS: u8;
    const EXPECTS_RESPONSE_CODE: bool;

    fn as_bytes(&self) -> Vec<u8, LEN>;
    fn parse(
        &self,
        resp: Result<&[u8], InternalError<'_>>
    ) -> Result<Self::Response, 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};
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;

    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> {
        Ok(NoResponse)
    }
}

Associated Types

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

Associated Constants

Whether or not this command can be aborted.

The max timeout in milliseconds.

The max number of times to attempt a command with automatic retries if using send_retry.

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 instance.

Implementations on Foreign Types

Implementors