Included LED RPC.

This commit is contained in:
2025-08-06 12:47:45 +02:00
parent 47f99db183
commit fc27bdc089
2 changed files with 47 additions and 8 deletions

View File

@@ -17,7 +17,7 @@ use postcard_rpc::{
},
};
use bioz_icd_rs::{PingEndpoint, GetUniqueIdEndpoint, ENDPOINT_LIST, TOPICS_IN_LIST, TOPICS_OUT_LIST};
use bioz_icd_rs::{PingEndpoint, GetUniqueIdEndpoint, SetGreenLedEndpoint, ENDPOINT_LIST, TOPICS_IN_LIST, TOPICS_OUT_LIST};
pub struct Context {
pub unique_id: [u8; 12],
@@ -48,6 +48,7 @@ define_dispatch! {
| ---------- | ---- | ------- |
| PingEndpoint | blocking | ping_handler |
| GetUniqueIdEndpoint | blocking | get_unique_id_handler |
| SetGreenLedEndpoint | async | set_green_led_handler |
};
topics_in: {
list: TOPICS_IN_LIST;
@@ -124,4 +125,15 @@ fn ping_handler(_context: &mut Context, _header: VarHeader, rqst: u32) -> u32 {
fn get_unique_id_handler(context: &mut Context, _header: VarHeader, _rqst: ()) -> [u8; 12] {
info!("get_unique_id");
context.unique_id
}
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::signal::Signal;
pub static LED_FREQUENCY_SIGNAL: Signal<CriticalSectionRawMutex, f32> = Signal::new();
async fn set_green_led_handler(_context: &mut Context, _header: VarHeader, rqst: f32) {
info!("Set green led frequency to {:?} Hz", rqst);
LED_FREQUENCY_SIGNAL.signal(rqst);
}