pub struct Connection { /* private fields */ }Expand description
Connection to a Crazyflie
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn new(internal_connection: Box<dyn ConnectionTrait + Send + Sync>) -> Self
pub fn new(internal_connection: Box<dyn ConnectionTrait + Send + Sync>) -> Self
Create a new connection object
Sourcepub async fn wait_close(&self) -> String
pub async fn wait_close(&self) -> String
Wait for the connection to be closed. Returns the message stored in the disconnected connection status that indicate the reason for the disconnection
Sourcepub async fn close(&self)
pub async fn close(&self)
Close the connection and wait for the connection task to stop.
The connection can also be closed by simply dropping the connection object. Though, if the connection task is currently processing a packet, it will continue running until the current packet has been processed. This function will wait for any ongoing packet to be processed and for the communication task to stop.
Sourcepub async fn status(&self) -> ConnectionStatus
pub async fn status(&self) -> ConnectionStatus
Return the connection status
Sourcepub async fn wait_disconnect(&self)
pub async fn wait_disconnect(&self)
Block until the connection is dropped. The status() function can be used to get the reason
for the disconnection.
Sourcepub async fn send_packet(&self, packet: Packet) -> Result<(), Error>
pub async fn send_packet(&self, packet: Packet) -> Result<(), Error>
Send a packet to the connected Crazyflie
This function can return an error if the connection task is not active anymore. This can happen if the Crazyflie is disconnected due to a timeout
Sourcepub async fn recv_packet(&self) -> Result<Packet, Error>
pub async fn recv_packet(&self) -> Result<Packet, Error>
Receive a packet from the connected Crazyflie
This function can return an error if the connection task is not active anymore. This can happen if the Crazyflie is disconnected due to a timeout