Struct rubble::link::LinkLayer [−][src]
pub struct LinkLayer<C: Config> {
dev_addr: DeviceAddress,
state: State<C>,
timer: C::Timer,
}
Expand description
Implementation of the real-time BLE Link-Layer logic.
Users of this struct must provide an interface to the platform’s hardware by implementing
Config
.
Fields
dev_addr: DeviceAddress
state: State<C>
timer: C::Timer
Implementations
Creates a new Link-Layer.
Parameters
dev_addr
: The device address to broadcast as.timer
: ATimer
implementation.tx
: Input queue of packets to transmit when connected.rx
: Output queue of received packets when connected.
Returns a reference to the timer instance used by the Link-Layer.
pub fn start_advertise(
&mut self,
interval: Duration,
data: &[AdStructure<'_>],
transmitter: &mut C::Transmitter,
tx: <<C as Config>::PacketQueue as PacketQueue>::Consumer,
rx: <<C as Config>::PacketQueue as PacketQueue>::Producer
) -> Result<NextUpdate, Error>
pub fn start_advertise(
&mut self,
interval: Duration,
data: &[AdStructure<'_>],
transmitter: &mut C::Transmitter,
tx: <<C as Config>::PacketQueue as PacketQueue>::Consumer,
rx: <<C as Config>::PacketQueue as PacketQueue>::Producer
) -> Result<NextUpdate, Error>
Starts advertising this device, optionally sending data along with the advertising PDU.
pub fn process_adv_packet(
&mut self,
rx_end: Instant,
tx: &mut C::Transmitter,
header: Header,
payload: &[u8],
crc_ok: bool
) -> Cmd
pub fn process_adv_packet(
&mut self,
rx_end: Instant,
tx: &mut C::Transmitter,
header: Header,
payload: &[u8],
crc_ok: bool
) -> Cmd
Process an incoming packet from an advertising channel.
The access address of the packet must be ADVERTISING_ADDRESS
.
Parameters
rx_end
: A timestamp indicating when the packet was fully received.tx
: A packet transmitter.header
: The header of the received packet.payload
: The packet payload following the header.crc_ok
: Whether the packet’s CRC is correct.
pub fn process_data_packet(
&mut self,
rx_end: Instant,
tx: &mut C::Transmitter,
header: Header,
payload: &[u8],
crc_ok: bool
) -> Cmd
pub fn process_data_packet(
&mut self,
rx_end: Instant,
tx: &mut C::Transmitter,
header: Header,
payload: &[u8],
crc_ok: bool
) -> Cmd
Process an incoming data channel packet.
Update the Link-Layer state after the timer expires.
This should be called whenever the timer set by the last returned Cmd
has expired.
Parameters
tx
: ATransmitter
for sending packets.
Returns a reference to the connection state.
If the Link Layer is not currently in a connection, returns None
.
Returns whether the Link-Layer is currently broadcasting advertisement packets.
Returns whether the Link-Layer is currently connected.