[][src]Struct core_bluetooth::central::peripheral::Peripheral

pub struct Peripheral { /* fields omitted */ }

A remote peripheral device.

The Peripheral object represents remote peripheral devices that your app discovers with a central manager. Peripherals use universally unique identifiers (UUIDs) to identify themselves. Peripherals may contain one or more services or provide useful information about their connected signal strength.

You use this object to discover, explore, and interact with the services available on a remote peripheral that supports Bluetooth low energy. A service encapsulates the way part of the device behaves. For example, one service of a heart rate monitor may be to expose heart rate data from a sensor. Services themselves contain of characteristics or included services (references to other services). Characteristics provide further details about a peripheral’s service. For example, the heart rate service may contain multiple characteristics. One characteristic could describe the intended body location of the device’s heart rate sensor, and another characteristic could transmit the heart rate measurement data. Finally, characteristics contain any number of descriptors that provide more information about the characteristic’s value, such as a human-readable description and a way to format the value.

Implementations

impl Peripheral[src]

pub fn id(&self) -> Uuid[src]

Peripheral identifier.

pub fn discover_services(&self)[src]

Discovers all available services of the peripheral.

See discover_services_with_uuids.

pub fn discover_services_with_uuids(&self, uuids: &[Uuid])[src]

Discovers peripheral's services with the specified uuids.

When the peripheral discovers one or more services, it triggers ServicesDiscovered event.

pub fn discover_included_services(&self, service: &Service)[src]

Discovers all available included services of a previously-discovered service.

See discover_included_services_with_uuids method.

pub fn discover_included_services_with_uuids(
    &self,
    service: &Service,
    uuids: &[Uuid]
)
[src]

Discovers the specified included services of a previously-discovered service.

When the peripheral discovers one or more included services, it triggers IncludedServicesDiscovered event.

pub fn discover_characteristics(&self, service: &Service)[src]

Discovers all available characteristics of a service.

See discover_characteristics_with_uuids method.

pub fn discover_characteristics_with_uuids(
    &self,
    service: &Service,
    uuids: &[Uuid]
)
[src]

Discovers the specified characteristics of a service.

When the peripheral discovers one or more characteristics, it triggers CharacteristicsDiscovered event.

pub fn discover_descriptors(&self, characteristic: &Characteristic)[src]

Discovers the descriptors of a characteristic.

When the peripheral discovers one or more descriptors, it triggers DescriptorsDiscovered event.

pub fn subscribe(&self, characteristic: &Characteristic)[src]

Subscribes to notifications or indications of the value of a specified characteristic.

After calling this method the peripheral triggers SubscriptionChangeResult event to inform whether the action succeeded. If successful, the peripheral then triggers CharacteristicValue event whenever the characteristic value changes.

Because the peripheral chooses when it sends an update, your app should prepare to handle them as long as subscription remains active. If the specified characteristic’s configuration allows both notifications and indications, calling this method enables notifications only. You can disable notifications and indications for a characteristic’s value by calling unsubscribe method.

pub fn unsubscribe(&self, characteristic: &Characteristic)[src]

Cancel subscription for characteristic value created by subscribe method.

pub fn read_characteristic(&self, characteristic: &Characteristic)[src]

Retrieves the value of a specified characteristic.

After calling this method the peripheral triggers CharacteristicValue event.

Not all characteristics have a readable value. You can determine whether a characteristic’s value is readable by accessing the relevant properties of the Properties object.

pub fn write_characteristic(
    &self,
    characteristic: &Characteristic,
    value: &[u8],
    kind: WriteKind
)
[src]

Writes the value of a characteristic.

When you call this method to write the value of a characteristic, the peripheral triggers WriteCharacteristicResult event, but only if the WithResponse write kind is requested.

If you specify the write kind as WithoutResponse, Core Bluetooth attempts to write the value but doesn’t guarantee success. If the write doesn’t succeed in this case, you aren’t notified and you don’t receive an error indicating the cause of the failure.

Examine can_write and can_write_without_response properties to determine which kinds of writes you can perform.

pub fn read_descriptor(&self, descriptor: &Descriptor)[src]

Retrieves the value of a specified characteristic descriptor.

After calling this method the peripheral triggers DescriptorValue event.

pub fn write_descriptor(&self, descriptor: &Descriptor, value: &[u8])[src]

Writes the value of a characteristic descriptor.

When you call this method to write the value of a characteristic, the peripheral triggers WriteDescriptorResult event.

pub fn read_rssi(&self)[src]

Retrieves the current RSSI value for the peripheral while connected to the central manager.

After calling this method the peripheral triggers ReadRssiResult event.

pub fn get_max_write_len(&self)[src]

Queries for maximum length of data that can be written to characteristic in a single request. The result is returned as GetMaxWriteLenResult event.

pub fn get_max_write_len_tagged(&self, tag: Tag)[src]

Allows tagging an asynchronous get_max_write_len call with arbitrary tag.

Trait Implementations

impl Clone for Peripheral[src]

impl Debug for Peripheral[src]

impl Eq for Peripheral[src]

impl Hash for Peripheral[src]

impl PartialEq<Peripheral> for Peripheral[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.