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
Associated Constants
const MAX_TIMEOUT_MS: u32
const MAX_TIMEOUT_MS: u32
The max timeout in milliseconds.
const FORCE_RECEIVE_STATE: bool
const FORCE_RECEIVE_STATE: bool
Force the ingress manager into receive state immediately after sending the command.
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