Trait rubble::link::Transmitter[][src]

pub trait Transmitter {
    fn tx_payload_buf(&mut self) -> &mut [u8];
fn transmit_advertising(
        &mut self,
        header: Header,
        channel: AdvertisingChannel
    );
fn transmit_data(
        &mut self,
        access_address: u32,
        crc_iv: u32,
        header: Header,
        channel: DataChannel
    ); }
Expand description

Trait for Link Layer packet transmission.

The specifics of sending a Link-Layer packet depend on the underlying hardware. The link module provides building blocks that enable implementations without any BLE hardware support, just a compatible radio is needed.

Required methods

Get a reference to the Transmitter’s PDU payload buffer.

The buffer must hold at least 37 Bytes, as that is the maximum length of advertising channel payloads. While data channel payloads can be up to 251 Bytes in length (resulting in a “length” field of 255 with the MIC), devices are allowed to use smaller buffers and report the supported payload length.

Both advertising and data channel packets also use an additional 2-Byte header preceding this payload.

This buffer must not be changed. The BLE stack relies on the buffer to retain its old contents after transmitting a packet. A separate buffer must be used for received packets.

Transmit an Advertising Channel PDU.

For Advertising Channel PDUs, the CRC initialization value is always CRC_PRESET, and the Access Address is always ADVERTISING_ADDRESS.

The implementor is expected to send the preamble and access address, and assemble the rest of the packet, and must apply data whitening and do the CRC calculation. The inter-frame spacing also has to be upheld by the implementor (T_IFS).

Parameters

  • header: Advertising Channel PDU Header to prepend to the Payload in payload_buf().
  • channel: Advertising Channel Index to transmit on.

Transmit a Data Channel PDU.

The implementor is expected to send the preamble and assemble the rest of the packet, and must apply data whitening and do the CRC calculation.

Parameters

  • access_address: The Access Address of the Link-Layer packet.
  • crc_iv: CRC calculation initial value (CRC_PRESET for advertising channel).
  • header: Data Channel PDU Header to be prepended to the Payload in payload_buf().
  • channel: Data Channel Index to transmit on.

Implementors