use embassy_time::Duration;
#[derive(Debug, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Config {
pub command_timeout: Duration,
pub max_retries: u8,
pub rx_buffer_size: usize,
pub response_slots: usize,
pub wifi_event_capacity: usize,
pub socket_event_capacity: usize,
pub socket_rx_buffer_size: usize,
pub echo_enabled: bool,
}
impl Default for Config {
fn default() -> Self {
Self {
command_timeout: Duration::from_secs(5),
max_retries: 3,
rx_buffer_size: 4096,
response_slots: 8,
wifi_event_capacity: 4,
socket_event_capacity: 16,
socket_rx_buffer_size: 2048,
echo_enabled: false,
}
}
}
impl Config {
pub const fn new() -> Self {
Self {
command_timeout: Duration::from_secs(5),
max_retries: 3,
rx_buffer_size: 4096,
response_slots: 8,
wifi_event_capacity: 4,
socket_event_capacity: 16,
socket_rx_buffer_size: 2048,
echo_enabled: false,
}
}
pub const fn with_command_timeout(mut self, timeout: Duration) -> Self {
self.command_timeout = timeout;
self
}
pub const fn with_max_retries(mut self, retries: u8) -> Self {
self.max_retries = retries;
self
}
pub const fn with_rx_buffer_size(mut self, size: usize) -> Self {
self.rx_buffer_size = size;
self
}
pub const fn with_response_slots(mut self, slots: usize) -> Self {
self.response_slots = slots;
self
}
pub const fn with_echo(mut self, enabled: bool) -> Self {
self.echo_enabled = enabled;
self
}
pub const fn with_socket_rx_buffer_size(mut self, size: usize) -> Self {
self.socket_rx_buffer_size = size;
self
}
}