This library provides the official Rust interface to the Linux Bluetooth protocol stack (BlueZ). Both publishing local and consuming remote GATT services using idiomatic Rust code is supported. L2CAP and RFCOMM sockets are presented using an API similar to Tokio networking.
This library depends on the tokio asynchronous runtime.
The following functionality is provided.
- Bluetooth adapters
- configuration of power, discoverability, name, etc.
- hot-plug support through change events stream
- Bluetooth devices
- consumption of remote GATT services
- publishing local GATT services
- sending Bluetooth Low Energy advertisements
- Bluetooth authorization agent
- efficient event dispatching
- not affected by D-Bus match rule count
- O(1) in number of subscriptions
- L2CAP sockets
- RFCOMM sockets
- database of assigned numbers
- manufacturer ids
- services classes, GATT services, characteristics and descriptors
Currently, some classic Bluetooth (BR/EDR) functionality is missing. However, pull requests and contributions are welcome!
The following crate features are available.
bluetoothd: Enables all functions requiring a running Bluetooth daemon.
id: Enables database of assigned numbers.
l2cap: Enables L2CAP sockets.
rfcomm: Enables RFCOMM sockets.
serde: Enables serialization and deserialization of some data types.
To enable all crate features specify the
full crate feature.
Create a Session using Session::new; this establishes a connection to the Bluetooth daemon. Then obtain a Bluetooth adapter using Session::adapter. From there on you can access most of the functionality using the methods provided by Adapter.
Bluetooth LE advertising.
Bluetooth authorization agent.
Local and remote GATT services.
Manufacturer ids and assigned UUIDs for service classes and profiles, GATT services, GATT characteristics and GATT descriptors.
Logical Link Control and Adaptation Protocol (L2CAP) sockets.
Radio frequency communication (RFCOMM) sockets and profiles.
Interface to a Bluetooth adapter.
Interface to a Bluetooth device.
Invalid Bluetooth address error.
Linux kernel modalias information.
Bluetooth adapter event.
Bluetooth adapter property.
Bluetooth device address type.
Bluetooth device event.
Bluetooth device property.
Bluetooth error kind.
Internal Bluetooth error kind.
Bluetooth session event.
UUID extension trait to convert to and from Bluetooth short UUIDs.