Expand description
BlueR — Official BlueZ Bindings for Rust
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
- enumeration
- configuration of power, discoverability, name, etc.
- hot-plug support through change events stream
- Bluetooth devices
- discovery
- querying of address, name, class, signal strength (RSSI), etc.
- Bluetooth Low Energy advertisements
- change events stream
- connecting and pairing
- consumption of remote GATT services
- GATT service discovery
- read, write and notify operations on characteristics
- read and write operations on characteristic descriptors
- optional use of low-overhead AsyncRead and AsyncWrite streams for notify and write operations
- publishing local GATT services
- read, write and notify operations on characteristics
- read and write operations on characteristic descriptors
- two programming models supported
- callback-based interface
- low-overhead AsyncRead and AsyncWrite streams
- 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
- support for both classic Bluetooth (BR/EDR) and Bluetooth LE
- stream oriented
- sequential packet oriented
- datagram oriented
- async IO interface with AsyncRead and AsyncWrite support
- RFCOMM sockets
- support for classic Bluetooth (BR/EDR)
- stream oriented
- async IO interface with AsyncRead and AsyncWrite support
- 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!
Crate features
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.
Basic usage
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.
L2CAP and RFCOMM sockets
Refer to the l2cap and rfcomm modules. No Session and therefore no running Bluetooth daemon is required.
Re-exports
pub use uuid::Uuid;
Modules
bluetoothd
Bluetooth LE advertising.
bluetoothd
Bluetooth authorization agent.
bluetoothd
Local and remote GATT services.
id
Manufacturer ids and assigned UUIDs for service classes and profiles, GATT services, GATT characteristics and GATT descriptors.
l2cap
Logical Link Control and Adaptation Protocol (L2CAP) sockets.
rfcomm
Radio frequency communication (RFCOMM) sockets and profiles.
Structs
bluetoothd
Interface to a Bluetooth adapter.
Bluetooth address.
bluetoothd
Interface to a Bluetooth device.
bluetoothd
Bluetooth error.
Invalid Bluetooth address error.
bluetoothd
Linux kernel modalias information.
bluetoothd
Bluetooth session.
Enums
bluetoothd
Bluetooth adapter event.
bluetoothd
Bluetooth adapter property.
Bluetooth device address type.
bluetoothd
Bluetooth device event.
bluetoothd
Bluetooth device property.
bluetoothd
Bluetooth error kind.
bluetoothd
Internal Bluetooth error kind.
bluetoothd
Bluetooth session event.
Traits
UUID extension trait to convert to and from Bluetooth short UUIDs.
Type Definitions
bluetoothd
Bluetooth result.