0
0
Fork 0

build: Add "io" module for BLE/ UART messages

This commit is contained in:
Jannik Beyerstedt 2026-07-22 15:30:47 +02:00
commit 21db09ad7f
6 changed files with 193 additions and 4 deletions

51
src/io.rs Normal file
View file

@ -0,0 +1,51 @@
//! UART/ BLE I/O Protocol
pub mod msg {
#![allow(clippy::all, clippy::pedantic, clippy::nursery, dead_code)]
include!(concat!(env!("OUT_DIR"), "/c_its_io.rs"));
}
impl From<msg::RawMsgRx> for msg::SerialOutputMsg {
fn from(value: msg::RawMsgRx) -> Self {
use msg::serial_output_msg::Payload;
Self {
payload: Some(Payload::RxMsg(value)),
}
}
}
impl From<msg::DenmEvent> for msg::SerialOutputMsg {
fn from(value: msg::DenmEvent) -> Self {
use msg::serial_output_msg::Payload;
Self {
payload: Some(Payload::Denm(value)),
}
}
}
impl From<msg::PositionState> for crate::applogic::PositionState {
fn from(value: msg::PositionState) -> Self {
let position = geo_types::Point::new(
value.position.longitude_deg.into(),
value.position.latitude_deg.into(),
);
let heading_deg = value.heading.map(|v| {
#[allow(clippy::cast_precision_loss)]
let val = (v as f32) / 10.;
val
});
let speed_mps = value.speed.map(|v| {
#[allow(clippy::cast_precision_loss)]
let val = (v as f32) / 100.;
val
});
Self {
position,
heading_deg,
speed_mps,
}
}
}