mirror of
https://github.com/hubaldv/bioz-firmware-rs.git
synced 2025-12-06 05:01:18 +00:00
Included unique ID.
This commit is contained in:
@@ -3,7 +3,7 @@ use defmt::{info, error};
|
|||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||||
use embassy_stm32::usb::Driver;
|
use embassy_stm32::usb::Driver;
|
||||||
use embassy_stm32::{peripherals, usb};
|
use embassy_stm32::{peripherals, uid, usb};
|
||||||
|
|
||||||
use postcard_rpc::{
|
use postcard_rpc::{
|
||||||
define_dispatch,
|
define_dispatch,
|
||||||
@@ -19,7 +19,9 @@ use postcard_rpc::{
|
|||||||
|
|
||||||
use bioz_icd_rs::{PingEndpoint, GetUniqueIdEndpoint, ENDPOINT_LIST, TOPICS_IN_LIST, TOPICS_OUT_LIST};
|
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 AppDriver = usb::Driver<'static, peripherals::USB>;
|
||||||
type AppStorage = WireStorage<ThreadModeRawMutex, AppDriver, 256, 256, 64, 256>;
|
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 pbufs = PBUFS.take();
|
||||||
let config = usb_config();
|
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 (device, tx_impl, rx_impl) = STORAGE.init(usb_driver, config, pbufs.tx_buf.as_mut_slice());
|
||||||
let dispatcher = MyApp::new(context, spawner.into());
|
let dispatcher = MyApp::new(context, spawner.into());
|
||||||
let vkk = dispatcher.min_key_len();
|
let vkk = dispatcher.min_key_len();
|
||||||
@@ -116,7 +121,7 @@ fn ping_handler(_context: &mut Context, _header: VarHeader, rqst: u32) -> u32 {
|
|||||||
rqst
|
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");
|
info!("get_unique_id");
|
||||||
200
|
context.unique_id
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user