BluetoothDevice Class

Definition

Represents a Bluetooth device.

Sample applications that use this class include Device enumeration and pairing sample and Bluetooth RFCOMM chat sample.

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
Inheritance
Object Platform::Object IInspectable BluetoothDevice
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)
App capabilities
bluetooth

Remarks

Version history

Windows version SDK version Value added
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

Properties

BluetoothAddress

Gets the device address.

BluetoothDeviceId

Gets the bluetooth device ID.

ClassOfDevice

Gets the Bluetooth Class Of Device information of the device.

ConnectionStatus

Gets the connection status of the device.

DeviceAccessInformation

The current DeviceAccessInformation object for the device. Used to check and monitor access changes to the device.

DeviceId

Gets the device ID that came from the Windows.Devices.Enumeration.DeviceInformation.Id

DeviceInformation

Gets the DeviceInformation object for the Bluetooth device.

HostName

Gets the HostName of the device.

Name

Gets the Name of the device.

RfcommServices

Gets the read-only list of RFCOMM services supported by the device.

Important

The RfcommServices API is deprecated, and it may not be available in future versions of Windows. Instead, use GetRfcommServicesAsync.

SdpRecords

Gets the read-only list of Service Discovery Protocol (SDP) records for the device.

WasSecureConnectionUsedForPairing

Gets a boolean indicating whether the BluetoothDevice was paired using a Secure Connection.

Methods

Close()

Closes the Bluetooth device.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

FromBluetoothAddressAsync(UInt64)

Returns a BluetoothDevice object for the given BluetoothAddress.

FromHostNameAsync(HostName)

Returns a BluetoothDevice object identified by the given HostName.

FromIdAsync(String)

Returns a BluetoothDevice object identified by the given DeviceId.

GetDeviceSelector()

Gets an Advanced Query Syntax (AQS) string for identifying instances of this device. This string is passed to the FindAllAsync or CreateWatcher method.

GetDeviceSelectorFromBluetoothAddress(UInt64)

Creates an Advanced Query Syntax (AQS) filter string from a 64-bit address that represents a Bluetooth device. The AQS string is passed into the CreateWatcher method to return a collection of DeviceInformation objects.

GetDeviceSelectorFromClassOfDevice(BluetoothClassOfDevice)

Creates an Advanced Query Syntax (AQS) filter string from a BluetoothClassOfDevice object. The AQS string is passed into the CreateWatcher method to return a collection of DeviceInformation objects.

GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus)

Creates an Advanced Query Syntax (AQS) filter string that contains a query for Bluetooth devices with the indicated BluetoothConnectionStatus. The AQS string is passed into the CreateWatcher method to return a collection of DeviceInformation objects with the indicated Bluetooth connection status.

GetDeviceSelectorFromDeviceName(String)

Creates an Advanced Query Syntax (AQS) filter string that contains a query for the Bluetooth device name. The AQS string is passed into the CreateWatcher method to return a collection of DeviceInformation objects containing the specified Bluetooth device name.

GetDeviceSelectorFromPairingState(Boolean)

Creates an Advanced Query Syntax (AQS) filter string that contains a query for Bluetooth devices that are either paired or unpaired. The AQS string is passed into the CreateWatcher method to return a collection of DeviceInformation objects.

GetRfcommServicesAsync()

Retrieves all Rfcomm Services on the remote Bluetooth Device.

GetRfcommServicesAsync(BluetoothCacheMode)

Retrieves all cached Rfcomm Services on the remote Bluetooth Device.

GetRfcommServicesForIdAsync(RfcommServiceId)

Retrieves all Rfcomm Services on the Remote Bluetooth Device matching the specified RfcommServiceId.

GetRfcommServicesForIdAsync(RfcommServiceId, BluetoothCacheMode)

Retrieves all cached Rfcomm Services on the Remote Bluetooth Device matching the specified RfcommServiceId.

RequestAccessAsync()

Used to request explicit access to the Bluetooth device. This invokes Device Consent and must be called on the UI thread.

Events

ConnectionStatusChanged

Occurs when the connection status of the device has changed.

NameChanged

Occurs when the name of the device has changed.

SdpRecordsChanged

Occurs when the list SDP records for the device has changed.

Applies to

See also