BluetoothLEDevice 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public ref class BluetoothLEDevice sealed : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class BluetoothLEDevice final : IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class BluetoothLEDevice : System.IDisposable
Public NotInheritable Class BluetoothLEDevice
Implements IDisposable
- 继承
- 属性
- 实现
Windows 要求
| 要求 | 说明 |
|---|---|
| 设备系列 |
Windows 10 (在 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 中引入)
|
| API contract |
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)
|
| 应用功能 |
bluetooth
|
注解
版本历史记录
| Windows 版本 | SDK 版本 | 已添加值 |
|---|---|---|
| 1511 | 10586 | 外观 |
| 1511 | 10586 | BluetoothAddressType |
| 1511 | 10586 | DeviceInformation |
| 1511 | 10586 | FromBluetoothAddressAsync(UInt64,BluetoothAddressType) |
| 1511 | 10586 | GetDeviceSelectorFromAppearance |
| 1511 | 10586 | GetDeviceSelectorFromBluetoothAddress(UInt64) |
| 1511 | 10586 | GetDeviceSelectorFromBluetoothAddress(UInt64,BluetoothAddressType) |
| 1511 | 10586 | GetDeviceSelectorFromConnectionStatus |
| 1511 | 10586 | GetDeviceSelectorFromDeviceName |
| 1511 | 10586 | GetDeviceSelectorFromPairingState |
| 1703 | 15063 | DeviceAccessInformation |
| 1703 | 15063 | GetGattServicesAsync |
| 1703 | 15063 | GetGattServicesAsync(BluetoothCacheMode) |
| 1703 | 15063 | GetGattServicesForUuidAsync(Guid) |
| 1703 | 15063 | GetGattServicesForUuidAsync(Guid,BluetoothCacheMode) |
| 1703 | 15063 | RequestAccessAsync |
| 1709 | 16299 | BluetoothDeviceId |
| 1803 | 17134 | WasSecureConnectionUsedForPairing |
属性
| 名称 | 说明 |
|---|---|
| Appearance |
获取蓝牙 LE 设备的 BluetoothLEAppearance 对象。 |
| BluetoothAddress |
获取设备地址。 |
| BluetoothAddressType |
获取蓝牙 LE 设备的地址类型。 |
| BluetoothDeviceId |
获取蓝牙设备 ID。 |
| ConnectionStatus |
获取设备的连接状态。 |
| DeviceAccessInformation |
获取 DeviceAccessInformation。 |
| DeviceId |
获取设备 ID。 |
| DeviceInformation |
获取蓝牙 LE 设备的设备信息。 |
| GattServices |
获取设备支持的 GATT 服务的只读列表。 重要 GattServices API 已弃用,在将来的 Windows 版本中可能不可用。 请改用 GetGattServicesAsync。 |
| Name |
获取蓝牙 LE 设备的名称。 |
| WasSecureConnectionUsedForPairing |
获取一个布尔值,该值指示是否使用安全连接配对蓝牙LEDevice。 |
方法
| 名称 | 说明 |
|---|---|
| Close() |
关闭此蓝牙 LE 设备。 如果这是具有连接的唯一应用,则这可能会关闭与设备的连接。 |
| Dispose() |
执行与释放、释放或重置非托管资源关联的应用程序定义任务。 |
| FromBluetoothAddressAsync(UInt64, BluetoothAddressType) |
返回一个 BluetoothLEDevice 对象,该对象代表具有给定地址和地址类型的对等设备。 请参阅 备注(在本成员主题中)。 |
| FromBluetoothAddressAsync(UInt64) |
返回一个 BluetoothLEDevice 对象,该对象代表具有给定地址的对等蓝牙 LE 设备。 请参阅 备注(在本成员主题中)。 |
| FromIdAsync(String) |
返回给定 ID 的 BluetoothLEDevice 对象。请参阅成员主题中的 备注。 |
| GetConnectionParameters() |
检索远程设备的连接参数。 如果多个应用或其他系统方案还请求这些参数,则系统会根据系统优先级自动合并参数(兼容)。 注意 设备未连接时,连接参数无效(全部为零)。 |
| GetConnectionPhy() |
检索有关蓝牙 LE 物理层(PHY)的信息。 注意 设备未连接时,连接 PHY 无效(全部为 false) |
| GetDeviceSelector() |
获取用于标识所有蓝牙低能(LE)设备的高级查询语法 (AQS) 字符串。 此字符串传递给 FindAllAsync 或 CreateWatcher 方法,以获取蓝牙 LE 设备列表。 |
| GetDeviceSelectorFromAppearance(BluetoothLEAppearance) |
从 BluetoothLEAppearance 对象创建高级查询语法 (AQS) 筛选器字符串。 AQS 字符串将传递到 CreateWatcher 方法,以返回具有指定外观的 DeviceInformation 对象的集合。 |
| GetDeviceSelectorFromBluetoothAddress(UInt64, BluetoothAddressType) |
从表示蓝牙 LE 设备的 64 位地址和地址类型创建高级查询语法 (AQS) 筛选器字符串。 AQS 字符串将传递到 CreateWatcher 方法中。 |
| GetDeviceSelectorFromBluetoothAddress(UInt64) |
从表示蓝牙 LE 设备的 64 位地址创建高级查询语法 (AQS) 筛选器字符串。 AQS 字符串将传递到 CreateWatcher 方法中,以返回 DeviceInformation 对象的集合。 |
| GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus) |
创建高级查询语法 (AQS) 筛选器字符串,该字符串包含具有指示的蓝牙 LE 设备的查询,BluetoothConnectionStatus。 AQS 字符串将传递到 CreateWatcher 方法中,以返回具有指示蓝牙连接状态的 DeviceInformation 对象的集合。 |
| GetDeviceSelectorFromDeviceName(String) |
创建高级查询语法 (AQS) 筛选器字符串,其中包含蓝牙 LE 设备名称的查询。 AQS 字符串将传递到 CreateWatcher 方法中,以返回包含指定蓝牙 LE 设备名称的 DeviceInformation 对象的集合。 |
| GetDeviceSelectorFromPairingState(Boolean) |
创建高级查询语法 (AQS) 筛选器字符串,其中包含对或未配对的蓝牙 LE 设备的查询。 AQS 字符串将传递到 CreateWatcher 方法中,以返回 DeviceInformation 对象的集合。 |
| GetGattService(Guid) |
返回具有给定服务 ID 的 GATT 服务。 重要 GetGattService API 已弃用,在将来的 Windows 版本中可能不可用。 请改用 GetGattServicesAsync。 |
| GetGattServicesAsync() |
获取此蓝牙 LowEnergy 设备的 GattDeviceServices。 |
| GetGattServicesAsync(BluetoothCacheMode) |
返回具有指定缓存模式的此蓝牙 LowEnergy 设备的 GattDeviceServices。 |
| GetGattServicesForUuidAsync(Guid, BluetoothCacheMode) |
返回具有指定 UUID 的蓝牙 LowEnergy 设备的 GattDeviceServices。 |
| GetGattServicesForUuidAsync(Guid) |
返回具有指定 UUID 的蓝牙 LowEnergy 设备的 GattDeviceServices。 |
| RequestAccessAsync() |
请求访问蓝牙 LowEnergy 设备。 |
| RequestPreferredConnectionParameters(BluetoothLEPreferredConnectionParameters) |
检索指定蓝牙 LE 首选连接参数对象的蓝牙 LE 首选连接参数对象。 |
事件
| 名称 | 说明 |
|---|---|
| ConnectionParametersChanged |
设备当前连接参数发生更改时引发的事件。 只有在与设备建立连接后,这些参数才会更新。 |
| ConnectionPhyChanged |
设备当前 PHY 更改时引发的事件。 只有在与设备建立连接后,PHY 才会更新。 |
| ConnectionStatusChanged |
当设备的连接状态已更改时发生。 |
| GattServicesChanged |
当设备支持的 GATT 服务列表发生更改时引发。 |
| NameChanged |
当设备名称发生更改时发生。 |