Dela via


GattSession Class

Definition

Represents a Generic Attribute Profile (GATT) session.

public ref class GattSession sealed : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 262144)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class GattSession final : IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 262144)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class GattSession : System.IDisposable
Public NotInheritable Class GattSession
Implements IDisposable
Inheritance
Object Platform::Object IInspectable GattSession
Attributes
Implements

Windows requirements

Device family
Windows 10 Creators Update (introduced in 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v4.0)
App capabilities
bluetooth

Properties

CanMaintainConnection

Gets a Boolean value that indicates whether the connection can be maintained.

DeviceId

Gets the device ID.

MaintainConnection

Gets or sets a Boolean value that indicates whether the connection should be maintained.

MaxPduSize

Gets the maximum protocol data unit (PDU) size. This metric is also known as the maximum transmission unit (MTU) size.

Also see the GattSession.MaxPduSizeChanged event.

SessionStatus

Gets the session status.

Methods

Close()

Closes the GattSession.

Dispose()

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

FromDeviceIdAsync(BluetoothDeviceId)

Creates a new GattSession object from the specified deviceId.

Events

MaxPduSizeChanged

An event that is raised when the maximum protocol data unit (PDU) size changes. The PDU is also known as the maximum transmission unit (MTU).

MaxPduSizeChanged is raised whenever the negotiated MTU for the Attribute Protocol (ATT) is changed. And that can be changed or negotiated by a remote Bluetooth peripheral. As a developer, you can't change the value used by Windows itself, since that's fully managed by the operating system.

Also see the GattSession.MaxPduSize property which, as mentioned, is read-only.

SessionStatusChanged

An event that is triggered when the GATT session status has changed.

Applies to