Struct bluez_async::BluetoothSession[][src]

pub struct BluetoothSession { /* fields omitted */ }

A connection to the Bluetooth daemon. This can be cheaply cloned and passed around to be used from different places. It is the main entry point to the library.

Implementations

impl BluetoothSession[src]

pub async fn new(
) -> Result<(impl Future<Output = Result<(), SpawnError>>, Self), BluetoothError>
[src]

Establish a new D-Bus connection to communicate with BlueZ.

Returns a tuple of (join handle, Self). If the join handle ever completes then you’re in trouble and should probably restart the process.

pub async fn start_discovery(&self) -> Result<(), BluetoothError>[src]

Power on all Bluetooth adapters, remove any discovery filter, and then start scanning for devices.

This is equivalent to calling start_discovery_with_filter(&DiscoveryFilter::default()).

pub async fn start_discovery_on_adapter(
    &self,
    adapter: &AdapterId
) -> Result<(), BluetoothError>
[src]

Power on the given Bluetooth adapter, remove any discovery filter, and then start scanning for devices.

This is equivalent to calling start_discovery_on_adapter_with_filter(adapter, &DiscoveryFilter::default()).

pub async fn start_discovery_with_filter(
    &self,
    discovery_filter: &DiscoveryFilter
) -> Result<(), BluetoothError>
[src]

Power on all Bluetooth adapters, set the given discovery filter, and then start scanning for devices.

Note that BlueZ combines discovery filters from all clients and sends events matching any filter to all clients, so you may receive unexpected discovery events if there are other clients on the system using Bluetooth as well.

In most common cases, DiscoveryFilter::default() is fine.

pub async fn start_discovery_on_adapter_with_filter(
    &self,
    adapter_id: &AdapterId,
    discovery_filter: &DiscoveryFilter
) -> Result<(), BluetoothError>
[src]

Power on the given Bluetooth adapter, set the given discovery filter, and then start scanning for devices.

Note that BlueZ combines discovery filters from all clients and sends events matching any filter to all clients, so you may receive unexpected discovery events if there are other clients on the system using Bluetooth as well.

In most common cases, DiscoveryFilter::default() is fine.

pub async fn stop_discovery(&self) -> Result<(), BluetoothError>[src]

Stop scanning for devices on all Bluetooth adapters.

pub async fn stop_discovery_on_adapter(
    &self,
    adapter_id: &AdapterId
) -> Result<(), BluetoothError>
[src]

Stop scanning for devices on the given Bluetooth adapters.

pub async fn get_adapters(&self) -> Result<Vec<AdapterInfo>, BluetoothError>[src]

Get a list of all Bluetooth adapters on the system.

pub async fn get_devices(&self) -> Result<Vec<DeviceInfo>, BluetoothError>[src]

Get a list of all Bluetooth devices which have been discovered so far.

pub async fn get_devices_on_adapter(
    &self,
    adapter: &AdapterId
) -> Result<Vec<DeviceInfo>, BluetoothError>
[src]

Get a list of all Bluetooth devices which have been discovered so far on a given adapter.

pub async fn get_services(
    &self,
    device: &DeviceId
) -> Result<Vec<ServiceInfo>, BluetoothError>
[src]

Get a list of all GATT services which the given Bluetooth device offers.

Note that this won’t be filled in until the device is connected.

pub async fn get_characteristics(
    &self,
    service: &ServiceId
) -> Result<Vec<CharacteristicInfo>, BluetoothError>
[src]

Get a list of all characteristics on the given GATT service.

pub async fn get_descriptors(
    &self,
    characteristic: &CharacteristicId
) -> Result<Vec<DescriptorInfo>, BluetoothError>
[src]

Get a list of all descriptors on the given GATT characteristic.

pub async fn get_service_by_uuid(
    &self,
    device: &DeviceId,
    uuid: Uuid
) -> Result<ServiceInfo, BluetoothError>
[src]

Find a GATT service with the given UUID advertised by the given device, if any.

Note that this generally won’t work until the device is connected.

pub async fn get_characteristic_by_uuid(
    &self,
    service: &ServiceId,
    uuid: Uuid
) -> Result<CharacteristicInfo, BluetoothError>
[src]

Find a characteristic with the given UUID as part of the given GATT service advertised by a device, if there is any.

pub async fn get_service_characteristic_by_uuid(
    &self,
    device: &DeviceId,
    service_uuid: Uuid,
    characteristic_uuid: Uuid
) -> Result<CharacteristicInfo, BluetoothError>
[src]

Convenience method to get a GATT charactacteristic with the given UUID advertised by a device as part of the given service.

This is equivalent to calling get_service_by_uuid and then get_characteristic_by_uuid.

pub async fn get_device_info(
    &self,
    id: &DeviceId
) -> Result<DeviceInfo, BluetoothError>
[src]

Get information about the given Bluetooth device.

pub async fn get_adapter_info(
    &self,
    id: &AdapterId
) -> Result<AdapterInfo, BluetoothError>
[src]

Get information about the given Bluetooth adapter.

pub async fn get_service_info(
    &self,
    id: &ServiceId
) -> Result<ServiceInfo, BluetoothError>
[src]

Get information about the given GATT service.

pub async fn get_characteristic_info(
    &self,
    id: &CharacteristicId
) -> Result<CharacteristicInfo, BluetoothError>
[src]

Get information about the given GATT characteristic.

pub async fn get_descriptor_info(
    &self,
    id: &DescriptorId
) -> Result<DescriptorInfo, BluetoothError>
[src]

Get information about the given GATT descriptor.

pub async fn connect(&self, id: &DeviceId) -> Result<(), BluetoothError>[src]

Connect to the given Bluetooth device.

pub async fn disconnect(&self, id: &DeviceId) -> Result<(), BluetoothError>[src]

Disconnect from the given Bluetooth device.

pub async fn read_characteristic_value(
    &self,
    id: &CharacteristicId
) -> Result<Vec<u8>, BluetoothError>
[src]

Read the value of the given GATT characteristic.

This is equivalent to calling read_characteristic_value_with_offset(0).

pub async fn read_characteristic_value_with_offset(
    &self,
    id: &CharacteristicId,
    offset: usize
) -> Result<Vec<u8>, BluetoothError>
[src]

Read the value of the given GATT characteristic, starting from the given offset.

pub async fn write_characteristic_value(
    &self,
    id: &CharacteristicId,
    value: impl Into<Vec<u8>>
) -> Result<(), BluetoothError>
[src]

Write the given value to the given GATT characteristic, with default options.

This is equivalent to calling write_characteristic_value_with_options(WriteOptions::default()).

pub async fn write_characteristic_value_with_options(
    &self,
    id: &CharacteristicId,
    value: impl Into<Vec<u8>>,
    options: WriteOptions
) -> Result<(), BluetoothError>
[src]

Write the given value to the given GATT characteristic, with the given options.

pub async fn read_descriptor_value(
    &self,
    id: &DescriptorId
) -> Result<Vec<u8>, BluetoothError>
[src]

Read the value of the given GATT descriptor.

This is equivalent to calling read_descriptor_value_with_offset(0).

pub async fn read_descriptor_value_with_offset(
    &self,
    id: &DescriptorId,
    offset: usize
) -> Result<Vec<u8>, BluetoothError>
[src]

Read the value of the given GATT descriptor, starting from the given offset.

pub async fn write_descriptor_value(
    &self,
    id: &DescriptorId,
    value: impl Into<Vec<u8>>
) -> Result<(), BluetoothError>
[src]

Write the given value to the given GATT descriptor.

This is equivalent to calling write_descriptor_value_with_offset(0).

pub async fn write_descriptor_value_with_offset(
    &self,
    id: &DescriptorId,
    value: impl Into<Vec<u8>>,
    offset: usize
) -> Result<(), BluetoothError>
[src]

Write the given value to the given GATT descriptor, starting from the given offset.

pub async fn start_notify(
    &self,
    id: &CharacteristicId
) -> Result<(), BluetoothError>
[src]

Start notifications on the given GATT characteristic.

pub async fn stop_notify(
    &self,
    id: &CharacteristicId
) -> Result<(), BluetoothError>
[src]

Stop notifications on the given GATT characteristic.

pub async fn event_stream(
    &self
) -> Result<impl Stream<Item = BluetoothEvent>, BluetoothError>
[src]

Get a stream of events for all devices.

pub async fn device_event_stream(
    &self,
    device: &DeviceId
) -> Result<impl Stream<Item = BluetoothEvent>, BluetoothError>
[src]

Get a stream of events for a particular device. This includes events for all its characteristics.

pub async fn characteristic_event_stream(
    &self,
    characteristic: &CharacteristicId
) -> Result<impl Stream<Item = BluetoothEvent>, BluetoothError>
[src]

Get a stream of events for a particular characteristic of a device.

Trait Implementations

impl Clone for BluetoothSession[src]

impl Debug for BluetoothSession[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.