diff --git a/src/communication.rs b/src/communication.rs index f81cd87..ce0b8a3 100644 --- a/src/communication.rs +++ b/src/communication.rs @@ -3,7 +3,7 @@ use defmt::{info, error}; use embassy_executor::Spawner; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; use embassy_stm32::usb::Driver; -use embassy_stm32::{peripherals, usb}; +use embassy_stm32::{peripherals, uid, usb}; use postcard_rpc::{ define_dispatch, @@ -19,7 +19,9 @@ use postcard_rpc::{ use bioz_icd_rs::{PingEndpoint, GetUniqueIdEndpoint, ENDPOINT_LIST, TOPICS_IN_LIST, TOPICS_OUT_LIST}; -pub struct Context; +pub struct Context { + pub unique_id: [u8; 12], +} type AppDriver = usb::Driver<'static, peripherals::USB>; type AppStorage = WireStorage; @@ -96,7 +98,10 @@ pub fn init_communication(usb_driver: Driver<'static, peripherals::USB>, spawner let pbufs = PBUFS.take(); let config = usb_config(); - let context = Context; + let context = Context { + unique_id: *uid::uid(), + }; + let (device, tx_impl, rx_impl) = STORAGE.init(usb_driver, config, pbufs.tx_buf.as_mut_slice()); let dispatcher = MyApp::new(context, spawner.into()); let vkk = dispatcher.min_key_len(); @@ -116,7 +121,7 @@ fn ping_handler(_context: &mut Context, _header: VarHeader, rqst: u32) -> u32 { rqst } -fn get_unique_id_handler(_context: &mut Context, _header: VarHeader, _rqst: ()) -> u64 { +fn get_unique_id_handler(context: &mut Context, _header: VarHeader, _rqst: ()) -> [u8; 12] { info!("get_unique_id"); - 200 + context.unique_id } \ No newline at end of file