pub struct Bluez { /* private fields */ }Expand description
A connection to BlueZ, with a cached mirror of its object tree.
Implementations§
Source§impl Bluez
impl Bluez
Sourcepub fn new(sink: Arc<dyn EventSink>) -> Result<Self>
pub fn new(sink: Arc<dyn EventSink>) -> Result<Self>
Connect to the system bus, subscribe to the tree, and load it.
Sourcepub fn connection(&self) -> &Arc<Connection> ⓘ
pub fn connection(&self) -> &Arc<Connection> ⓘ
The underlying bus, for the peripheral role’s object exports.
Sourcepub fn adapters(&self) -> Vec<String>
pub fn adapters(&self) -> Vec<String>
Every adapter BlueZ is managing, sorted, so hci0 comes first.
Sourcepub fn select_adapter(&self, name: &str) -> Result<()>
pub fn select_adapter(&self, name: &str) -> Result<()>
Use a named adapter for everything from here on.
Takes hci1 or a full object path. Fails if BlueZ is not managing it,
rather than silently carrying on with a different one.
Sourcepub fn adapter_address(&self) -> Option<String>
pub fn adapter_address(&self) -> Option<String>
The local adapter’s own Bluetooth address, as BlueZ reports it.
Sourcepub fn is_powered(&self) -> bool
pub fn is_powered(&self) -> bool
Whether an adapter exists and is powered.
Sourcepub fn set_powered(&self, on: bool) -> Result<()>
pub fn set_powered(&self, on: bool) -> Result<()>
Turn the adapter on.
Sourcepub fn paths_with(&self, interface: &str) -> Vec<String>
pub fn paths_with(&self, interface: &str) -> Vec<String>
Every object path carrying interface.
Sourcepub fn children_with(&self, parent: &str, interface: &str) -> Vec<String>
pub fn children_with(&self, parent: &str, interface: &str) -> Vec<String>
Children of parent carrying interface — how the GATT tree is walked,
since BlueZ encodes the hierarchy in the path.
Sourcepub fn get_property(
&self,
path: &str,
interface: &str,
name: &str,
) -> Result<Value>
pub fn get_property( &self, path: &str, interface: &str, name: &str, ) -> Result<Value>
Read a property live, bypassing the cache.
Sourcepub fn set_property(
&self,
path: &str,
interface: &str,
name: &str,
value: Value,
) -> Result<()>
pub fn set_property( &self, path: &str, interface: &str, name: &str, value: Value, ) -> Result<()>
Write a property.
Sourcepub fn call_async(
&self,
path: &str,
interface: &str,
member: &str,
args: Vec<Value>,
then: impl FnOnce(Result<Message>) + Send + 'static,
)
pub fn call_async( &self, path: &str, interface: &str, member: &str, args: Vec<Value>, then: impl FnOnce(Result<Message>) + Send + 'static, )
Call a BlueZ method, delivering the reply to a callback.
Callback-based rather than blocking, so the async layer can wrap it without a thread per request — the same shape as the Apple backend.
Sourcepub fn call_async_with_fds(
&self,
path: &str,
interface: &str,
member: &str,
args: Vec<Value>,
then: impl FnOnce(Result<(Vec<Value>, Vec<RawFd>)>) + Send + 'static,
)
pub fn call_async_with_fds( &self, path: &str, interface: &str, member: &str, args: Vec<Value>, then: impl FnOnce(Result<(Vec<Value>, Vec<RawFd>)>) + Send + 'static, )
As Bluez::call_async, keeping any descriptors the reply carried.
For AcquireWrite and AcquireNotify, whose answer is a socket. The
body holds only an index; the descriptor travelled beside the message.
Sourcepub fn call(
&self,
path: &str,
interface: &str,
member: &str,
args: Vec<Value>,
) -> Result<Message>
pub fn call( &self, path: &str, interface: &str, member: &str, args: Vec<Value>, ) -> Result<Message>
Call a BlueZ method and wait.
Sourcepub fn export(&self, path: &str, handler: Arc<dyn ObjectHandler>)
pub fn export(&self, path: &str, handler: Arc<dyn ObjectHandler>)
Export an object so BlueZ can call into it — the peripheral role.