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
Associated Constants
const MAX_TIMEOUT_MS: u32
const MAX_TIMEOUT_MS: u32
The max timeout in milliseconds.
The max number of times to attempt a command with automatic retries if
using send_retry
.
const EXPECTS_RESPONSE_CODE: bool
const EXPECTS_RESPONSE_CODE: bool
Force client to look for a response. Empty slice is then passed to parse by client. Implemented to enhance expandability fo ATAT