pub struct BleTransport<I: BleIo> { /* private fields */ }Expand description
BLE transport for FIPS.
Provides connection-oriented, reliable delivery over BLE L2CAP CoC. Each peer has its own L2CAP connection; the pool enforces hardware connection limits with priority eviction.
Implementations§
Source§impl<I: BleIo> BleTransport<I>
impl<I: BleIo> BleTransport<I>
Sourcepub fn new(
transport_id: TransportId,
name: Option<String>,
config: BleConfig,
io: I,
packet_tx: PacketTx,
) -> Self
pub fn new( transport_id: TransportId, name: Option<String>, config: BleConfig, io: I, packet_tx: PacketTx, ) -> Self
Create a new BLE transport.
Sourcepub fn set_local_pubkey(&mut self, pubkey: [u8; 32])
pub fn set_local_pubkey(&mut self, pubkey: [u8; 32])
Set the local public key for pre-handshake identity exchange.
Must be called before start_async(). Without this, BLE
connections skip the pubkey exchange and discovered peers
won’t have identity information for auto-connect.
Sourcepub async fn start_async(&mut self) -> Result<(), TransportError>
pub async fn start_async(&mut self) -> Result<(), TransportError>
Start the transport asynchronously.
Sourcepub async fn stop_async(&mut self) -> Result<(), TransportError>
pub async fn stop_async(&mut self) -> Result<(), TransportError>
Stop the transport asynchronously.
Sourcepub async fn send_async(
&self,
addr: &TransportAddr,
data: &[u8],
) -> Result<usize, TransportError>
pub async fn send_async( &self, addr: &TransportAddr, data: &[u8], ) -> Result<usize, TransportError>
Send data to a remote BLE address.
If no connection exists, triggers a background connect and fails fast. The next send retry (typically 1s later for handshake msg1) will find the connection established. This avoids blocking the event loop on L2CAP connect (up to 10s).
Sourcepub async fn connect_async(
&self,
addr: &TransportAddr,
) -> Result<(), TransportError>
pub async fn connect_async( &self, addr: &TransportAddr, ) -> Result<(), TransportError>
Initiate a non-blocking connection to a remote BLE device.
Spawns a background task that connects with timeout and promotes
to the pool on success. Poll connection_state_sync() to check.
Sourcepub fn connection_state_sync(&self, addr: &TransportAddr) -> ConnectionState
pub fn connection_state_sync(&self, addr: &TransportAddr) -> ConnectionState
Query the state of a connection attempt.
Sourcepub async fn close_connection_async(&self, addr: &TransportAddr)
pub async fn close_connection_async(&self, addr: &TransportAddr)
Close a specific connection.
Sourcepub fn link_mtu(&self, addr: &TransportAddr) -> u16
pub fn link_mtu(&self, addr: &TransportAddr) -> u16
Get the link MTU for a specific address.
Trait Implementations§
Source§impl<I: BleIo> Transport for BleTransport<I>
impl<I: BleIo> Transport for BleTransport<I>
Source§fn transport_id(&self) -> TransportId
fn transport_id(&self) -> TransportId
Source§fn transport_type(&self) -> &TransportType
fn transport_type(&self) -> &TransportType
Source§fn state(&self) -> TransportState
fn state(&self) -> TransportState
Source§fn send(
&self,
_addr: &TransportAddr,
_data: &[u8],
) -> Result<(), TransportError>
fn send( &self, _addr: &TransportAddr, _data: &[u8], ) -> Result<(), TransportError>
Source§fn discover(&self) -> Result<Vec<DiscoveredPeer>, TransportError>
fn discover(&self) -> Result<Vec<DiscoveredPeer>, TransportError>
Source§fn auto_connect(&self) -> bool
fn auto_connect(&self) -> bool
Source§fn accept_connections(&self) -> bool
fn accept_connections(&self) -> bool
Source§fn close_connection(&self, _addr: &TransportAddr)
fn close_connection(&self, _addr: &TransportAddr)
Auto Trait Implementations§
impl<I> Freeze for BleTransport<I>
impl<I> !RefUnwindSafe for BleTransport<I>
impl<I> Send for BleTransport<I>
impl<I> Sync for BleTransport<I>
impl<I> Unpin for BleTransport<I>
impl<I> UnsafeUnpin for BleTransport<I>
impl<I> !UnwindSafe for BleTransport<I>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more