pub struct BluerConnection { /* private fields */ }Expand description
BlueZ connection wrapper
Wraps a bluer::Device with connection state tracking and write queue.
BLE only allows one pending write per connection, so all writes are
serialized through the write queue.
Implementations§
Source§impl BluerConnection
impl BluerConnection
Sourcepub async fn discover_mtu(
&self,
service_uuid: Uuid,
char_uuid: Uuid,
) -> Result<u16>
pub async fn discover_mtu( &self, service_uuid: Uuid, char_uuid: Uuid, ) -> Result<u16>
Discover the actual negotiated MTU via a characteristic
BlueZ negotiates MTU during the first GATT operation. Call this after connecting to get the actual negotiated value. Uses AcquireWrite which returns the negotiated MTU.
Sourcepub async fn update_rssi(&self)
pub async fn update_rssi(&self)
Update RSSI from device
Sourcepub async fn disconnect(&self) -> Result<()>
pub async fn disconnect(&self) -> Result<()>
Disconnect from the device
Clears any pending writes and disconnects the BLE connection.
Sourcepub async fn discover_services(&self) -> Result<()>
pub async fn discover_services(&self) -> Result<()>
Discover GATT services
Sourcepub async fn read_characteristic(
&self,
service_uuid: Uuid,
char_uuid: Uuid,
) -> Result<Vec<u8>>
pub async fn read_characteristic( &self, service_uuid: Uuid, char_uuid: Uuid, ) -> Result<Vec<u8>>
Read a characteristic value
Sourcepub async fn write_characteristic(
&self,
service_uuid: Uuid,
char_uuid: Uuid,
value: &[u8],
) -> Result<()>
pub async fn write_characteristic( &self, service_uuid: Uuid, char_uuid: Uuid, value: &[u8], ) -> Result<()>
Write a characteristic value (direct, non-queued)
Warning: BLE only allows one pending write per connection. Calling this
method concurrently may cause write failures. Use write_characteristic_queued
for safe concurrent writes.
Sourcepub async fn write_characteristic_queued(
&self,
service_uuid: Uuid,
char_uuid: Uuid,
value: &[u8],
) -> Result<()>
pub async fn write_characteristic_queued( &self, service_uuid: Uuid, char_uuid: Uuid, value: &[u8], ) -> Result<()>
Write a characteristic value with queuing
BLE only allows one pending write per connection. This method queues writes and processes them serially, preventing write conflicts. Safe to call concurrently from multiple tasks.
Returns when the write completes (or fails).
Sourcepub async fn write_queue_depth(&self) -> usize
pub async fn write_queue_depth(&self) -> usize
Get the current write queue depth
Useful for monitoring backpressure. If the queue grows too large, consider slowing down write requests.
Sourcepub async fn write_in_progress(&self) -> bool
pub async fn write_in_progress(&self) -> bool
Check if a write is currently in progress
Sourcepub async fn clear_write_queue(&self)
pub async fn clear_write_queue(&self)
Clear the write queue (e.g., on disconnect)
All pending writes will receive an error.
Trait Implementations§
Source§impl BleConnection for BluerConnection
impl BleConnection for BluerConnection
Source§fn connected_duration(&self) -> Duration
fn connected_duration(&self) -> Duration
Source§impl Clone for BluerConnection
impl Clone for BluerConnection
Source§fn clone(&self) -> BluerConnection
fn clone(&self) -> BluerConnection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more