Struct ockam_transport_ble::BleTransport
source · pub struct BleTransport { /* private fields */ }
Expand description
High level management interface for BLE transports
Be aware that only one BleTransport
can exist per node, as it
registers itself as a router for the BLE
address type. Multiple
calls to BleTransport::create
will panic.
To register additional connections on an already initialised
BleTransport
, use
ble.connect()
. To listen for
incoming connections use
ble.listen()
use ockam_transport_ble::{BleClient, BleTransport};
use ockam_transport_ble::driver::btleplug::BleAdapter;
// Create a ble_client
let ble_adapter = BleAdapter::try_new().await?;
let ble_client = BleClient::with_adapter(ble_adapter);
// Initialize the BLE Transport.
let ble = BleTransport::create(&ctx).await?;
// Try to connect to BleServer
ble.connect(ble_client, "ockam_ble_1".to_string()).await?;
Implementations§
source§impl BleTransport
impl BleTransport
sourcepub async fn create(ctx: &Context) -> Result<Self>
pub async fn create(ctx: &Context) -> Result<Self>
Create a new BLE transport and router for the current node
sourcepub async fn connect<A: BleClientDriver + BleStreamDriver + Send + 'static, S: AsRef<str> + Debug>(
&self,
ble_client: BleClient<A>,
peer: S
) -> Result<()>
pub async fn connect<A: BleClientDriver + BleStreamDriver + Send + 'static, S: AsRef<str> + Debug>( &self, ble_client: BleClient<A>, peer: S ) -> Result<()>
Establish an outgoing BLE connection on an existing transport
Starts a new pair of Ble connection workers
One worker handles outgoing messages, while another handles incoming messages. The local worker address is chosen based on the peer the worker is meant to be connected to.
Trait Implementations§
source§impl AsyncTryClone for BleTransport
impl AsyncTryClone for BleTransport
Auto Trait Implementations§
impl !RefUnwindSafe for BleTransport
impl Send for BleTransport
impl Sync for BleTransport
impl Unpin for BleTransport
impl !UnwindSafe for BleTransport
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
Mutably borrows from an owned value. Read more