mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
update FidoMsg api and fix opcode bug
This commit is contained in:
parent
6f1bbb49d1
commit
52e6071265
2 changed files with 12 additions and 10 deletions
|
|
@ -10,7 +10,6 @@ pub use usbd_human_interface_device::page::Keyboard as UsbKeyCode;
|
|||
use packed_struct::PackedStruct;
|
||||
use xous_ipc::Buffer;
|
||||
pub use usbd_human_interface_device::device::fido::FidoMsg;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
|
||||
pub enum UsbDeviceType {
|
||||
Debug = 0,
|
||||
|
|
@ -212,7 +211,7 @@ impl UsbHid {
|
|||
let ack = buf.to_original::<U2fMsgIpc, _>().unwrap();
|
||||
assert_eq!(ack.code, U2fCode::RxAck, "Expected U2fCode::RxAck");
|
||||
let mut u2fmsg = FidoMsg::default();
|
||||
u2fmsg.deref_mut().copy_from_slice(&ack.data);
|
||||
u2fmsg.packet.copy_from_slice(&ack.data);
|
||||
Ok(u2fmsg)
|
||||
}
|
||||
pub fn u2f_send(&self, msg: FidoMsg) -> Result<(), xous::Error> {
|
||||
|
|
@ -220,9 +219,9 @@ impl UsbHid {
|
|||
data: [0; 64],
|
||||
code: U2fCode::Tx
|
||||
};
|
||||
req.data.copy_from_slice(&msg.deref());
|
||||
req.data.copy_from_slice(&msg.packet);
|
||||
let mut buf = Buffer::into_buf(req).or(Err(xous::Error::InternalError))?;
|
||||
buf.lend_mut(self.conn, Opcode::U2fRxDeferred.to_u32().unwrap()).or(Err(xous::Error::InternalError))?;
|
||||
buf.lend_mut(self.conn, Opcode::U2fTx.to_u32().unwrap()).or(Err(xous::Error::InternalError))?;
|
||||
let ack = buf.to_original::<U2fMsgIpc, _>().unwrap();
|
||||
match ack.code {
|
||||
U2fCode::TxAck => Ok(()),
|
||||
|
|
|
|||
|
|
@ -29,9 +29,6 @@ use usbd_human_interface_device::device::fido::FidoMsg;
|
|||
#[cfg(any(target_os = "none", target_os = "xous"))]
|
||||
use usbd_human_interface_device::device::fido::FidoInterface;
|
||||
use xous::{msg_scalar_unpack, msg_blocking_scalar_unpack};
|
||||
use core::ops::DerefMut;
|
||||
#[cfg(any(target_os = "none", target_os = "xous"))]
|
||||
use core::ops::Deref;
|
||||
use core::num::NonZeroU8;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
|
|
@ -74,7 +71,7 @@ impl Clock for EmbeddedClock {
|
|||
|
||||
fn main() -> ! {
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Debug);
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
log::info!("my PID is {}", xous::process::id());
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
|
|
@ -194,6 +191,11 @@ fn main() -> ! {
|
|||
// the receiver will get a response with the `code` field still in the `RxWait` state to indicate the problem
|
||||
}
|
||||
if fido_listener_pid == msg.sender.pid() {
|
||||
{
|
||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let u2f_ipc = buffer.to_original::<U2fMsgIpc, _>().unwrap();
|
||||
log::info!("registering listener: {:?}", u2f_ipc);
|
||||
}
|
||||
fido_listener = Some(msg);
|
||||
} else {
|
||||
log::warn!("U2F interface capability is locked on first use; additional servers are ignored: {:?}", msg.sender);
|
||||
|
|
@ -212,7 +214,8 @@ fn main() -> ! {
|
|||
if fido_listener_pid == msg.sender.pid() {
|
||||
let mut u2f_msg = FidoMsg::default();
|
||||
assert_eq!(u2f_ipc.code, U2fCode::Tx, "Expected U2fCode::Tx in wrapper");
|
||||
u2f_msg.deref_mut().copy_from_slice(&u2f_ipc.data);
|
||||
u2f_msg.packet.copy_from_slice(&u2f_ipc.data);
|
||||
log::info!("send U2F packet {:?}", u2f_ipc.data);
|
||||
#[cfg(any(target_os = "none", target_os = "xous"))]
|
||||
let u2f = composite.interface::<FidoInterface<'_, _>, _>();
|
||||
#[cfg(any(target_os = "none", target_os = "xous"))]
|
||||
|
|
@ -243,7 +246,7 @@ fn main() -> ! {
|
|||
};
|
||||
let mut buf = response.to_original::<U2fMsgIpc, _>().unwrap();
|
||||
assert_eq!(buf.code, U2fCode::RxWait, "Expected U2fcode::RxWait in wrapper");
|
||||
buf.data.copy_from_slice(&u2f_report.deref());
|
||||
buf.data.copy_from_slice(&u2f_report.packet);
|
||||
buf.code = U2fCode::RxAck;
|
||||
response.replace(buf).unwrap();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue