[][src]Enum core_bluetooth::central::CentralEvent

#[non_exhaustive]pub enum CentralEvent {
    CharacteristicsDiscovered {
        peripheral: Peripheral,
        service: Service,
        characteristics: Result<Vec<Characteristic>, Error>,
    },
    CharacteristicValue {
        peripheral: Peripheral,
        characteristic: Characteristic,
        value: Result<Vec<u8>, Error>,
    },
    DescriptorsDiscovered {
        peripheral: Peripheral,
        characteristic: Characteristic,
        descriptors: Result<Vec<Descriptor>, Error>,
    },
    DescriptorValue {
        peripheral: Peripheral,
        descriptor: Descriptor,
        value: Result<Vec<u8>, Error>,
    },
    GetMaxWriteLenResult {
        max_write_len: MaxWriteLen,
        tag: Option<Tag>,
    },
    GetPeripheralsResult {
        peripherals: Vec<Peripheral>,
        tag: Option<Tag>,
    },
    GetPeripheralsWithServicesResult {
        peripherals: Vec<Peripheral>,
        tag: Option<Tag>,
    },
    IncludedServicesDiscovered {
        peripheral: Peripheral,
        service: Service,
        included_services: Result<Vec<Service>, Error>,
    },
    ManagerStateChanged {
        new_state: ManagerState,
    },
    PeripheralConnected {
        peripheral: Peripheral,
    },
    PeripheralConnectFailed {
        peripheral: Peripheral,
        error: Option<Error>,
    },
    PeripheralDisconnected {
        peripheral: Peripheral,
        error: Option<Error>,
    },
    PeripheralDiscovered {
        peripheral: Peripheral,
        advertisement_data: AdvertisementData,
        rssi: i32,
    },
    PeripheralIsReadyToWriteWithoutResponse {
        peripheral: Peripheral,
    },
    PeripheralNameChanged {
        peripheral: Peripheral,
        new_name: Option<String>,
    },
    ReadRssiResult {
        peripheral: Peripheral,
        rssi: Result<i32, Error>,
    },
    ServicesChanged {
        peripheral: Peripheral,
        services: Vec<Service>,
        invalidated_services: Vec<Service>,
    },
    ServicesDiscovered {
        peripheral: Peripheral,
        services: Result<Vec<Service>, Error>,
    },
    SubscriptionChangeResult {
        peripheral: Peripheral,
        characteristic: Characteristic,
        result: Result<(), Error>,
    },
    WriteCharacteristicResult {
        peripheral: Peripheral,
        characteristic: Characteristic,
        result: Result<(), Error>,
    },
    WriteDescriptorResult {
        peripheral: Peripheral,
        descriptor: Descriptor,
        result: Result<(), Error>,
    },
}

Events that a central manager sends about changes in its state or state of its local or remote components.

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
CharacteristicsDiscovered

Indicates the peripheral discovered characteristics for a service.

This event is triggered in response to the discover_characteristics method call.

Fields of CharacteristicsDiscovered

peripheral: Peripheral

The peripheral providing this information.

service: Service

The service to which the characteristics belong.

characteristics: Result<Vec<Characteristic>, Error>

The discovered characteristics or error if the call failed.

CharacteristicValue

Indicates that retrieving the specified characteristic’s value completed, or that the characteristic’s value changed.

This event is triggered in response to the read_characteristic method call. A peripheral also invokes this method to notify about a change to the value of the characteristic for which notifications were previously enabled by calling subscribe method.

Fields of CharacteristicValue

peripheral: Peripheral

The peripheral providing this information.

characteristic: Characteristic

The characteristic containing the value.

value: Result<Vec<u8>, Error>

The value or error if the call failed.

DescriptorsDiscovered

Indicates the peripheral discovered descriptors for a characteristic.

This event is triggered in response to the discover_descriptors method call.

Fields of DescriptorsDiscovered

peripheral: Peripheral

The peripheral providing this information.

characteristic: Characteristic

The characteristic to which the descriptors belong.

descriptors: Result<Vec<Descriptor>, Error>

The discovered descriptors or error if the call failed.

DescriptorValue

Indicates that retrieving the specified characteristic descriptor’s value completed.

This event is triggered in response to the read_descriptor method call.

Fields of DescriptorValue

peripheral: Peripheral

The peripheral providing this information.

descriptor: Descriptor

The descriptor containing the value.

value: Result<Vec<u8>, Error>

The value or error if the call failed.

GetMaxWriteLenResult

Indicates that the get_max_write_len method call completed.

Fields of GetMaxWriteLenResult

max_write_len: MaxWriteLen

Maximum write length information.

tag: Option<Tag>

Optional tag specified by get_max_write_len_tagged.

GetPeripheralsResult

Indicates that the get_peripherals method call completed.

Fields of GetPeripheralsResult

peripherals: Vec<Peripheral>

A list of peripherals that the central manager is able to match to the provided identifiers.

tag: Option<Tag>

Optional tag specified by get_peripherals_tagged.

GetPeripheralsWithServicesResult

Indicates that the get_peripherals_with_services method call completed.

Fields of GetPeripheralsWithServicesResult

peripherals: Vec<Peripheral>

A list of the peripherals that are currently connected to the system and that contain any of the services specified in the service_uuids parameter. This list can include peripherals connected by other apps. You need to connect them before use.

tag: Option<Tag>

Optional tag specified by get_peripherals_with_services_tagged.

IncludedServicesDiscovered

Indicates that discovery of included services within the provided service completed.

Fields of IncludedServicesDiscovered

peripheral: Peripheral

The peripheral providing this information.

service: Service

The service containing the discovered included services.

included_services: Result<Vec<Service>, Error>

The discovered included services or error if the call failed.

This event is triggered in response to the discover_included_services method call.

ManagerStateChanged

Indicates the central manager’s state updated.

You handle this event to ensure that the central device supports Bluetooth low energy and that it’s available to use. You should issue commands to the central manager only when the central manager’s state indicates it’s powered on. A state with a value lower than PoweredOn implies that scanning has stopped, which in turn disconnects any previously-connected peripherals. If the state moves below PoweredOff, all Peripheral objects obtained from this central manager become invalid; you must retrieve or discover these peripherals again. For a complete list of possible states, see the ManagerState enum.

Fields of ManagerStateChanged

new_state: ManagerState

Current state of the central manager.

PeripheralConnected

Indicates the central manager connected to the peripheral.

This event is triggered when a call to connect method succeeds.

Fields of PeripheralConnected

peripheral: Peripheral

The now-connected peripheral.

PeripheralConnectFailed

Indicates the central manager failed to create a connection with the peripheral.

This event is triggered when connection initiated with the connect method fails to complete. Because connection attempts don’t time out, a failed connection usually indicates a transient issue, in which case you may attempt connecting to the peripheral again.

Fields of PeripheralConnectFailed

peripheral: Peripheral

The peripheral that failed to connect.

error: Option<Error>

The cause of the failure, or None if no error occurred.

PeripheralDisconnected

Indicates the central manager disconnected from a peripheral.

This event is triggered when disconnecting a peripheral previously connected with the connect method. The error contains the reason for the disconnection, unless the disconnect resulted from a call to disconnect. After this event, no other event will be received for the peripheral.

All services, characteristics, and characteristic descriptors of the peripheral become invalidated after it disconnects.

Fields of PeripheralDisconnected

peripheral: Peripheral

The now-disconnected peripheral.

error: Option<Error>

The cause of the failure, or None if no error occurred.

PeripheralDiscovered

Indicates the central manager discovered a peripheral while scanning for devices.

Fields of PeripheralDiscovered

peripheral: Peripheral

The discovered peripheral.

advertisement_data: AdvertisementData

Peripheral's advertisment data.

rssi: i32

The current received signal strength indicator (RSSI) of the peripheral, in decibels.

Use the RSSI data to determine the proximity of a discoverable peripheral device, and whether you want to connect to it automatically.

PeripheralIsReadyToWriteWithoutResponse

Indicates that a peripheral is again ready to send characteristic updates.

This event is triggered after a failed call to write_characteristic, once peripheral is ready to send characteristic value updates.

Fields of PeripheralIsReadyToWriteWithoutResponse

peripheral: Peripheral

The peripheral providing this update.

PeripheralNameChanged

Indicates that a peripheral’s name changed.

This event is triggered whenever the peripheral’s Generic Access Profile (GAP) device name changes. Since a peripheral device can change its GAP device name, you can handle this event if you need to display the current name of the peripheral device.

Fields of PeripheralNameChanged

peripheral: Peripheral

The peripheral providing this information.

new_name: Option<String>

The peripheral's name.

ReadRssiResult

Indicates that retrieving the value of the peripheral’s current Received Signal Strength Indicator (RSSI) completed.

This event is triggered in response to read_rssi, method call.

Fields of ReadRssiResult

peripheral: Peripheral

The peripheral providing this information.

rssi: Result<i32, Error>

The RSSI, in decibels, or error if the call failed.

ServicesChanged

Indicates that a peripheral’s services changed.

This event is triggered whenever one or more services of a peripheral change. A peripheral’s services have changed if:

  • The peripheral removes a service from its database.
  • The peripheral adds a new service to its database.
  • The peripheral adds back a previously-removed service, but at a different location in the database.

The invalidated_services includes any changed services that you previously discovered; you can no longer use these services. You can use the discover_services method to discover any new services that the peripheral added to its database. Use this same method to find out whether any of the invalidated services that you were using (and want to continue using) now have a different location in the peripheral’s database.

Fields of ServicesChanged

peripheral: Peripheral

The peripheral providing this information.

services: Vec<Service>

A list of services after the change. Note, this doesn't include newly added services.

invalidated_services: Vec<Service>

A list of services invalidated by this change.

ServicesDiscovered

Peripheral service discovery succeeded.

This event is triggered in response to the discover_services method call.

Fields of ServicesDiscovered

peripheral: Peripheral

The peripheral to which the services belong.

services: Result<Vec<Service>, Error>

The discovered services or error if the call failed.

SubscriptionChangeResult

Indicates the peripheral received a request to start or stop providing notifications for a specified characteristic’s value.

This event is triggered in response to the subscribe or unsubscribe methods call.

Fields of SubscriptionChangeResult

peripheral: Peripheral

The peripheral providing this information.

characteristic: Characteristic

The characteristic for which to configure value notifications.

result: Result<(), Error>

Whether the subscription change succeeded.

WriteCharacteristicResult

Characteristic value write completed.

This event is triggered in response to the write_characteristic method called with WithResponse as the kind parameter.

Fields of WriteCharacteristicResult

peripheral: Peripheral

The peripheral providing this information.

characteristic: Characteristic

The target characteristic.

result: Result<(), Error>

Whether the write succeeded.

WriteDescriptorResult

Characteristic descriptor's value write completed.

This event is triggered in response to the write_descriptor method call.

Fields of WriteDescriptorResult

peripheral: Peripheral

The peripheral providing this information.

descriptor: Descriptor

The target descriptor.

result: Result<(), Error>

Whether the write succeeded.

Trait Implementations

impl Debug for CentralEvent[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, 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.