Share via


BluetoothDevice 类

定义

表示蓝牙设备。

使用此类的示例应用程序包括 设备枚举和配对示例 以及 蓝牙 RFCOMM 聊天示例

public ref class BluetoothDevice 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 BluetoothDevice 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 BluetoothDevice : System.IDisposable
Public NotInheritable Class BluetoothDevice
Implements IDisposable
继承
Object Platform::Object IInspectable BluetoothDevice
属性
实现

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 DeviceInformation
1511 10586 GetDeviceSelectorFromBluetoothAddress
1511 10586 GetDeviceSelectorFromClassOfDevice
1511 10586 GetDeviceSelectorFromConnectionStatus
1511 10586 GetDeviceSelectorFromDeviceName
1511 10586 GetDeviceSelectorFromPairingState
1607 14393 DeviceAccessInformation
1607 14393 GetRfcommServicesAsync
1607 14393 GetRfcommServicesAsync (BluetoothCacheMode)
1607 14393 GetRfcommServicesForIdAsync (RfcommServiceId)
1607 14393 GetRfcommServicesForIdAsync (RfcommServiceId,BluetoothCacheMode)
1607 14393 RequestAccessAsync
1709 16299 BluetoothDeviceId
1803 17134 WasSecureConnectionUsedForPairing

属性

BluetoothAddress

获取设备地址。

BluetoothDeviceId

获取蓝牙设备 ID。

ClassOfDevice

获取设备的蓝牙设备类信息。

ConnectionStatus

获取设备的连接状态。

DeviceAccessInformation

设备的当前 DeviceAccessInformation 对象。 用于检查和监视对设备的访问更改。

DeviceId

获取来自 Windows.Devices.Enumeration.DeviceInformation.Id 的设备 ID

DeviceInformation

获取蓝牙设备的 DeviceInformation 对象。

HostName

获取设备的 HostName。

Name

获取设备的名称。

RfcommServices

获取设备支持的 RFCOMM 服务的只读列表。

重要

RfcommServices API 已弃用,将来的 Windows 版本中可能不可用。 请改用 GetRfcommServicesAsync

SdpRecords

获取设备的 SDP) 记录 (服务发现协议的只读列表。

WasSecureConnectionUsedForPairing

获取一个布尔值,该值指示 BluetoothDevice 是否使用安全连接进行配对。

方法

Close()

关闭蓝牙设备。

Dispose()

执行与释放或重置非托管资源关联的应用程序定义的任务。

FromBluetoothAddressAsync(UInt64)

返回给定 BluetoothAddressBluetoothDevice 对象。

FromHostNameAsync(HostName)

返回由给定主机名标识的 BluetoothDevice 对象。

FromIdAsync(String)

返回由给定 DeviceId 标识的 BluetoothDevice 对象。

GetDeviceSelector()

获取用于标识此设备的实例 (AQS) 字符串的高级查询语法。 此字符串将传递给 FindAllAsync 或 CreateWatcher 方法。

GetDeviceSelectorFromBluetoothAddress(UInt64)

从表示蓝牙设备的 64 位地址创建 (AQS) 筛选器字符串的高级查询语法。 AQS 字符串将传递到 CreateWatcher 方法,以返回 DeviceInformation 对象的集合。

GetDeviceSelectorFromClassOfDevice(BluetoothClassOfDevice)

BluetoothClassOfDevice 对象 (AQS) 筛选器字符串创建高级查询语法。 AQS 字符串将传递到 CreateWatcher 方法,以返回 DeviceInformation 对象的集合。

GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus)

(AQS) 筛选器字符串创建高级查询语法,该字符串包含针对具有指示的 BluetoothConnectionStatus 的蓝牙设备的查询。 AQS 字符串将传递到 CreateWatcher 方法,以返回具有指示的蓝牙连接状态的 DeviceInformation 对象的集合。

GetDeviceSelectorFromDeviceName(String)

(AQS) 筛选器字符串创建高级查询语法,其中包含蓝牙设备名称的查询。 AQS 字符串将传递到 CreateWatcher 方法,以返回包含指定蓝牙设备名称的 DeviceInformation 对象的集合。

GetDeviceSelectorFromPairingState(Boolean)

(AQS) 筛选器字符串创建高级查询语法,其中包含已配对或未配对的蓝牙设备的查询。 AQS 字符串将传递到 CreateWatcher 方法,以返回 DeviceInformation 对象的集合。

GetRfcommServicesAsync()

检索远程蓝牙设备上的所有 Rfcomm 服务。

GetRfcommServicesAsync(BluetoothCacheMode)

检索远程蓝牙设备上所有缓存的 Rfcomm 服务。

GetRfcommServicesForIdAsync(RfcommServiceId)

检索远程蓝牙设备上与指定的 RfcommServiceId 匹配的所有 Rfcomm 服务

GetRfcommServicesForIdAsync(RfcommServiceId, BluetoothCacheMode)

检索远程蓝牙设备上与指定的 RfcommServiceId 匹配的所有缓存 的 Rfcomm 服务

RequestAccessAsync()

用于请求对蓝牙设备的显式访问。 这会调用设备同意,并且必须在 UI 线程上调用。

事件

ConnectionStatusChanged

当设备的连接状态发生更改时发生。

NameChanged

在设备名称更改时发生。

SdpRecordsChanged

当设备的 SDP 记录列表已更改时发生。

适用于

另请参阅