#![cfg_attr(not(feature = "use-std"), no_std)] use postcard_rpc::{endpoints, topics, TopicDirection}; use postcard_schema::Schema; use serde::{Deserialize, Serialize}; use defmt::Format; // --- endpoints! { list = ENDPOINT_LIST; omit_std = true; | EndpointTy | RequestTy | ResponseTy | Path | | ---------- | --------- | ---------- | ---- | | PingEndpoint | u32 | u32 | "ping" | | GetUniqueIdEndpoint | () | [u8; 12] | "get_id" | | StartDataEndpoint | () | () | "data/start" | | StopDataEndpoint | () | bool | "data/stop" | | SetAlgorithmEndpoint | SetAlgorithm | () | "algorithm/start" | | SetSetpointEndpoint | f32 | () | "setpoint/set" | | PressureEndpoint | () | f32 | "data/pressure" | | ExternalSensorEndpoint | () | f32 | "data/external_sensor" | | OutFlowEndpoint | () | f32 | "data/out_flow" | | SetpointPressureEndpoint | () | (f32, f32) | "data/setpoint_pressure" | | SetValvesEndpoint | SetValves | () | "valve/set" | } topics! { list = TOPICS_IN_LIST; direction = TopicDirection::ToServer; | TopicTy | MessageTy | Path | | ------- | --------- | ---- | } topics! { list = TOPICS_OUT_LIST; direction = TopicDirection::ToClient; | TopicTy | MessageTy | Path | Cfg | | ------- | --------- | ---- | --- | | AllDataTopic | AllData | "data/all" | | } #[derive(Serialize, Deserialize, Schema, Debug, PartialEq)] pub struct AllData { pub timestamp_us: u64, pub pressure: f32, pub pressure_filtered: f32, pub setpoint_rp: f32, pub setpoint_cascade: f32, pub temperature: f32, pub valve_a: u16, pub valve_b: u16, pub external_sensor: f32, } #[derive(Serialize, Deserialize, Schema, Debug, PartialEq, Clone, Format)] pub enum Algorithm { None, Embed_RP, Embed_Cascade_PID, Embed_Cascade_S, UDP } #[derive(Serialize, Deserialize, Schema, Debug, PartialEq, Format)] pub struct SetAlgorithm { pub run: bool, pub algorithm: Algorithm, pub setpoint: f32, } #[derive(Serialize, Deserialize, Schema, Debug, PartialEq, Format)] pub struct SetValves { pub valve_a: u16, pub valve_b: u16, }