[][src]Struct bluez_async::BluetoothSession

pub struct BluetoothSession {
    pub connection: Arc<SyncConnection>,
}

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.

Fields

connection: Arc<SyncConnection>

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 and start scanning for devices.

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_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_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 Bluetooth device with the given D-Bus object path.

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

Disconnect from the Bluetooth device with the given D-Bus object path.

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

Read the value of the given GATT characteristic.

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.

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

Read the value of the given GATT descriptor.

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.

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.