Included unique ID.

This commit is contained in:
2025-08-06 11:21:31 +02:00
parent 142576b033
commit 47f99db183

View File

@@ -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<ThreadModeRawMutex, AppDriver, 256, 256, 64, 256>;
@@ -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
}