Struct GattClient

Source
pub struct GattClient<'reference, T: Controller, P: PacketPool, const MAX_SERVICES: usize> { /* private fields */ }
Expand description

A GATT client capable of using the GATT protocol.

Implementations§

Source§

impl<'reference, C: Controller, P: PacketPool, const MAX_SERVICES: usize> GattClient<'reference, C, P, MAX_SERVICES>

Source

pub async fn new( stack: &'reference Stack<'reference, C, P>, connection: &Connection<'reference, P>, ) -> Result<GattClient<'reference, C, P, MAX_SERVICES>, BleHostError<C::Error>>

Creates a GATT client capable of processing the GATT protocol using the provided table of attributes.

Source

pub async fn services_by_uuid( &self, uuid: &Uuid, ) -> Result<Vec<ServiceHandle, MAX_SERVICES>, BleHostError<C::Error>>

Discover primary services associated with a UUID.

Source

pub async fn characteristic_by_uuid<T: AsGatt>( &self, service: &ServiceHandle, uuid: &Uuid, ) -> Result<Characteristic<T>, BleHostError<C::Error>>

Discover characteristics in a given service using a UUID.

Source

pub async fn read_characteristic<T: AsGatt>( &self, characteristic: &Characteristic<T>, dest: &mut [u8], ) -> Result<usize, BleHostError<C::Error>>

Read a characteristic described by a handle.

The number of bytes copied into the provided buffer is returned.

Source

pub async fn read_characteristic_by_uuid( &self, service: &ServiceHandle, uuid: &Uuid, dest: &mut [u8], ) -> Result<usize, BleHostError<C::Error>>

Read a characteristic described by a UUID.

The number of bytes copied into the provided buffer is returned.

Source

pub async fn write_characteristic<T: FromGatt>( &self, handle: &Characteristic<T>, buf: &[u8], ) -> Result<(), BleHostError<C::Error>>

Write to a characteristic described by a handle.

Source

pub async fn write_characteristic_without_response<T: FromGatt>( &self, handle: &Characteristic<T>, buf: &[u8], ) -> Result<(), BleHostError<C::Error>>

Write without waiting for a response to a characteristic described by a handle.

Source

pub async fn subscribe<T: AsGatt>( &self, characteristic: &Characteristic<T>, indication: bool, ) -> Result<NotificationListener<'_, 512>, BleHostError<C::Error>>

Subscribe to indication/notification of a given Characteristic

A listener is returned, which has a next() method

Source

pub async fn unsubscribe<T: AsGatt>( &self, characteristic: &Characteristic<T>, ) -> Result<(), BleHostError<C::Error>>

Unsubscribe from a given Characteristic

Source

pub async fn task(&self) -> Result<(), BleHostError<C::Error>>

Task which handles GATT rx data (needed for notifications to work)

Auto Trait Implementations§

§

impl<'reference, T, P, const MAX_SERVICES: usize> !Freeze for GattClient<'reference, T, P, MAX_SERVICES>

§

impl<'reference, T, P, const MAX_SERVICES: usize> !RefUnwindSafe for GattClient<'reference, T, P, MAX_SERVICES>

§

impl<'reference, T, P, const MAX_SERVICES: usize> !Send for GattClient<'reference, T, P, MAX_SERVICES>

§

impl<'reference, T, P, const MAX_SERVICES: usize> !Sync for GattClient<'reference, T, P, MAX_SERVICES>

§

impl<'reference, T, P, const MAX_SERVICES: usize> Unpin for GattClient<'reference, T, P, MAX_SERVICES>
where <P as PacketPool>::Packet: Unpin,

§

impl<'reference, T, P, const MAX_SERVICES: usize> !UnwindSafe for GattClient<'reference, T, P, MAX_SERVICES>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.