diff --git a/src/ankaios.rs b/src/ankaios.rs index 68cbf4c..cf09f70 100644 --- a/src/ankaios.rs +++ b/src/ankaios.rs @@ -160,6 +160,8 @@ pub struct Ankaios{ response_receiver: mpsc::Receiver, /// The control interface instance that is used to communicate with the Control Interface. control_interface: ControlInterface, + /// Flag used to correct the connection checks, will be removed in the near future + connection_established: bool, /// The timeout used for the requests. pub timeout: Duration, } @@ -198,6 +200,7 @@ impl Ankaios { let mut object = Self{ response_receiver, control_interface: ControlInterface::new(response_sender), + connection_established: false, timeout, }; @@ -688,11 +691,20 @@ impl Ankaios { match response.content { ResponseType::CompleteState(complete_state) => { + self.connection_established = true; + Ok(*complete_state) }, ResponseType::Error(error) => { - log::error!("Error while trying to get the state: {error}"); - Err(AnkaiosError::AnkaiosResponseError(error)) + if self.connection_established { + log::error!("Error while trying to get the state: {error}"); + return Err(AnkaiosError::AnkaiosResponseError(error)); + } + + // flag connection as established, will be removed in the near future + self.connection_established = true; + + Ok(CompleteState::default()) }, _ => { log::error!("Received unexpected response type."); @@ -880,6 +892,7 @@ fn generate_test_ankaios(mock_control_interface: ControlInterface) -> (Ankaios, (Ankaios{ response_receiver, control_interface: mock_control_interface, + connection_established: true, timeout: Duration::from_millis(50), }, response_sender)