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