Skip to main content

veloxity_core/comm/
interface.rs

1use crate::board;
2use crate::comm::messages::{Messages, messages::*};
3
4pub trait CommInterface<B: board::BoardIo> {
5    fn send_heartbeat(&mut self, board: &mut B, system_id: u8, msg: HeartbeatMsg) -> bool;
6    fn send_named_value(&mut self, board: &mut B, system_id: u8, msg: ParamValueMsg);
7    fn send_status(&mut self, board: &mut B, system_id: u8, msg: RosflightStatusMsg);
8    fn send_timesync(&mut self, board: &mut B, system_id: u8, msg: TimesyncMsg) -> bool;
9    fn send_version(&mut self, board: &mut B, system_id: u8, msg: RosflightVersionMsg);
10    fn send_output_raw(&mut self, baord: &mut B, system_id: u8, msg: RosflightOutputRawMsg);
11    fn send_attitude(&mut self, board: &mut B, system_id: u8, msg: AttitudeQuaternionMsg);
12    fn send_baro(&mut self, board: &mut B, system_id: u8, msg: SmallBaroMsg);
13    fn send_diff_pressure(&mut self, board: &mut B, system_id: u8, msg: DiffPressureMsg);
14    fn send_imu(&mut self, board: &mut B, system_id: u8, msg: SmallImuMsg);
15    fn send_mag(&mut self, board: &mut B, system_id: u8, msg: SmallMagMsg);
16    fn send_rc_raw(&mut self, board: &mut B, system_id: u8, msg: RcChannelsMsg);
17    fn send_range(&mut self, board: &mut B, system_id: u8, msg: SmallRangeMsg);
18    fn send_gnss(&mut self, board: &mut B, system_id: u8, msg: RosflightGnssMsg);
19    fn send_cmd_ack(&mut self, board: &mut B, system_id: u8, msg: RosflightCmdAckMsg);
20    fn send_rc_channels(&mut self, board: &mut B, system_id: u8, msg: RcChannelsMsg);
21    fn send_battery_status(&mut self, board: &mut B, system_id: u8, msg: BatteryStatusMsg);
22    fn send_statustext(&mut self, board: &mut B, system_id: u8, msg: StatustextMsg);
23    fn send_hard_error(&mut self, board: &mut B, system_id: u8, msg: RosflightHardErrorMsg);
24
25    fn handle_incoming_messages(&mut self, board: &mut B, msgs: &mut Messages);
26}
27
28#[allow(async_fn_in_trait)]
29pub trait EmbeddedComInterface {
30    async fn process_bytes(&mut self, buf: &[u8], num_bytes: usize);
31}