Skip to main content

BluestConnection

Struct BluestConnection 

Source
pub struct BluestConnection { /* private fields */ }
Expand description

A GattConnection over a connected bluest Device that reconnects and retries on a dropped link.

Implementations§

Source§

impl BluestConnection

Source

pub async fn new(adapter: Adapter, device: Device) -> Result<Self>

Wrap an already-connected device, discovering its services and characteristics.

§Errors

Returns BleError::Backend on a bluest discovery failure.

Source

pub async fn disconnect(&self)

Release the active GATT link. A sleepy HAP accessory only advertises and emits encrypted broadcasts while disconnected, and on macOS CoreBluetooth filters a connected peripheral out of scan results — so a caller watching for sleepy events must disconnect after setup. A subsequent encrypted operation (e.g. a disconnected-event poll read) transparently reconnects via the supervisor.

Trait Implementations§

Source§

impl AdvertSource for BluestConnection

Source§

fn watch_adverts<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Receiver<RawAdvert>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stream Apple HAP advertisements by running a continuous adapter scan.

Spawns a background task that feeds every Apple (company id 0x004C) manufacturer-data frame into the returned channel. The task stops when the receiver is dropped or the adapter’s scan stream ends.

§Errors

Returns crate::error::BleError on adapter/scan failures.

Source§

impl GattConnection for BluestConnection

Source§

fn instance_id<'life0, 'life1, 'async_trait>( &'life0 self, char_uuid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<u16>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read one characteristic’s HAP instance id (its Instance-ID descriptor) without walking the whole tree — used to address the pairing characteristics before the (slow) full database sweep.
Source§

fn max_write<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

The maximum bytes that fit in a single GATT write — the HAP-BLE PDU fragment size. Backends that can’t determine the negotiated MTU return a conservative default.
Source§

fn generation<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = u64> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

A monotonically increasing link-generation counter that advances on every reconnect. A secure session minted at generation g is invalidated when the accessory drops the link (the count moves past g), so the holder must re-run Pair Verify before its next encrypted operation. Backends without a reconnect supervisor never invalidate sessions and return 0.
Source§

fn write<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, char_uuid: &'life1 str, value: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Write a value to a characteristic identified by its UUID.
Source§

fn read<'life0, 'life1, 'async_trait>( &'life0 self, char_uuid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read a characteristic’s current value by UUID.
Source§

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, char_uuid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Receiver<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Subscribe to notifications on a characteristic; the receiver yields raw notification payloads.
Source§

fn enumerate<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<GattService>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enumerate the accessory’s services and characteristics (with iids).

Auto Trait Implementations§

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