BluetoothLEDevice.FromBluetoothAddressAsync 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
| 名称 | 说明 |
|---|---|
| FromBluetoothAddressAsync(UInt64) |
返回一个 BluetoothLEDevice 对象,该对象代表具有给定地址的对等蓝牙 LE 设备。 请参阅 “备注 ”(在此成员主题中)。 |
| FromBluetoothAddressAsync(UInt64, BluetoothAddressType) |
返回一个 BluetoothLEDevice 对象,该对象代表具有给定地址和地址类型的对等设备。 请参阅 “备注 ”(在此成员主题中)。 |
FromBluetoothAddressAsync(UInt64)
返回一个 BluetoothLEDevice 对象,该对象代表具有给定地址的对等蓝牙 LE 设备。 请参阅 “备注 ”(在此成员主题中)。
public:
static IAsyncOperation<BluetoothLEDevice ^> ^ FromBluetoothAddressAsync(unsigned long long bluetoothAddress);
/// [Windows.Foundation.Metadata.RemoteAsync]
static IAsyncOperation<BluetoothLEDevice> FromBluetoothAddressAsync(uint64_t const& bluetoothAddress);
/// [Windows.Foundation.Metadata.RemoteAsync]
/// [Windows.Foundation.Metadata.Overload("FromBluetoothAddressAsync")]
static IAsyncOperation<BluetoothLEDevice> FromBluetoothAddressAsync(uint64_t const& bluetoothAddress);
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<BluetoothLEDevice> FromBluetoothAddressAsync(ulong bluetoothAddress);
[Windows.Foundation.Metadata.RemoteAsync]
[Windows.Foundation.Metadata.Overload("FromBluetoothAddressAsync")]
public static IAsyncOperation<BluetoothLEDevice> FromBluetoothAddressAsync(ulong bluetoothAddress);
function fromBluetoothAddressAsync(bluetoothAddress)
Public Shared Function FromBluetoothAddressAsync (bluetoothAddress As ULong) As IAsyncOperation(Of BluetoothLEDevice)
参数
- bluetoothAddress
-
UInt64
unsigned long long
uint64_t
包含对等蓝牙 LE 设备的 64 位地址的 BluetoothAddress 值。
返回
返回表示异步操作的对象。 当该对象完成时,它包含一个 蓝牙LEDevice 对象,该对象表示具有给定地址的对等蓝牙 LE 设备。
Important
如果 FromBluetoothAddressAsync 找不到蓝牙Address 标识的设备,则返回的 BluetoothLEDevice 设置为null。 具体而言,如果设备未配对,并且未在系统缓存中找到该设备。 可以使用 LE 广告观察程序 API(BluetoothLEAdvertisementWatcher)或设备枚举 API(GetDeviceSelectorFromPairingState)填充非配对设备的缓存,以便在 FromBluetoothAddressAsync 成功使用之前扫描蓝牙设备。
- 属性
Windows 要求
| 要求 | 说明 |
|---|---|
| 应用功能 |
bluetooth
|
注解
单独调用此方法创建 BluetoothLEDevice 对象并不(一定)启动连接。 若要启动连接,请将 GattSession.MaintainConnection 设置为true或调用蓝牙LEDevice 上的未缓存服务发现方法,或对设备执行读/写操作。
- 如果 GattSession.MaintainConnection 设置为 true,则系统无限期等待连接,并在设备可用时连接。 应用程序没有任何需要等待的内容,因为 GattSession.MaintainConnection 是一个属性。
- 对于 GATT 中的服务发现和读/写操作,系统等待有限但可变的时间。 从瞬间到几分钟不等。 因素包括堆栈上的流量,以及请求排队的方式。 如果没有其他挂起的请求,并且远程设备无法访问,则系统将在超时之前等待 7 秒。如果有其他挂起的请求,则队列中的每个请求可能需要 7 秒来处理,因此,越往队列的后面,等待的时间越长。
无法取消连接过程。
另请参阅
适用于
FromBluetoothAddressAsync(UInt64, BluetoothAddressType)
返回一个 BluetoothLEDevice 对象,该对象代表具有给定地址和地址类型的对等设备。 请参阅 “备注 ”(在此成员主题中)。
public:
static IAsyncOperation<BluetoothLEDevice ^> ^ FromBluetoothAddressAsync(unsigned long long bluetoothAddress, BluetoothAddressType bluetoothAddressType);
/// [Windows.Foundation.Metadata.Overload("FromBluetoothAddressWithBluetoothAddressTypeAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
static IAsyncOperation<BluetoothLEDevice> FromBluetoothAddressAsync(uint64_t const& bluetoothAddress, BluetoothAddressType const& bluetoothAddressType);
[Windows.Foundation.Metadata.Overload("FromBluetoothAddressWithBluetoothAddressTypeAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<BluetoothLEDevice> FromBluetoothAddressAsync(ulong bluetoothAddress, BluetoothAddressType bluetoothAddressType);
function fromBluetoothAddressAsync(bluetoothAddress, bluetoothAddressType)
Public Shared Function FromBluetoothAddressAsync (bluetoothAddress As ULong, bluetoothAddressType As BluetoothAddressType) As IAsyncOperation(Of BluetoothLEDevice)
参数
- bluetoothAddress
-
UInt64
unsigned long long
uint64_t
包含对等蓝牙 LE 设备的 64 位地址的 BluetoothAddress 值。
- bluetoothAddressType
- BluetoothAddressType
一个 BluetoothAddressType 值,该值包含对等蓝牙 LE 设备的地址类型。
返回
返回表示异步操作的对象。 当该对象完成时,它包含一个 蓝牙LEDevice 对象,该对象表示具有给定地址和地址类型的对等设备。
Important
如果 FromBluetoothAddressAsync 找不到蓝牙Address 标识的设备,则返回的 BluetoothLEDevice 设置为null。 具体而言,如果设备未配对,并且未在系统缓存中找到该设备。 可以使用 LE 广告观察程序 API(BluetoothLEAdvertisementWatcher)或设备枚举 API(GetDeviceSelectorFromPairingState)填充非配对设备的缓存,以便在 FromBluetoothAddressAsync 成功使用之前扫描蓝牙设备。
- 属性
Windows 要求
| 要求 | 说明 |
|---|---|
| 设备系列 |
Windows 10 (在 10.0.10586.0 - for Xbox, see UWP features that aren't yet supported on Xbox 中引入)
|
| API contract |
Windows.Foundation.UniversalApiContract (在 v2.0 中引入)
|
| 应用功能 |
bluetooth
|
注解
单独调用此方法创建 BluetoothLEDevice 对象并不(一定)启动连接。 若要启动连接,请将 GattSession.MaintainConnection 设置为true或调用蓝牙LEDevice 上的未缓存服务发现方法,或对设备执行读/写操作。
- 如果 GattSession.MaintainConnection 设置为 true,则系统无限期等待连接,并在设备可用时连接。 应用程序没有任何需要等待的内容,因为 GattSession.MaintainConnection 是一个属性。
- 对于 GATT 中的服务发现和读/写操作,系统等待有限但可变的时间。 从瞬间到几分钟不等。 因素包括堆栈上的流量,以及请求排队的方式。 如果没有其他挂起的请求,并且远程设备无法访问,则系统将在超时之前等待 7 秒。如果有其他挂起的请求,则队列中的每个请求可能需要 7 秒来处理,因此,越往队列的后面,等待的时间越长。
目前,无法取消连接过程。