Shared helpers for outbound D-Bus method calls to org.bluez over a
rebus connection, used by Bluez.Client (passive
scanning) and Bluez.Gatt (active connections).
The rebus connection correlates in-flight calls by serial and replies via
GenServer.reply/2, so concurrent calls on one connection don't
serialize — a slow Device1.Connect does not block a ReadValue to
another device. The timeout here is purely the caller's patience
(GenServer.call/3 exit, surfaced as {:error, {:exit, ...}}).
Callers beware: these block the calling process for up to timeout.
Call from a Task (never from a GenServer's own loop) for anything
that can be slow — Connect can take ~25 s, GATT reads up to the ATT
timeout.
Summary
Functions
Install a bus-side match rule so the daemon routes matching signals to this connection (rebus installs none by itself).
Synchronous method call to org.bluez → {:ok, reply_body} | {:error, reason}.
Like call/7 but to an arbitrary bus name. call/7 is this with
destination: "org.bluez"; Bluez.BlueAlsa uses it to reach
org.bluealsa over the same kind of connection. Same error normalization.
Fetch org.bluez's full object tree (ObjectManager.GetManagedObjects).
Functions
Install a bus-side match rule so the daemon routes matching signals to this connection (rebus installs none by itself).
@spec call(pid(), String.t(), String.t(), String.t(), String.t(), list(), timeout()) :: {:ok, list()} | {:error, term()}
Synchronous method call to org.bluez → {:ok, reply_body} | {:error, reason}.
Pass signature: "" for argument-less members. Errors are normalized:
a D-Bus error reply yields {:error, error_name}, a raise yields
{:error, exception}, and a GenServer.call timeout / dead connection
yields {:error, {:exit, reason}} (exits are caught, not propagated).
@spec call_to( pid(), String.t(), String.t(), String.t(), String.t(), String.t(), list(), timeout() ) :: {:ok, list()} | {:error, term()}
Like call/7 but to an arbitrary bus name. call/7 is this with
destination: "org.bluez"; Bluez.BlueAlsa uses it to reach
org.bluealsa over the same kind of connection. Same error normalization.
Fetch org.bluez's full object tree (ObjectManager.GetManagedObjects).