Share via


BluetoothLEDevice.FromIdAsync(String) Method

Definition

Returns a BluetoothLEDevice object for the given Id. See Remarks in the member topic.

public:
 static IAsyncOperation<BluetoothLEDevice ^> ^ FromIdAsync(Platform::String ^ deviceId);
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<BluetoothLEDevice> FromIdAsync(winrt::hstring const& deviceId);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<BluetoothLEDevice> FromIdAsync(string deviceId);
function fromIdAsync(deviceId)
Public Shared Function FromIdAsync (deviceId As String) As IAsyncOperation(Of BluetoothLEDevice)

Parameters

deviceId
String

Platform::String

winrt::hstring

The Id of the Bluetooth LE device.

Returns

After the asynchronous operation completes, returns the BluetoothLEDevice object with the given Id.

Attributes

Windows requirements

App capabilities
bluetooth

Remarks

This method must be called from a UI thread.

Creating a BluetoothLEDevice object by calling this method alone doesn't (necessarily) initiate a connection. To initiate a connection, set GattSession.MaintainConnection to true, or call an uncached service discovery method on BluetoothLEDevice, or perform a read/write operation against the device.

  • If GattSession.MaintainConnection is set to true, then the system waits indefinitely for a connection, and it will connect when the device is available. There's nothing for your application to wait on, since GattSession.MaintainConnection is a property.
  • For service discovery and read/write operations in GATT, the system waits a finite but variable time. Anything from instantaneous to a matter of minutes. Factors include the traffic on the stack, and how queued up the request is. If there are no other pending request, and the remote device is unreachable, then the system will wait for 7 seconds before it times out. If there are other pending requests, then each of the requests in the queue can take 7 seconds to process, so the further yours is toward the back of the queue, the longer you'll wait.

Currently, you can't cancel the connection process.

Applies to