API Reference bluez v#0.1.0

Copy Markdown View Source

Modules

Brings up the Linux BlueZ stack — dbus-daemon, bluetoothd, and (optionally) bluez-alsa — under one supervisor, with Elixir clients for BLE scanning (Bluez.Client), active GATT connections (Bluez.Gatt), pairing (Bluez.Agent), and A2DP audio PCM discovery (Bluez.BlueAlsa).

Reconstructs a BLE advertisement (the verbatim-ish AD byte structure plus the fields an ESPHome-style scanner host needs) from BlueZ's parsed device properties.

The org.bluez.Agent1 pairing agent backing Bluez.Gatt's pair/1 (Phase 2 of the Bluetooth proxy).

Persistent rebus D-Bus client to org.bluealsa (the bluez-alsa bluealsad daemon), used to learn which A2DP-playback PCMs are ready to open right now. This is the control-plane half of the Bluetooth-headphone audio path; the data plane is sendspin opening the ALSA PCM string directly.

A supervised gate that blocks in init/1 until the D-Bus system-bus socket exists, so the next :rest_for_one sibling (bluetoothd) never starts before dbus-daemon is listening. Stays alive afterwards as an idle GenServer so :rest_for_one re-runs it whenever dbus-daemon restarts.

Persistent rebus D-Bus client + service to org.bluez, driving BLE scanning and turning device signals into advertisements, fanned out through the on_advertisement: fun.

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).

Pure per-device advertisement cache with emit-gating and a bounded size. No I/O — Bluez.Client owns the side effects (it emits the adverts this module returns).

Convert between wire BLE addresses and BlueZ device object paths.

Active BLE connections + GATT client over BlueZ D-Bus — the engine an ESPHome-proxy-style host puts behind its Bluetooth-proxy adapter.

A GATT characteristic within a Bluez.Gatt.Service.

A GATT descriptor within a Bluez.Gatt.Characteristic. handle is the descriptor's own attribute handle.

A GATT primary/secondary service discovered on a connected device — the neutral shape Bluez.GattTree builds and Bluez.Gatt emits in {:gatt_service, address, service} events. Hosts translate it to their own wire shape in the on_gatt_event: fun.

Build a GATT tree from BlueZ's GetManagedObjects reply.

An Elixir implementation of the D-Bus message protocol.

D-Bus message decoder that unmarshals data according to D-Bus wire format.

D-Bus message encoder that marshals data according to D-Bus wire format.

D-Bus message protocol implementation.

Unwraps org.bluez D-Bus property maps (as decoded by rebus) into plain Elixir maps for Bluez.Advert.