Skip to main content

Module bluez

Module bluez 

Source
Expand description

The BlueZ object model.

BlueZ publishes the whole Bluetooth world as a D-Bus object tree and expects clients to track it through ObjectManager:

  /org/bluez                                        org.bluez.AgentManager1
  /org/bluez/hci0                                   org.bluez.Adapter1
                                                    org.bluez.LEAdvertisingManager1
                                                    org.bluez.GattManager1
  /org/bluez/hci0/dev_AA_BB_CC_DD_EE_FF             org.bluez.Device1
  …/dev_AA_BB_CC_DD_EE_FF/service0010               org.bluez.GattService1
  …/service0010/char0011                            org.bluez.GattCharacteristic1
  …/char0011/desc0013                               org.bluez.GattDescriptor1

So an object path is the handle, and the hierarchy is encoded in it: a characteristic’s service is its parent path. That is the opposite of CoreBluetooth, where handles are opaque pointers and the tree is walked by asking. It is also why this layer keeps a cached mirror of the tree — every lookup would otherwise be a round trip.

§Where this differs from CoreBluetooth

  • Discovery is not a request/reply. StartDiscovery returns immediately and devices appear as InterfacesAdded signals. Same as CoreBluetooth.
  • GATT reads are. ReadValue returns the bytes in its method reply, so there is no read-versus-notification ambiguity to resolve — the problem crate::dbus’s Apple counterpart needs a FIFO for does not exist here.
  • Notifications are property changes. StartNotify then PropertiesChanged on Value.
  • Services are not discovered explicitly. Connecting resolves them and sets ServicesResolved; the objects simply appear in the tree.

Modules§

interfaces

Structs§

Bluez
A connection to BlueZ, with a cached mirror of its object tree.
Object
One object in BlueZ’s tree: its interfaces and their properties.

Enums§

Event
What the tree tells us happened.

Constants§

SERVICE_NAME

Traits§

EventSink
Where tree changes are delivered. Called on the D-Bus reader thread.

Functions§

path

Type Aliases§

Path
A D-Bus object path — the Linux equivalent of a CoreBluetooth handle.
Result