pub struct Config<'a, const QUEUE_LEN: usize> {
pub sim_card_pin: Option<&'a str>,
pub auto_reset_when_stalled: bool,
pub module_stalled_callback: Option<&'a mut dyn FnMut() -> bool>,
pub module_powered_down_callback: Option<&'a mut dyn FnMut()>,
pub received_sms_callback: Option<&'a mut dyn FnMut(&str, &str)>,
pub received_call_callback: Option<&'a mut dyn FnMut(&str) -> bool>,
pub call_connected_callback: Option<&'a mut dyn FnMut()>,
pub call_disconnected_callback: Option<&'a mut dyn FnMut()>,
pub received_ussd_callback: Option<&'a mut dyn FnMut(&str)>,
}
impl<'a> Default for Config<'a, 10> {
fn default() -> Self {
Self {
sim_card_pin: None,
auto_reset_when_stalled: true,
module_stalled_callback: None,
module_powered_down_callback: None,
received_sms_callback: None,
received_call_callback: None,
call_connected_callback: None,
call_disconnected_callback: None,
received_ussd_callback: None,
}
}
}
impl<'a, const QUEUE_LEN: usize> Config<'a, QUEUE_LEN> {
pub fn new() -> Self {
Self {
sim_card_pin: None,
auto_reset_when_stalled: true,
module_stalled_callback: None,
module_powered_down_callback: None,
received_sms_callback: None,
received_call_callback: None,
call_connected_callback: None,
call_disconnected_callback: None,
received_ussd_callback: None,
}
}
pub fn with_sim_card_pin(mut self, pin: &'a str) -> Self {
self.sim_card_pin = Some(pin);
self
}
pub fn with_auto_reset_when_stalled(mut self, auto_reset: bool) -> Self {
self.auto_reset_when_stalled = auto_reset;
self
}
pub fn with_module_stalled_callback(mut self, callback: &'a mut impl FnMut() -> bool) -> Self {
self.module_stalled_callback = Some(callback);
self
}
pub fn with_module_powered_down_callback(mut self, callback: &'a mut impl FnMut()) -> Self {
self.module_powered_down_callback = Some(callback);
self
}
pub fn with_received_sms_callback(mut self, callback: &'a mut impl FnMut(&str, &str)) -> Self {
self.received_sms_callback = Some(callback);
self
}
pub fn with_received_call_callback(
mut self,
callback: &'a mut impl FnMut(&str) -> bool,
) -> Self {
self.received_call_callback = Some(callback);
self
}
pub fn with_call_connected_callback(mut self, callback: &'a mut impl FnMut()) -> Self {
self.call_connected_callback = Some(callback);
self
}
pub fn with_call_disconnected_callback(mut self, callback: &'a mut impl FnMut()) -> Self {
self.call_disconnected_callback = Some(callback);
self
}
pub fn with_received_ussd_callback(mut self, callback: &'a mut impl FnMut(&str)) -> Self {
self.received_ussd_callback = Some(callback);
self
}
}