Bluetooth API Reference (Windows Runtime)
This section provides API documentation for Bluetooth functionality within the Windows Runtime (UWP) ecosystem. Learn how to discover, connect, and communicate with Bluetooth devices from your Windows applications.
Namespaces
- Windows.Devices.Bluetooth.GenericAttributeProfile
- Windows.Devices.Bluetooth.Rfcomm
- Windows.Devices.Bluetooth.Advertisement
- Windows.Devices.Bluetooth.Background
- Windows.Devices.Bluetooth.DeviceInformation
Windows.Devices.Bluetooth.GenericAttributeProfile
Provides APIs for interacting with Bluetooth Low Energy (BLE) devices using the Generic Attribute Profile (GATT).
- GattDeviceCharacteristic
- GattDeviceControl
- GattDeviceInformation
- GattDeviceService
- GattLocalCharacteristic
- GattLocalDescriptor
- GattLocalNotificationHandler
- GattLocalRequirement
- GattLocalCharacteristicParameters
- GattLocalCharacteristicReadResult
- GattLocalCharacteristicValueChangedEventArgs
- GattLocalDescriptorParameters
- GattLocalDescriptorReadResult
- GattLocalNotificationSupport
- GattLocalReadResult
- GattLocalWriteResult
- GattProtocolError
- GattServiceUuids
- GattWriteOption
- GattWriteResult
GattDeviceCharacteristic
Represents a characteristic within a GATT service.
Methods
-
Windows.Foundation.IAsyncOperationReadValueAsync() Reads the value of the characteristic asynchronously.Returns
- An asynchronous operation that returns a
Windows.Storage.Streams.IBufferrepresenting the characteristic's value.
// Example: Reading a characteristic value var result = await characteristic.ReadValueAsync(); if (result.Status == GattCommunicationStatus.Success) { var buffer = result.Value; // Process the buffer... } - An asynchronous operation that returns a
-
Windows.Foundation.IAsyncOperationWriteValueAsync(Windows.Storage.Streams.IBuffer value) Writes a value to the characteristic asynchronously.Parameters
- value:
Windows.Storage.Streams.IBuffer- The data to write to the characteristic.
Returns
- An asynchronous operation that returns a
Windows.Devices.Bluetooth.GenericAttributeProfile.GattWriteResultindicating the outcome of the write operation.
// Example: Writing a characteristic value var writer = new DataWriter(); writer.WriteByte(0x01); // Example byte var buffer = writer.DetachBuffer(); var result = await characteristic.WriteValueAsync(buffer); if (result.Status == GattCommunicationStatus.Success) { // Write successful } - value:
-
Windows.Foundation.IAsyncOperationWriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue clientCharacteristicConfigurationDescriptor) Writes the client characteristic configuration descriptor for the characteristic asynchronously. This is used to enable or disable notifications/indications.Parameters
- clientCharacteristicConfigurationDescriptor:
Windows.Devices.Bluetooth.GenericAttributeProfile.GattClientCharacteristicConfigurationDescriptorValue- The desired configuration value (e.g., Notify, Indicate, None).
Returns
- An asynchronous operation that returns a
Windows.Devices.Bluetooth.GenericAttributeProfile.GattClientCharacteristicConfigurationDescriptorValuerepresenting the result of the operation.
- clientCharacteristicConfigurationDescriptor:
Windows.Devices.Bluetooth.Rfcomm
Provides APIs for classic Bluetooth communication using the RFCOMM protocol.
RfcommDeviceId
Represents a device ID for an RFCOMM service.
Properties
-
string DeviceId { get; }Gets the string representation of the RFCOMM device ID. -
Windows.Devices.Enumeration.DeviceInformation DeviceInfo { get; }Gets the DeviceInformation object associated with this RFCOMM device ID.
Methods
-
static Windows.Foundation.IAsyncOperationFromIdAsync(string deviceId) Creates an RfcommDeviceId from a device ID string.Parameters
- deviceId:
string- The device ID string to parse.
Returns
- An asynchronous operation that returns an
RfcommDeviceId.
- deviceId:
Windows.Devices.Bluetooth.Advertisement
APIs for handling Bluetooth advertisements (advertising and scanning).
- BluetoothLEAdvertisementBatteryStatus
- BluetoothLEAdvertisementData
- BluetoothLEAdvertisementDataSection
- BluetoothLEAdvertisementManufacturerData
- BluetoothLEAdvertisementReceivedEventArgs
- BluetoothLEAdvertisementSignalStrength
- BluetoothLEAdvertisementType
- BluetoothLEAdvertisementWatcher
- BluetoothLEAdvertisementWatcherStopReason
- BluetoothLEAdvertisementWatcherStopOperation
- BluetoothLEAdvertisementWatcherStartOperation
Windows.Devices.Bluetooth.Background
APIs for enabling Bluetooth functionality in background tasks.
Windows.Devices.Bluetooth.DeviceInformation
Provides access to device information for Bluetooth devices.
BluetoothDevice
Represents a Bluetooth device.
Properties
-
string Name { get; }Gets the name of the Bluetooth device. -
BluetoothDeviceId BluetoothDeviceId { get; }Gets the unique identifier for the Bluetooth device. -
Windows.Foundation.Collections.IVectorViewServices { get; } Gets the collection of GATT services exposed by the device.
Methods
-
static Windows.Foundation.IAsyncOperationFromIdAsync(string deviceId) Retrieves a BluetoothDevice object from its device ID.Parameters
- deviceId:
string- The device ID of the Bluetooth device.
Returns
- An asynchronous operation that returns a
BluetoothDevice.
- deviceId:
-
static Windows.Foundation.IAsyncOperationGetDeviceSelectorAsync() Gets a device selector string that can be used withWindows.Devices.Enumeration.DeviceInformation.FindAllAsyncto find Bluetooth devices.Returns
- An asynchronous operation that returns a
Windows.Devices.Enumeration.DeviceInformationCollection.
- An asynchronous operation that returns a