mirror of
https://github.com/hubaldv/bioz-icd-rs.git
synced 2026-07-24 00:57:44 +00:00
Updated start/stop/log using postcard-rpc.
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bioz-icd-rs"
|
name = "EQ-DA-icd"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
postcard-rpc = { version = "0.11.12" }
|
postcard-rpc = { version = "0.11.12" }
|
||||||
|
defmt = "1.0.1"
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
version = "1.0.219"
|
version = "1.0.219"
|
||||||
|
|||||||
43
src/lib.rs
43
src/lib.rs
@@ -4,6 +4,8 @@ use postcard_rpc::{endpoints, topics, TopicDirection};
|
|||||||
use postcard_schema::Schema;
|
use postcard_schema::Schema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use defmt::Format;
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
endpoints! {
|
endpoints! {
|
||||||
@@ -13,9 +15,10 @@ endpoints! {
|
|||||||
| ---------- | --------- | ---------- | ---- |
|
| ---------- | --------- | ---------- | ---- |
|
||||||
| PingEndpoint | u32 | u32 | "ping" |
|
| PingEndpoint | u32 | u32 | "ping" |
|
||||||
| GetUniqueIdEndpoint | () | [u8; 12] | "get_id" |
|
| GetUniqueIdEndpoint | () | [u8; 12] | "get_id" |
|
||||||
| SetGreenLedEndpoint | f32 | () | "led/green" |
|
| StartDataEndpoint | () | () | "data/start" |
|
||||||
| StartImpedanceEndpoint | StartImpedance | () | "imp/start" |
|
| StopDataEndpoint | () | bool | "data/stop" |
|
||||||
| StopImpedanceEndpoint | () | bool | "imp/stop" |
|
| SetAlgorithmEndpoint | SetAlgorithm | () | "algorithm/start" |
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
topics! {
|
topics! {
|
||||||
@@ -30,17 +33,35 @@ topics! {
|
|||||||
direction = TopicDirection::ToClient;
|
direction = TopicDirection::ToClient;
|
||||||
| TopicTy | MessageTy | Path | Cfg |
|
| TopicTy | MessageTy | Path | Cfg |
|
||||||
| ------- | --------- | ---- | --- |
|
| ------- | --------- | ---- | --- |
|
||||||
| ImpedanceTopic | Impedance | "imp/data" | |
|
| AllDataTopic | AllData | "data/all" | |
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
|
||||||
pub struct Impedance {
|
pub struct AllData {
|
||||||
pub magnitude: f32,
|
pub pressure: f32,
|
||||||
pub phase: 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)]
|
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq, Clone, Format)]
|
||||||
pub struct StartImpedance {
|
pub enum Algorithm {
|
||||||
pub update_frequency: u32,
|
None,
|
||||||
pub sinus_frequency: f32,
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user