Files
bioz-icd-rs/src/lib.rs
2025-08-06 12:48:15 +02:00

56 lines
1.9 KiB
Rust

#![cfg_attr(not(feature = "use-std"), no_std)]
use postcard_rpc::{endpoints, topics, TopicDirection};
use postcard_schema::Schema;
use serde::{Deserialize, Serialize};
// ---
endpoints! {
list = ENDPOINT_LIST;
omit_std = true;
| EndpointTy | RequestTy | ResponseTy | Path |
| ---------- | --------- | ---------- | ---- |
| PingEndpoint | u32 | u32 | "ping" |
| GetUniqueIdEndpoint | () | [u8; 12] | "get_id" |
| SetGreenLedEndpoint | f32 | () | "led/green" |
| StartAccelerationEndpoint | StartAccel | () | "accel/start" |
| StopAccelerationEndpoint | () | bool | "accel/stop" |
}
topics! {
list = TOPICS_IN_LIST;
direction = TopicDirection::ToServer;
| TopicTy | MessageTy | Path |
| ------- | --------- | ---- |
}
topics! {
list = TOPICS_OUT_LIST;
direction = TopicDirection::ToClient;
| TopicTy | MessageTy | Path | Cfg |
| ------- | --------- | ---- | --- |
| AccelTopic | Acceleration | "accel/data" | |
}
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
pub struct Acceleration {
pub x: i16,
pub y: i16,
pub z: i16,
}
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
pub enum AccelRange {
G2,
G4,
G8,
G16,
}
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
pub struct StartAccel {
pub interval_ms: u32,
pub range: AccelRange,
}