2022-07-11 03:07:39 +02:00
|
|
|
macro_rules! impl_bytes {
|
|
|
|
($t:ident) => {
|
|
|
|
impl $t {
|
|
|
|
pub const SIZE: usize = core::mem::size_of::<Self>();
|
|
|
|
|
|
|
|
pub fn to_bytes(&self) -> [u8; Self::SIZE] {
|
|
|
|
unsafe { core::mem::transmute(*self) }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_bytes(bytes: &[u8; Self::SIZE]) -> Self {
|
|
|
|
unsafe { core::mem::transmute(*bytes) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-07-11 00:25:35 +02:00
|
|
|
#[derive(Clone, Copy)]
|
2022-07-11 05:19:31 +02:00
|
|
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
2022-07-11 00:25:35 +02:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct SdpcmHeader {
|
|
|
|
pub len: u16,
|
|
|
|
pub len_inv: u16,
|
|
|
|
/// Rx/Tx sequence number
|
|
|
|
pub sequence: u8,
|
|
|
|
/// 4 MSB Channel number, 4 LSB arbitrary flag
|
|
|
|
pub channel_and_flags: u8,
|
|
|
|
/// Length of next data frame, reserved for Tx
|
|
|
|
pub next_length: u8,
|
|
|
|
/// Data offset
|
|
|
|
pub header_length: u8,
|
|
|
|
/// Flow control bits, reserved for Tx
|
|
|
|
pub wireless_flow_control: u8,
|
|
|
|
/// Maximum Sequence number allowed by firmware for Tx
|
|
|
|
pub bus_data_credit: u8,
|
|
|
|
/// Reserved
|
|
|
|
pub reserved: [u8; 2],
|
|
|
|
}
|
2022-07-11 03:07:39 +02:00
|
|
|
impl_bytes!(SdpcmHeader);
|
2022-07-11 00:25:35 +02:00
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
2022-07-11 05:19:31 +02:00
|
|
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
2022-07-11 00:25:35 +02:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct CdcHeader {
|
|
|
|
pub cmd: u32,
|
|
|
|
pub out_len: u16,
|
|
|
|
pub in_len: u16,
|
|
|
|
pub flags: u16,
|
|
|
|
pub id: u16,
|
|
|
|
pub status: u32,
|
|
|
|
}
|
2022-07-11 03:07:39 +02:00
|
|
|
impl_bytes!(CdcHeader);
|
2022-07-11 00:25:35 +02:00
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
2022-07-11 05:19:31 +02:00
|
|
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
2022-07-11 00:25:35 +02:00
|
|
|
#[repr(C)]
|
2022-07-11 05:19:31 +02:00
|
|
|
pub struct BcdHeader {
|
2022-07-11 00:25:35 +02:00
|
|
|
pub flags: u8,
|
|
|
|
/// 802.1d Priority (low 3 bits)
|
|
|
|
pub priority: u8,
|
|
|
|
pub flags2: u8,
|
|
|
|
/// Offset from end of BDC header to packet data, in 4-uint8_t words. Leaves room for optional headers.
|
|
|
|
pub data_offset: u8,
|
|
|
|
}
|
2022-07-11 05:19:31 +02:00
|
|
|
impl_bytes!(BcdHeader);
|
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct EventHeader {
|
|
|
|
/// version
|
|
|
|
pub version: u16,
|
|
|
|
/// see flags below
|
|
|
|
pub flags: u16,
|
|
|
|
/// Message (see below)
|
|
|
|
pub event_type: u32,
|
|
|
|
/// Status code (see below)
|
|
|
|
pub status: u32,
|
|
|
|
/// Reason code (if applicable)
|
|
|
|
pub reason: u32,
|
|
|
|
/// WLC_E_AUTH
|
|
|
|
pub auth_type: u32,
|
|
|
|
/// data buf
|
|
|
|
pub datalen: u32,
|
|
|
|
/// Station address (if applicable)
|
|
|
|
pub addr: [u8; 6],
|
|
|
|
/// name of the incoming packet interface
|
|
|
|
pub ifname: [u8; 16],
|
|
|
|
/// destination OS i/f index
|
|
|
|
pub ifidx: u8,
|
|
|
|
/// source bsscfg index
|
|
|
|
pub bsscfgidx: u8,
|
|
|
|
}
|
|
|
|
impl_bytes!(EventHeader);
|
2022-07-11 00:25:35 +02:00
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct DownloadHeader {
|
2022-07-11 03:07:39 +02:00
|
|
|
pub flag: u16, //
|
2022-07-11 00:25:35 +02:00
|
|
|
pub dload_type: u16,
|
|
|
|
pub len: u32,
|
|
|
|
pub crc: u32,
|
|
|
|
}
|
2022-07-11 03:07:39 +02:00
|
|
|
impl_bytes!(DownloadHeader);
|
2022-07-11 00:25:35 +02:00
|
|
|
|
2022-07-11 03:07:39 +02:00
|
|
|
pub const DOWNLOAD_FLAG_NO_CRC: u16 = 0x0001;
|
|
|
|
pub const DOWNLOAD_FLAG_BEGIN: u16 = 0x0002;
|
|
|
|
pub const DOWNLOAD_FLAG_END: u16 = 0x0004;
|
|
|
|
pub const DOWNLOAD_FLAG_HANDLER_VER: u16 = 0x1000;
|
2022-07-11 00:25:35 +02:00
|
|
|
|
2022-07-11 03:07:39 +02:00
|
|
|
pub const DOWNLOAD_TYPE_CLM: u16 = 2;
|
2022-07-11 00:25:35 +02:00
|
|
|
|
2022-07-11 03:07:39 +02:00
|
|
|
#[derive(Clone, Copy)]
|
2022-07-11 05:19:31 +02:00
|
|
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
2022-07-11 03:07:39 +02:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct CountryInfo {
|
|
|
|
pub country_abbrev: [u8; 4],
|
|
|
|
pub rev: i32,
|
|
|
|
pub country_code: [u8; 4],
|
2022-07-11 00:25:35 +02:00
|
|
|
}
|
2022-07-11 03:07:39 +02:00
|
|
|
impl_bytes!(CountryInfo);
|
2022-07-11 05:19:31 +02:00
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct SsidInfo {
|
|
|
|
pub len: u32,
|
|
|
|
pub ssid: [u8; 32],
|
|
|
|
}
|
|
|
|
impl_bytes!(SsidInfo);
|
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct EventMask {
|
|
|
|
pub iface: u32,
|
|
|
|
pub events: [u8; 24],
|
|
|
|
}
|
|
|
|
impl_bytes!(EventMask);
|