pub struct Receiver { /* private fields */ }Expand description
Implements the Bolt receiver.
Implementations§
Source§impl Receiver
impl Receiver
Sourcepub fn new(chan: Arc<HidppChannel>) -> Result<Self, ReceiverError>
pub fn new(chan: Arc<HidppChannel>) -> Result<Self, ReceiverError>
Tries to initialize a new Receiver from a raw HID++ channel.
If no receiver could be found, or if the vendor and product IDs don’t
match the ones of any known Bolt receiver, this function will return
ReceiverError::UnknownReceiver.
Sourcepub async fn get_notification_state(
&self,
) -> Result<NotificationState, ReceiverError>
pub async fn get_notification_state( &self, ) -> Result<NotificationState, ReceiverError>
Queries the current information about what notifications are enabled.
Sourcepub async fn set_notification_state(
&self,
state: NotificationState,
) -> Result<(), ReceiverError>
pub async fn set_notification_state( &self, state: NotificationState, ) -> Result<(), ReceiverError>
Configures what notifications are enabled and thus reported by the receiver.
Sourcepub async fn count_pairings(&self) -> Result<u8, ReceiverError>
pub async fn count_pairings(&self) -> Result<u8, ReceiverError>
Counts the amount of devices currently paired to this receiver. The devices don’t have to be online to be included here as pairings are persistent.
Sourcepub async fn trigger_device_arrival(&self) -> Result<(), ReceiverError>
pub async fn trigger_device_arrival(&self) -> Result<(), ReceiverError>
Triggers device arrival notifications for all devices currently connected to the receiver. This is useful for device enumeration.
Check Self::get_notification_state first to make sure that
NotificationState::wireless_notifications is enabled.
Sourcepub async fn collect_paired_devices(
&self,
) -> Result<Vec<DeviceConnection>, ReceiverError>
pub async fn collect_paired_devices( &self, ) -> Result<Vec<DeviceConnection>, ReceiverError>
Collects information about all paired devices by calling
Self::trigger_device_arrival and collecting incoming
Event::DeviceConnection events.
Check Self::get_notification_state first to make sure that
NotificationState::wireless_notifications is enabled.
Sourcepub async fn get_unique_id(&self) -> Result<String, ReceiverError>
pub async fn get_unique_id(&self) -> Result<String, ReceiverError>
Retrieves the unique ID of the receiver. This is not the same as the serial number.
Sourcepub async fn get_device_pairing_information(
&self,
device_index: u8,
) -> Result<DevicePairingInformation, ReceiverError>
pub async fn get_device_pairing_information( &self, device_index: u8, ) -> Result<DevicePairingInformation, ReceiverError>
Provides the pairing information of a specific paired device by its index.
Sourcepub async fn get_device_codename(
&self,
device_index: u8,
) -> Result<String, ReceiverError>
pub async fn get_device_codename( &self, device_index: u8, ) -> Result<String, ReceiverError>
Provides the codename of a specific paired device by its index.
Sourcepub async fn unpair_device(&self, device_index: u8) -> Result<(), ReceiverError>
pub async fn unpair_device(&self, device_index: u8) -> Result<(), ReceiverError>
Unpairs a device from the receiver by its index.
Sourcepub async fn pair_device(
&self,
slot: u8,
address: [u8; 6],
authentication: u8,
entropy: u8,
) -> Result<(), ReceiverError>
pub async fn pair_device( &self, slot: u8, address: [u8; 6], authentication: u8, entropy: u8, ) -> Result<(), ReceiverError>
Starts the pairing process for a new device.
The required address and authentication values are usually
discovered from the Event::DeviceDiscoveryDeviceDetails event which
is emitted regularly when actively discovering available devices
(Self::discover_devices).
entropy specifies how complex the authentication passkey should be.
For mice, this defines the amount of keypresses (left or right) the user
has to perform. Not all values seem to be supported.
Sourcepub async fn discover_devices(
&self,
timeout: Option<u8>,
) -> Result<(), ReceiverError>
pub async fn discover_devices( &self, timeout: Option<u8>, ) -> Result<(), ReceiverError>
Starts device discovery for timeout seconds (None = default, seems
to be 30s). The maximum supported value is 60s.
While device discovery is enabled,
Event::DeviceDiscoveryDeviceDetails and
Event::DeviceDiscoveryDeviceName events are emitted for every
discovered device.
Sourcepub async fn cancel_device_discovery(&self) -> Result<(), ReceiverError>
pub async fn cancel_device_discovery(&self) -> Result<(), ReceiverError>
Cancels the device discovery process.