feat(bluez): add AgentManager1, HealthManager1, and ProfileManager1 interfaces
This commit is contained in:
parent
8059e6bdaa
commit
5630ebe694
6 changed files with 125 additions and 10 deletions
|
|
@ -9,8 +9,8 @@ categories = ["os::linux-apis"]
|
||||||
keywords = ["dbus", "bluez", "zbus", "bluetooth"]
|
keywords = ["dbus", "bluez", "zbus", "bluetooth"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
futures = "0.3.30"
|
futures-util.workspace = true
|
||||||
zbus = "4.2.1"
|
zbus.workspace = true
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pico-args = "0.5.0"
|
pico-args = "0.5.0"
|
||||||
|
|
|
||||||
39
bluez/src/agent_manager1.rs
Normal file
39
bluez/src/agent_manager1.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
//! # D-Bus interface proxy for: `org.bluez.AgentManager1`
|
||||||
|
//!
|
||||||
|
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
|
||||||
|
//! Source: `Interface '/org/bluez' from service 'org.bluez' on system bus`.
|
||||||
|
//!
|
||||||
|
//! You may prefer to adapt it, instead of using it verbatim.
|
||||||
|
//!
|
||||||
|
//! More information can be found in the [Writing a client proxy] section of the zbus
|
||||||
|
//! documentation.
|
||||||
|
//!
|
||||||
|
//! This type implements the [D-Bus standard interfaces], (`org.freedesktop.DBus.*`) for which the
|
||||||
|
//! following zbus API can be used:
|
||||||
|
//!
|
||||||
|
//! * [`zbus::fdo::IntrospectableProxy`]
|
||||||
|
//!
|
||||||
|
//! Consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
||||||
|
//!
|
||||||
|
//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html
|
||||||
|
//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces,
|
||||||
|
use zbus::proxy;
|
||||||
|
#[proxy(
|
||||||
|
interface = "org.bluez.AgentManager1",
|
||||||
|
default_service = "org.bluez",
|
||||||
|
default_path = "/org/bluez"
|
||||||
|
)]
|
||||||
|
trait AgentManager1 {
|
||||||
|
/// RegisterAgent method
|
||||||
|
fn register_agent(
|
||||||
|
&self,
|
||||||
|
agent: &zbus::zvariant::ObjectPath<'_>,
|
||||||
|
capability: &str,
|
||||||
|
) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
/// RequestDefaultAgent method
|
||||||
|
fn request_default_agent(&self, agent: &zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
/// UnregisterAgent method
|
||||||
|
fn unregister_agent(&self, agent: &zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
//! # D-Bus interface proxy for: `org.bluez.Device1`
|
//! # D-Bus interface proxy for: `org.bluez.Device1`
|
||||||
//!
|
//!
|
||||||
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
|
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
|
||||||
|
|
|
||||||
36
bluez/src/health_manager1.rs
Normal file
36
bluez/src/health_manager1.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
//! # D-Bus interface proxy for: `org.bluez.HealthManager1`
|
||||||
|
//!
|
||||||
|
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
|
||||||
|
//! Source: `Interface '/org/bluez' from service 'org.bluez' on system bus`.
|
||||||
|
//!
|
||||||
|
//! You may prefer to adapt it, instead of using it verbatim.
|
||||||
|
//!
|
||||||
|
//! More information can be found in the [Writing a client proxy] section of the zbus
|
||||||
|
//! documentation.
|
||||||
|
//!
|
||||||
|
//! This type implements the [D-Bus standard interfaces], (`org.freedesktop.DBus.*`) for which the
|
||||||
|
//! following zbus API can be used:
|
||||||
|
//!
|
||||||
|
//! * [`zbus::fdo::IntrospectableProxy`]
|
||||||
|
//!
|
||||||
|
//! Consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
||||||
|
//!
|
||||||
|
//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html
|
||||||
|
//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces,
|
||||||
|
use zbus::proxy;
|
||||||
|
#[proxy(
|
||||||
|
interface = "org.bluez.HealthManager1",
|
||||||
|
default_service = "org.bluez",
|
||||||
|
default_path = "/org/bluez"
|
||||||
|
)]
|
||||||
|
trait HealthManager1 {
|
||||||
|
/// CreateApplication method
|
||||||
|
fn create_application(
|
||||||
|
&self,
|
||||||
|
config: std::collections::HashMap<&str, &zbus::zvariant::Value<'_>>,
|
||||||
|
) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
|
||||||
|
|
||||||
|
/// DestroyApplication method
|
||||||
|
fn destroy_application(&self, application: &zbus::zvariant::ObjectPath<'_>)
|
||||||
|
-> zbus::Result<()>;
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use futures::join;
|
use futures_util::join;
|
||||||
|
|
||||||
pub mod adapter1;
|
pub mod adapter1;
|
||||||
|
pub mod agent_manager1;
|
||||||
pub mod battery1;
|
pub mod battery1;
|
||||||
pub mod device1;
|
pub mod device1;
|
||||||
|
pub mod health_manager1;
|
||||||
|
pub mod profile_manager1;
|
||||||
|
|
||||||
pub async fn get_adapters<'a>(
|
pub async fn get_adapters<'a>(
|
||||||
connection: &zbus::Connection,
|
connection: &zbus::Connection,
|
||||||
|
|
@ -23,7 +26,7 @@ pub async fn get_adapters<'a>(
|
||||||
.collect();
|
.collect();
|
||||||
let adapters: Vec<
|
let adapters: Vec<
|
||||||
zbus::Result<(zbus::zvariant::OwnedObjectPath, adapter1::Adapter1Proxy<'a>)>,
|
zbus::Result<(zbus::zvariant::OwnedObjectPath, adapter1::Adapter1Proxy<'a>)>,
|
||||||
> = futures::future::join_all(adapter_addresses.into_iter().map(|path| async {
|
> = futures_util::future::join_all(adapter_addresses.into_iter().map(|path| async {
|
||||||
Ok((
|
Ok((
|
||||||
path.clone(),
|
path.clone(),
|
||||||
adapter1::Adapter1Proxy::new(connection, path).await?,
|
adapter1::Adapter1Proxy::new(connection, path).await?,
|
||||||
|
|
@ -103,11 +106,7 @@ pub async fn get_device<'a>(
|
||||||
connection: &zbus::Connection,
|
connection: &zbus::Connection,
|
||||||
device_path: zbus::zvariant::OwnedObjectPath,
|
device_path: zbus::zvariant::OwnedObjectPath,
|
||||||
) -> zbus::Result<BluetoothDevice<'a>> {
|
) -> zbus::Result<BluetoothDevice<'a>> {
|
||||||
BluetoothDevice::new(
|
BluetoothDevice::new(connection, device_path.into()).await
|
||||||
connection,
|
|
||||||
device_path.into(),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_adapter<'a>(
|
pub async fn get_adapter<'a>(
|
||||||
|
|
@ -147,7 +146,7 @@ pub async fn get_devices<'a>(
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let devices: Vec<zbus::Result<(zbus::zvariant::OwnedObjectPath, BluetoothDevice<'a>)>> =
|
let devices: Vec<zbus::Result<(zbus::zvariant::OwnedObjectPath, BluetoothDevice<'a>)>> =
|
||||||
futures::future::join_all(device_addresses.into_iter().map(|path| async {
|
futures_util::future::join_all(device_addresses.into_iter().map(|path| async {
|
||||||
Ok((
|
Ok((
|
||||||
path.clone(),
|
path.clone(),
|
||||||
BluetoothDevice::new(connection, path.into()).await?,
|
BluetoothDevice::new(connection, path.into()).await?,
|
||||||
|
|
|
||||||
39
bluez/src/profile_manager1.rs
Normal file
39
bluez/src/profile_manager1.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
|
//! # D-Bus interface proxy for: `org.bluez.ProfileManager1`
|
||||||
|
//!
|
||||||
|
//! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data.
|
||||||
|
//! Source: `Interface '/org/bluez' from service 'org.bluez' on system bus`.
|
||||||
|
//!
|
||||||
|
//! You may prefer to adapt it, instead of using it verbatim.
|
||||||
|
//!
|
||||||
|
//! More information can be found in the [Writing a client proxy] section of the zbus
|
||||||
|
//! documentation.
|
||||||
|
//!
|
||||||
|
//! This type implements the [D-Bus standard interfaces], (`org.freedesktop.DBus.*`) for which the
|
||||||
|
//! following zbus API can be used:
|
||||||
|
//!
|
||||||
|
//! * [`zbus::fdo::IntrospectableProxy`]
|
||||||
|
//!
|
||||||
|
//! Consequently `zbus-xmlgen` did not generate code for the above interfaces.
|
||||||
|
//!
|
||||||
|
//! [Writing a client proxy]: https://dbus2.github.io/zbus/client.html
|
||||||
|
//! [D-Bus standard interfaces]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces,
|
||||||
|
use zbus::proxy;
|
||||||
|
#[proxy(
|
||||||
|
interface = "org.bluez.ProfileManager1",
|
||||||
|
default_service = "org.bluez",
|
||||||
|
default_path = "/org/bluez"
|
||||||
|
)]
|
||||||
|
trait ProfileManager1 {
|
||||||
|
/// RegisterProfile method
|
||||||
|
fn register_profile(
|
||||||
|
&self,
|
||||||
|
profile: &zbus::zvariant::ObjectPath<'_>,
|
||||||
|
UUID: &str,
|
||||||
|
options: std::collections::HashMap<&str, &zbus::zvariant::Value<'_>>,
|
||||||
|
) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
/// UnregisterProfile method
|
||||||
|
fn unregister_profile(&self, profile: &zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue