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

取得藍牙裝置識別碼。

ClassOfDevice

取得裝置的藍牙類別裝置資訊。

ConnectionStatus

取得裝置的線上狀態。

DeviceAccessInformation

裝置目前的 DeviceAccessInformation 物件。 用來檢查和監視裝置的存取變更。

DeviceId

取得來自 Windows.Devices.Enumeration.DeviceInformation.Id 的裝置識別碼

DeviceInformation

取得藍牙裝置的 DeviceInformation 物件。

HostName

取得裝置的 HostName。

Name

取得裝置的名稱。

RfcommServices

取得裝置所支援之 RFCOMM 服務的唯讀清單。

重要

RfcommServices API 已被取代,未來版本的 Windows 可能無法使用。 請改用 GetRfcommServicesAsync

SdpRecords

取得裝置的服務探索通訊協定 (SDP) 記錄的唯讀清單。

WasSecureConnectionUsedForPairing

取得布林值,指出藍牙Device 是否使用安全連線配對。

方法

Close()

關閉藍牙裝置。

Dispose()

執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。

FromBluetoothAddressAsync(UInt64)

會傳回指定藍牙AddressBluetoothDevice物件。

FromHostNameAsync(HostName)

傳回指定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) 篩選字串,其中包含具有指定 藍牙ConnectionStatus 的藍牙裝置查詢。 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 記錄已變更時。

適用於

另請參閱