wpan: add BLE HCI
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
use core::{ptr, slice};
|
||||
|
||||
use super::PacketHeader;
|
||||
use crate::consts::TL_EVT_HEADER_SIZE;
|
||||
|
||||
/**
|
||||
* The payload of `Evt` for a command status event
|
||||
@ -105,6 +106,14 @@ impl EvtBox {
|
||||
Self { ptr }
|
||||
}
|
||||
|
||||
pub fn evt<'a>(&self) -> &'a [u8] {
|
||||
unsafe {
|
||||
let evt_packet = &(*self.ptr);
|
||||
|
||||
core::slice::from_raw_parts(evt_packet as *const _ as *const u8, core::mem::size_of::<EvtPacket>())
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns information about the event
|
||||
pub fn stub(&self) -> EvtStub {
|
||||
unsafe {
|
||||
@ -124,6 +133,20 @@ impl EvtBox {
|
||||
slice::from_raw_parts(p_payload, payload_len as usize)
|
||||
}
|
||||
}
|
||||
|
||||
/// writes an underlying [`EvtPacket`] into the provided buffer.
|
||||
/// Returns the number of bytes that were written.
|
||||
/// Returns an error if event kind is unknown or if provided buffer size is not enough.
|
||||
pub fn serial<'a>(&self) -> &'a [u8] {
|
||||
unsafe {
|
||||
let evt_serial: *const EvtSerial = &(*self.ptr).evt_serial;
|
||||
let evt_serial_buf: *const u8 = evt_serial.cast();
|
||||
|
||||
let len = (*evt_serial).evt.payload_len as usize + TL_EVT_HEADER_SIZE;
|
||||
|
||||
slice::from_raw_parts(evt_serial_buf, len)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for EvtBox {
|
||||
|
Reference in New Issue
Block a user