Trait stm32wb_hci::host::HciHeader
source · pub trait HciHeader {
const HEADER_LENGTH: usize;
// Required methods
fn new(opcode: Opcode, param_len: usize) -> Self;
fn copy_into_slice(&self, buf: &mut [u8]);
}Expand description
Trait to define a command packet header.
See the Bluetooth Specification Vol 2, Part E, section 5.4.1. The command packet header contains an opcode (comprising a 6-bit OGF and 10-bit OCF) and a 1-byte parameter length. The packet itself then contains various parameters as defined by the Bluetooth specification.
Before this command header, many (all?) Bluetooth implementations include a 1-byte packet type
preceding the command header. This version of the HciHeader is implemented by
uart::CommandHeader, while versions without the packet byte are implemented by
[cmd_link::Header] and [event_link::NoCommands].
Required Associated Constants§
sourceconst HEADER_LENGTH: usize
const HEADER_LENGTH: usize
Defines the length of the packet header. With the packet byte, this is 4. Without it, the length shall be 3.
Required Methods§
sourcefn new(opcode: Opcode, param_len: usize) -> Self
fn new(opcode: Opcode, param_len: usize) -> Self
Returns a new header with the given opcode and parameter length.
sourcefn copy_into_slice(&self, buf: &mut [u8])
fn copy_into_slice(&self, buf: &mut [u8])
Serialize the header into the given buffer, in Bluetooth byte order (little-endian).
Panics
Panics if buf.len() < Self::HEADER_LENGTH