[−][src]Struct rubble::link::advertising::Header
16-bit Advertising Channel PDU header preceding the Payload.
The header looks like this:
LSB MSB
+------------+------------+---------+---------+--------------+------------+
| PDU Type | - | TxAdd | RxAdd | Length | - |
| (4 bits) | (2 bits) | (1 bit) | (1 bit) | (6 bits) | (2 bits) |
+------------+------------+---------+---------+--------------+------------+
The TxAdd
and RxAdd
field are only used for some payloads, for all others, they should be
set to 0.
Length may be in range 6 to 37 (inclusive). With the 2-Byte header this is exactly the max. on-air packet size.
Methods
impl Header
[src]
pub fn new(ty: PduType) -> Self
[src]
Creates a new Advertising Channel PDU header specifying the Payload type ty
.
pub fn parse(raw: &[u8]) -> Self
[src]
pub fn to_u16(&self) -> u16
[src]
Returns the raw representation of the header.
The returned u16
must be transmitted LSb first as the first 2 octets of the PDU.
pub fn type_(&self) -> PduType
[src]
Returns the PDU type specified in the header.
pub fn tx_add(&self) -> bool
[src]
Returns the state of the TxAdd
field.
pub fn set_tx_add(&mut self, value: bool)
[src]
Sets the TxAdd
field's value.
pub fn rx_add(&self) -> bool
[src]
Returns the state of the RxAdd
field.
pub fn set_rx_add(&mut self, value: bool)
[src]
Sets the RxAdd
field's value.
pub fn payload_length(&self) -> u8
[src]
Returns the length of the payload in octets as specified in the Length
field.
According to the spec, the length must be in range 6...37, but this isn't checked by this function.
pub fn set_payload_length(&mut self, length: u8)
[src]
Sets the payload length of this PDU.
The length
must be in range 6...37, otherwise this function panics.
Trait Implementations
impl ToBytes for Header
[src]
fn to_bytes(&self, writer: &mut ByteWriter) -> Result<(), Error>
[src]
impl<'a> FromBytes<'a> for Header
[src]
fn from_bytes(bytes: &mut ByteReader<'a>) -> Result<Self, Error>
[src]
impl Copy for Header
[src]
impl Debug for Header
[src]
impl Clone for Header
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> From for T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,