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 with custom filters
- querying of address, name, class, signal strength (RSSI), etc.
- Bluetooth Low Energy advertisements
- change events stream
- connecting and pairing
- passive LE advertisement monitoring
- 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
- Bluetooth Mesh
- provision and join networks
- send and receive messages
- 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.mesh
: Enables Bluetooth mesh functionality.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§
- adv
bluetoothd
Bluetooth LE advertising. - agent
bluetoothd
Bluetooth authorization agent. - gatt
bluetoothd
Local and remote GATT services. - id
id
Manufacturer ids and assigned UUIDs for service classes and profiles, GATT services, GATT characteristics and GATT descriptors. - l2cap
l2cap
Logical Link Control and Adaptation Protocol (L2CAP) sockets. - mesh
mesh
Bluetooth Mesh support. - monitor
bluetoothd
Bluetooth advertisement monitor. - rfcomm
rfcomm
Radio frequency communication (RFCOMM) sockets and profiles.
Structs§
- Adapter
bluetoothd
Interface to a Bluetooth adapter. - Bluetooth address.
- Device
bluetoothd
Interface to a Bluetooth device. - DiscoveryFilter
bluetoothd
Bluetooth device discovery filter. - Error
bluetoothd
Bluetooth error. - Invalid Bluetooth address error.
- Modalias
bluetoothd
Linux kernel modalias information. - Session
bluetoothd
Bluetooth session.
Enums§
- AdapterEvent
bluetoothd
Bluetooth adapter event. - AdapterProperty
bluetoothd
Bluetooth adapter property. - Bluetooth device address type.
- DeviceEvent
bluetoothd
Bluetooth device event. - DeviceProperty
bluetoothd
Bluetooth device property. - DiscoveryTransport
bluetoothd
Transport parameter determines the type of scan. - ErrorKind
bluetoothd
Bluetooth error kind. - InternalErrorKind
bluetoothd
Internal Bluetooth error kind. - SessionEvent
bluetoothd
Bluetooth session event.
Traits§
- UUID extension trait to convert to and from Bluetooth short UUIDs.
Type Aliases§
- Result
bluetoothd
Bluetooth result.