net-esp-hosted: update payload header defines

This commit is contained in:
Andelf 2023-12-09 05:07:27 +08:00
parent a4d53c7cb1
commit 4386ff51a1

View File

@ -86,12 +86,25 @@ impl_bytes!(PayloadHeader);
#[allow(unused)] #[allow(unused)]
#[repr(u8)] #[repr(u8)]
enum InterfaceType { enum InterfaceType {
Sta = 0, Invalid = 0,
Ap = 1, Sta = 1,
Serial = 2, Ap = 2,
Hci = 3, Serial = 3,
Priv = 4, Hci = 4,
Test = 5, Priv = 5,
Test = 6,
Dummy = 7,
}
impl InterfaceType {
/// Convert from u8
///
/// # Safety
///
/// The value must be in the range 0..=7
fn from_u8(v: u8) -> Self {
unsafe { core::mem::transmute(v & 0x07) }
}
} }
const MAX_SPI_BUFFER_SIZE: usize = 1600; const MAX_SPI_BUFFER_SIZE: usize = 1600;
@ -274,17 +287,15 @@ where
let payload = &mut buf[PayloadHeader::SIZE..][..payload_len]; let payload = &mut buf[PayloadHeader::SIZE..][..payload_len];
match if_type_and_num & 0x0f { match InterfaceType::from_u8(if_type_and_num) {
// STA InterfaceType::Sta => match self.ch.try_rx_buf() {
0 => match self.ch.try_rx_buf() {
Some(buf) => { Some(buf) => {
buf[..payload.len()].copy_from_slice(payload); buf[..payload.len()].copy_from_slice(payload);
self.ch.rx_done(payload.len()) self.ch.rx_done(payload.len())
} }
None => warn!("failed to push rxd packet to the channel."), None => warn!("failed to push rxd packet to the channel."),
}, },
// serial InterfaceType::Serial => {
2 => {
trace!("serial rx: {:02x}", payload); trace!("serial rx: {:02x}", payload);
if payload.len() < 14 { if payload.len() < 14 {
warn!("serial rx: too short"); warn!("serial rx: too short");
@ -313,6 +324,9 @@ where
self.shared.ioctl_done(data); self.shared.ioctl_done(data);
} }
} }
InterfaceType::Priv => {
trace!("received INIT event");
}
_ => warn!("unknown iftype {}", if_type_and_num), _ => warn!("unknown iftype {}", if_type_and_num),
} }
} }