Dela via


BluetoothLEDevice Class

Definition

Represents a Bluetooth LE device.

For code examples, see Bluetooth Low Energy sample and Device enumeration and pairing sample.

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
Inheritance
Object Platform::Object IInspectable BluetoothLEDevice
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 Appearance
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

Properties

Appearance

Gets the BluetoothLEAppearance object for the Bluetooth LE device.

BluetoothAddress

Gets the device address.

BluetoothAddressType

Gets the address type for the Bluetooth LE device.

BluetoothDeviceId

Gets the bluetooth device ID.

ConnectionStatus

Gets the connection status of the device.

DeviceAccessInformation

Gets the DeviceAccessInformation.

DeviceId

Gets the device Id.

DeviceInformation

Gets the device information for the Bluetooth LE device.

GattServices

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

Important

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

Name

Gets the name of the Bluetooth LE device.

WasSecureConnectionUsedForPairing

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

Methods

Close()

Closes this Bluetooth LE device. This may close the connection to the device if this is the only app with a connection.

Dispose()

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

FromBluetoothAddressAsync(UInt64, BluetoothAddressType)

Returns a BluetoothLEDevice object representing the peer device with the given address and address type. See Remarks (in this member topic).

FromBluetoothAddressAsync(UInt64)

Returns a BluetoothLEDevice object representing the peer Bluetooth LE device with the given address. See Remarks (in this member topic).

FromIdAsync(String)

Returns a BluetoothLEDevice object for the given Id. See Remarks in the member topic.

GetConnectionParameters()

Retrieves connection parameters for the remote device. If multiple apps or other system scenarios also request these parameters, then the system automatically combines the parameters, where compatible, based on system priority.

Note

When the device is not connected, the connection parameters are invalid (all zero).

GetConnectionPhy()

Retrieves info about about the Bluetooth LE physical layer (PHY).

Note

When the device is not connected, the connection PHYs are invalid (all false)

GetDeviceSelector()

Gets an Advanced Query Syntax (AQS) string for identifying all Bluetooth Low Energy (LE) devices. This string is passed to the FindAllAsync or CreateWatcher method in order to get a list of Bluetooth LE devices.

GetDeviceSelectorFromAppearance(BluetoothLEAppearance)

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

GetDeviceSelectorFromBluetoothAddress(UInt64, BluetoothAddressType)

Creates an Advanced Query Syntax (AQS) filter string from a 64-bit address and address type that represents a Bluetooth LE device. The AQS string is passed into the CreateWatcher method.

GetDeviceSelectorFromBluetoothAddress(UInt64)

Creates an Advanced Query Syntax (AQS) filter string from a 64-bit address that represents a Bluetooth LE device. 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 LE 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 LE device name. The AQS string is passed into the CreateWatcher method to return a collection of DeviceInformation objects containing the specified Bluetooth LE device name.

GetDeviceSelectorFromPairingState(Boolean)

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

GetGattService(Guid)

Returns the GATT service with the given service Id.

Important

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

GetGattServicesAsync()

Gets the GattDeviceServices for this Bluetooth LowEnergy device.

GetGattServicesAsync(BluetoothCacheMode)

Returns the GattDeviceServices for this Bluetooth LowEnergy device with the specified cache mode.

GetGattServicesForUuidAsync(Guid, BluetoothCacheMode)

Returns the GattDeviceServices for the Bluetooth LowEnergy device with the specified UUID.

GetGattServicesForUuidAsync(Guid)

Returns the GattDeviceServices for the Bluetooth LowEnergy device with the specified UUID.

RequestAccessAsync()

Requests access to the Bluetooth LowEnergy device.

RequestPreferredConnectionParameters(BluetoothLEPreferredConnectionParameters)

Retrieves a Bluetooth LE preferred connection parameters request object for the specified Bluetooth LE preferred connection parameters object.

Events

ConnectionParametersChanged

An event that's raised when the current connection parameters for the device change. The parameters will update only after a connection to the device has been established.

ConnectionPhyChanged

An event that's raised when the current PHY for the device changes. The PHY will update only after a connection to the device has been established.

ConnectionStatusChanged

Occurs when the connection status for the device has changed.

GattServicesChanged

Raised when the list of GATT services supported by the device has changed.

NameChanged

Occurs when the name of the device has changed.

Applies to

See also