1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
use crate::state::*;
use crate::video::*;
use crate::command::*;
/// Tello drone connection and other usage options.
#[derive(Default)]
pub struct TelloOptions {
pub(crate) state_sender: Option<TelloStateSender>,
pub(crate) video_sender: Option<TelloVideoSender>,
pub(crate) command_receiver: Option<TelloCommandReceiver>
}
impl TelloOptions {
/// Request state updates from the drone.
///
/// *nb* As messages are sent to the UDP broadcast address 0.0.0.0 this
/// only works in AP mode, ie using the drone's own WiFi network
///
/// Returns the receiver end of the channel used to pass on updates
///
pub fn with_state(&mut self) -> TelloStateReceiver {
let (tx, rx) = make_tello_state_channel();
self.state_sender = Some(tx);
rx
}
/// Request video from the drone as a stream of h264-encoded 720p YUV
/// frames.
///
/// *nb* As messages are sent to the UDP broadcast address 0.0.0.0 this
/// only works in AP mode, ie using the drone's own WiFi network
///
/// Returns the receiver end of the channel used to pass on frames
///
pub fn with_video(&mut self) -> TelloVideoReceiver {
let (tx, rx) = make_tello_video_channel();
self.video_sender = Some(tx);
rx
}
/// Returns the sender end of a channel for issuing commands to the
/// drone, eg for a remote control application.
///
pub fn with_command(&mut self) -> TelloCommandSender {
let (tx, rx) = make_tello_command_channel();
self.command_receiver = Some(rx);
tx
}
}