pub async fn find_device(identifier: &str) -> Result<(Adapter, Peripheral)>Expand description
Find a device by its address, identifier or full name.
identifier is trimmed and case is ignored, but otherwise it must match one
of these exactly:
- the device’s
DiscoveredDevice::identifier: the MAC address on Linux and Windows, the CoreBluetooth UUID on macOS; - btleplug’s device ID as
DiscoveredDevice::iddisplays it (hci0/dev_AA_BB_CC_DD_EE_FFon Linux); - the MAC address, with or without colons;
- the whole advertised name. On macOS a name shown as
"Kitchen [Aranet4 1A2B3]"also matchesKitchenorAranet4 1A2B3.
An address or identifier match wins over a name match.
The device is searched for as find_device_with_options describes, with the
default ScanOptions.
§Errors
Error::InvalidConfigifidentifieris empty or blank, before Bluetooth is used.Error::DeviceNotFoundwithDeviceNotFoundReason::NoAdapterif there is no Bluetooth adapter.Error::DeviceNotFoundwithDeviceNotFoundReason::Ambiguousat once if several nearby devices match;DeviceNotFoundReason::NoExactMatchif none matches but some Aranet device names containidentifier, after the first scan that ends that way rather than after the last; andDeviceNotFoundReason::NotFoundotherwise, after the last scan.Error::Bluetoothif the adapter fails.