diff --git a/src/lib.rs b/src/lib.rs index 736d9fb..65afe95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,14 @@ mod ccid; #[cfg(feature = "ctaphid")] mod ctaphid; -use std::{cell::RefCell, marker::PhantomData, rc::Rc, thread, time::Duration}; +use std::{ + cell::RefCell, + marker::PhantomData, + rc::Rc, + sync::atomic::{AtomicBool, Ordering}, + thread, + time::Duration, +}; use trussed::{ backend::{BackendId, CoreOnly, Dispatch}, @@ -17,6 +24,12 @@ use usb_device::{ }; use usbip_device::UsbIpBus; +static IS_WAITING: AtomicBool = AtomicBool::new(false); + +pub fn set_waiting(waiting: bool) { + IS_WAITING.store(waiting, Ordering::Relaxed) +} + pub type Client = ClientImplementation, D>; pub type InitPlatform = Box)>; @@ -106,6 +119,10 @@ impl<'interrupt, S: StoreProvider, D: Dispatch, A: Apps<'interrupt, Client #[cfg(feature = "ccid")] &mut ccid, ]); + #[cfg(feature = "ctaphid")] + ctaphid.send_keepalive(IS_WAITING.load(Ordering::Relaxed)); + #[cfg(feature = "ccid")] + ccid.send_wait_extension(); }); loop { thread::sleep(Duration::from_millis(5));