use crate::{time::Duration, RxConfig};
#[derive(Debug)]
pub struct Uninitialized;
#[derive(Debug)]
pub struct Ready;
#[derive(Debug)]
pub struct Sending {
pub(super) finished: bool,
}
#[derive(Debug)]
pub struct SingleBufferReceiving {
pub(super) finished: bool,
pub(super) config: RxConfig,
}
#[derive(Debug)]
pub struct AutoDoubleBufferReceiving {
pub(super) finished: bool,
pub(super) config: RxConfig,
}
#[derive(Debug)]
pub struct Sleeping {
pub(super) tx_antenna_delay: Duration,
}
pub trait Awake {}
impl Awake for Uninitialized {}
impl Awake for Ready {}
impl Awake for Sending {}
impl Awake for SingleBufferReceiving {}
impl Awake for AutoDoubleBufferReceiving {}
pub trait Asleep {}
impl Asleep for Sleeping {}
pub trait Receiving: Awake {
const AUTO_RX_REENABLE: bool;
const DOUBLE_BUFFERED: bool;
fn mark_finished(&mut self);
fn is_finished(&self) -> bool;
fn get_rx_config(&self) -> &RxConfig;
}
impl Receiving for SingleBufferReceiving {
const AUTO_RX_REENABLE: bool = false;
const DOUBLE_BUFFERED: bool = false;
fn mark_finished(&mut self) {
self.finished = true;
}
fn is_finished(&self) -> bool {
self.finished
}
fn get_rx_config(&self) -> &RxConfig {
&self.config
}
}
impl Receiving for AutoDoubleBufferReceiving {
const AUTO_RX_REENABLE: bool = true;
const DOUBLE_BUFFERED: bool = true;
fn mark_finished(&mut self) {
self.finished = true;
}
fn is_finished(&self) -> bool {
self.finished
}
fn get_rx_config(&self) -> &RxConfig {
&self.config
}
}