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
impl BluestConnection
Sourcepub async fn new(adapter: Adapter, device: Device) -> Result<Self>
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.
Sourcepub async fn disconnect(&self)
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
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,
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. Forwarding is
best-effort: frames are dropped when the receiver falls behind, not
queued unboundedly, to ensure the task never blocks on backpressure
and can always respond to a pause request. While a connect owns the
radio (the [ScanGate] is paused) the task drops its scan stream and
restarts it on resume. The task stops for good when the receiver is
dropped or the adapter’s scan stream ends.
Intended for a single active watcher per connection: concurrent scan tasks would share one scanning flag and corrupt the pause-ack protocol.
§Errors
Returns crate::error::BleError on adapter/scan failures.