Skip to main content

BleTransport

Struct BleTransport 

Source
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>

Source

pub fn new( transport_id: TransportId, name: Option<String>, config: BleConfig, io: I, packet_tx: PacketTx, ) -> Self

Create a new BLE transport.

Source

pub fn name(&self) -> Option<&str>

Get the instance name.

Source

pub fn stats(&self) -> &Arc<BleStats>

Get the transport statistics.

Source

pub fn io(&self) -> &Arc<I>

Get the I/O implementation (for test injection).

Source

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.

Source

pub async fn start_async(&mut self) -> Result<(), TransportError>

Start the transport asynchronously.

Source

pub async fn stop_async(&mut self) -> Result<(), TransportError>

Stop the transport asynchronously.

Source

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).

Source

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.

Source

pub fn connection_state_sync(&self, addr: &TransportAddr) -> ConnectionState

Query the state of a connection attempt.

Source

pub async fn close_connection_async(&self, addr: &TransportAddr)

Close a specific connection.

Get the link MTU for a specific address.

Trait Implementations§

Source§

impl<I: BleIo> Transport for BleTransport<I>

Source§

fn transport_id(&self) -> TransportId

Get the transport identifier.
Source§

fn transport_type(&self) -> &TransportType

Get the transport type metadata.
Source§

fn state(&self) -> TransportState

Get the current state.
Source§

fn mtu(&self) -> u16

Get the MTU for this transport.
Get the MTU for a specific link. Read more
Source§

fn start(&mut self) -> Result<(), TransportError>

Start the transport.
Source§

fn stop(&mut self) -> Result<(), TransportError>

Stop the transport.
Source§

fn send( &self, _addr: &TransportAddr, _data: &[u8], ) -> Result<(), TransportError>

Send data to a transport address.
Source§

fn discover(&self) -> Result<Vec<DiscoveredPeer>, TransportError>

Discover potential peers (if supported).
Source§

fn auto_connect(&self) -> bool

Whether to auto-connect to peers returned by discover(). Default: false. Concrete transports read from their own config.
Source§

fn accept_connections(&self) -> bool

Whether to accept inbound handshake initiations on this transport. Default: true (preserves UDP’s current implicit behavior).
Source§

fn close_connection(&self, _addr: &TransportAddr)

Close a specific connection (connection-oriented transports only). Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more