From 6b520fe02275858b749ff89861d0ed35a860fe83 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Wed, 9 Jul 2025 00:49:10 +0100 Subject: [PATCH] Add method to turn adapter on or off. --- bluez-async/CHANGELOG.md | 6 ++++++ bluez-async/src/lib.rs | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/bluez-async/CHANGELOG.md b/bluez-async/CHANGELOG.md index 961a4a3..b1b2ca9 100644 --- a/bluez-async/CHANGELOG.md +++ b/bluez-async/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### New features + +- Added `set_powered` to `BluetoothSession`. + ## 0.8.1 ### New features diff --git a/bluez-async/src/lib.rs b/bluez-async/src/lib.rs index c6509fe..1e8d6ec 100644 --- a/bluez-async/src/lib.rs +++ b/bluez-async/src/lib.rs @@ -296,6 +296,16 @@ impl BluetoothSession { Ok((dbus_handle.map(|res| res?), BluetoothSession { connection })) } + /// Powers the given adapter on or off. + pub async fn set_powered( + &self, + adapter_id: &AdapterId, + powered: bool, + ) -> Result<(), BluetoothError> { + self.adapter(adapter_id).set_powered(powered).await?; + Ok(()) + } + /// Power on all Bluetooth adapters, remove any discovery filter, and then start scanning for /// devices. ///