Trait open_protocol::ack::AckHandler
[−]
[src]
pub trait AckHandler { fn handle_version(&mut self, data: &[u8]) -> Result<AckData> { ... } fn waypoint_upload(&self, data: &[u8]) -> Result<AckData> { ... } fn waypoint_get_idle_speed(&self, data: &[u8]) -> Result<AckData> { ... } fn handle_flight_data(&mut self, _: &[u8]) -> Result<AckData> { ... } fn handle_mission(&mut self, _: &[u8]) -> Result<AckData> { ... } fn handle_waypoint_event(&mut self, _: &[u8]) -> Result<AckData> { ... } fn handle_switch_result(&mut self, _: &[u8]) -> Result<AckData> { ... } fn handle_waypoint_start(&mut self, _: &[u8]) -> Result<AckData> { ... } fn handle_lost_control(&mut self, data: &[u8]) -> Result<AckData> { ... } fn default<T: AckCode + FromBytes>(
&self,
name: &str,
data: &[u8]
) -> Result<AckData> { ... } fn handle_ack(&mut self, cmd: &CmdSet, data: &[u8]) -> Result<AckData> { ... } }
This trait is used to handle ack frames. All functions return an AckData
.
Example
use open_protocol::ack::{AckHandler, AckData}; use open_protocol::command::{CmdSet, PushData}; use open_protocol::types::{self, FromBytes}; use open_protocol::Result; struct Handler; impl AckHandler for Handler { fn handle_flight_data(&mut self, data: &[u8]) -> Result<AckData> { let mut fd = types::FlightData::default(); types::FlightData::fetch_data(data, &mut fd).unwrap(); let pos = fd.position.pos; println!("Current position of the drone: {}, {}, {}", pos.latitude, pos.longitude, pos.altitude); Ok(Default::default()) } } let data = vec![62, 59, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 128, 4, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 106, 0, 0, 128, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 205, 170, 175, 241, 75, 225, 63, 66, 226, 94, 187, 158, 229, 0, 64, 205, 204, 204, 61, 0, 0, 0, 0, 5, 205, 204, 204, 61, 0, 0, 240, 65, 0, 0, 200, 66, 0, 0, 200, 66, 0, 0, 200, 66, 0, 0, 0, 0, 31, 220, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 1, 0, 0, 0, 0, 0, 24, 178, 0, 0, 0, 0, 0, 0, 0, 0, 0]; let _ = Handler.handle_ack(&CmdSet::PushData(PushData::FlightData), &data);
Provided Methods
fn handle_version(&mut self, data: &[u8]) -> Result<AckData>
fn waypoint_upload(&self, data: &[u8]) -> Result<AckData>
fn waypoint_get_idle_speed(&self, data: &[u8]) -> Result<AckData>
fn handle_flight_data(&mut self, _: &[u8]) -> Result<AckData>
fn handle_mission(&mut self, _: &[u8]) -> Result<AckData>
fn handle_waypoint_event(&mut self, _: &[u8]) -> Result<AckData>
fn handle_switch_result(&mut self, _: &[u8]) -> Result<AckData>
fn handle_waypoint_start(&mut self, _: &[u8]) -> Result<AckData>
fn handle_lost_control(&mut self, data: &[u8]) -> Result<AckData>
fn default<T: AckCode + FromBytes>(
&self,
name: &str,
data: &[u8]
) -> Result<AckData>
&self,
name: &str,
data: &[u8]
) -> Result<AckData>
fn handle_ack(&mut self, cmd: &CmdSet, data: &[u8]) -> Result<AckData>
The entry point for handling all kinds of ack frames.