Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bluez-async/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### New features

- Added `pair_with_timeout` and `cancel_pairing` to `BluetoothSession`.

## 0.8.0

### Breaking changes
Expand Down
20 changes: 19 additions & 1 deletion bluez-async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,31 @@ impl BluetoothSession {
.unwrap_or(Err(BluetoothError::ServiceDiscoveryTimedOut))
}

/// Connect to the given Bluetooth device and initiate pairing, with the specified timeout.
pub async fn pair_with_timeout(
&self,
id: &DeviceId,
timeout: Duration,
) -> Result<(), BluetoothError> {
self.device(id, timeout).pair().await?;
self.await_service_discovery(id).await
}

/// Cancel a pairing operation with the given Bluetooth device.
pub async fn cancel_pairing(&self, id: &DeviceId) -> Result<(), BluetoothError> {
Ok(self
.device(id, DBUS_METHOD_CALL_TIMEOUT)
.cancel_pairing()
.await?)
}

/// Connect to the given Bluetooth device.
pub async fn connect(&self, id: &DeviceId) -> Result<(), BluetoothError> {
self.connect_with_timeout(id, DBUS_METHOD_CALL_TIMEOUT)
.await
}

/// Connect to the given Bluetooth device with specified timeout.
/// Connect to the given Bluetooth device with the specified timeout.
pub async fn connect_with_timeout(
&self,
id: &DeviceId,
Expand Down
Loading