Updated start/stop/log using postcard-rpc.

This commit is contained in:
2025-08-22 11:20:24 +02:00
parent e6294977a0
commit 680f1ad530
2 changed files with 34 additions and 12 deletions

View File

@@ -1,10 +1,11 @@
[package]
name = "bioz-icd-rs"
name = "EQ-DA-icd"
version = "0.1.0"
edition = "2024"
[dependencies]
postcard-rpc = { version = "0.11.12" }
defmt = "1.0.1"
[dependencies.serde]
version = "1.0.219"

View File

@@ -4,6 +4,8 @@ use postcard_rpc::{endpoints, topics, TopicDirection};
use postcard_schema::Schema;
use serde::{Deserialize, Serialize};
use defmt::Format;
// ---
endpoints! {
@@ -13,9 +15,10 @@ endpoints! {
| ---------- | --------- | ---------- | ---- |
| PingEndpoint | u32 | u32 | "ping" |
| GetUniqueIdEndpoint | () | [u8; 12] | "get_id" |
| SetGreenLedEndpoint | f32 | () | "led/green" |
| StartImpedanceEndpoint | StartImpedance | () | "imp/start" |
| StopImpedanceEndpoint | () | bool | "imp/stop" |
| StartDataEndpoint | () | () | "data/start" |
| StopDataEndpoint | () | bool | "data/stop" |
| SetAlgorithmEndpoint | SetAlgorithm | () | "algorithm/start" |
}
topics! {
@@ -30,17 +33,35 @@ topics! {
direction = TopicDirection::ToClient;
| TopicTy | MessageTy | Path | Cfg |
| ------- | --------- | ---- | --- |
| ImpedanceTopic | Impedance | "imp/data" | |
| AllDataTopic | AllData | "data/all" | |
}
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
pub struct Impedance {
pub magnitude: f32,
pub phase: f32,
pub struct AllData {
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)]
pub struct StartImpedance {
pub update_frequency: u32,
pub sinus_frequency: f32,
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq, Clone, Format)]
pub enum Algorithm {
None,
Embed_RP,
Embed_Cascade_PID,
Embed_Cascade_S,
}
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq, Format)]
pub struct SetAlgorithm {
pub run: bool,
pub algorithm: Algorithm,
pub setpoint: f32,
}