Struct rubble::link::connection::Connection [−][src]
pub struct Connection<C: Config> {Show 16 fields
access_address: u32,
crc_init: u32,
channel_map: ChannelMap,
hop: u8,
conn_interval: Duration,
conn_event_count: Wrapping<u16>,
unmapped_channel: DataChannel,
channel: DataChannel,
transmit_seq_num: SeqNum,
next_expected_seq_num: SeqNum,
last_header: Header,
received_packet: bool,
tx: <<C as Config>::PacketQueue as PacketQueue>::Consumer,
rx: <<C as Config>::PacketQueue as PacketQueue>::Producer,
update_data: Option<LlcpUpdate>,
_p: PhantomData<C>,
}
Expand description
Connection state and parameters.
Fields
access_address: u32
crc_init: u32
channel_map: ChannelMap
hop: u8
Number of (unmapped) channels to hop between each connection event.
conn_interval: Duration
Connection event interval (duration between the start of 2 subsequent connection events).
conn_event_count: Wrapping<u16>
Connection event counter (connEventCount(er)
in the spec).
unmapped_channel: DataChannel
Unmapped data channel on which the next connection event will take place.
Also known as lastUnmappedChannel
or previous_event_channel
(yes, the spec uses both).
channel: DataChannel
Actual data channel on which the next data packets will be exchanged.
transmit_seq_num: SeqNum
SN
bit to be used
next_expected_seq_num: SeqNum
last_header: Header
Header of the last transmitted packet, used for retransmission.
received_packet: bool
Whether we have ever received a data packet in this connection.
tx: <<C as Config>::PacketQueue as PacketQueue>::Consumer
rx: <<C as Config>::PacketQueue as PacketQueue>::Producer
update_data: Option<LlcpUpdate>
LLCP connection update data received in a previous LL Control PDU.
Contains the instant at which it should be applied to the Link Layer state.
_p: PhantomData<C>
Implementations
pub(crate) fn create(
lldata: &ConnectRequestData,
rx_end: Instant,
tx: <<C as Config>::PacketQueue as PacketQueue>::Consumer,
rx: <<C as Config>::PacketQueue as PacketQueue>::Producer
) -> (Self, Cmd)
pub(crate) fn create(
lldata: &ConnectRequestData,
rx_end: Instant,
tx: <<C as Config>::PacketQueue as PacketQueue>::Consumer,
rx: <<C as Config>::PacketQueue as PacketQueue>::Producer
) -> (Self, Cmd)
Initializes a connection state according to the LLData
contained in the CONNECT_REQ
advertising PDU.
Returns the connection state and a Cmd
to apply to the radio/timer.
Parameters
lldata
: Data contained in theCONNECT_REQ
advertising PDU.rx_end
: Instant at which theCONNECT_REQ
PDU was fully received.tx
: Channel for packets to transmit.rx
: Channel for received packets.
Called by the LinkLayer
when a data channel packet is received.
Returns Err(())
when the connection is ended (not necessarily due to an error condition).
Called by the LinkLayer
when the configured timer expires (according to a Cmd
returned
earlier).
Returns Err(())
when the connection is closed or lost. In that case, the Link-Layer will
return to standby state.
Whether we want to send more data during this connection event.
Note that this has to change to false
eventually, even if there’s more data to be sent,
because the connection event must close at least T_IFS
before the next one occurs.
Advances the unmapped_channel
and channel
fields to the next data channel on which a
connection event will take place.
According to: 4.5.8.2 Channel Selection
.
Sends a new PDU to the connected device (ie. a non-retransmitted PDU).
fn process_control_pdu(
&mut self,
pdu: ControlPdu<'_>,
can_respond: bool
) -> Result<Option<ControlPdu<'static>>, LlcpError>
fn process_control_pdu(
&mut self,
pdu: ControlPdu<'_>,
can_respond: bool
) -> Result<Option<ControlPdu<'static>>, LlcpError>
Tries to process and acknowledge an LL Control PDU.
Returns Err(())
when the connection is closed or lost.
Note this this function is on a time-critical path and thus can not use logging since that’s currently way too slow. Critical errors can still be logged, since they abort the connection anyways.
Parameters
pdu
: The LL Control PDU (LLCPDU) to process.can_respond
: Whether the radio’s TX buffer may be overwritten to send a response. If this isfalse
, this method may choose not to acknowledge the PDU and wait for a retransmission instead.
Stores update
in the link layer state so that it will be applied once its instant is
reached.
Patches the link layer state to incorporate update
.
Returns a Cmd
when the usual Link Layer Cmd
should be overridden. In that case, this
method must also perform channel hopping.
Returns the configured interval between connection events.
The connection event interval is arbitrated by the device in the Central role and heavily influences the data transmission latency of the connection, which is important for some applications.
The Peripheral can request the Central to change the interval by sending an L2CAP signaling message, or by using the Link Layer control procedure for requesting new connection parameters.