Class BluetoothGattClient
Definition
- Assembly:
- Tizen.Network.Bluetooth.dll
The Bluetooth GATT client.
C#Copypublic class BluetoothGattClient : IDisposable
- Inheritance
-
objectBluetoothGattClient
- Implements
-
System.IDisposable
Properties
Declaration
C#Copypublic string RemoteAddress { get; }
Property Value
| Type | Description |
|---|---|
| string |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when the BT/BTLE is not enabled or when the remote device is disconnected. |
Methods
Declaration
C#Copypublic Task ConnectAsync(bool autoConnect)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | autoConnect | The flag for reconnecting when the connection is disconnceted. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task indicating whether the method is done or not. |
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the BT/BTLE is not supported. |
| System.InvalidOperationException | Thrown when the create GATT client fails. |
Declaration
C#Copypublic static BluetoothGattClient CreateClient(string remoteAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| string | remoteAddress | The remote device address. |
Returns
| Type | Description |
|---|---|
| BluetoothGattClient | The BluetoothGattClient instance. |
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the BT/BTLE is not supported. |
| System.InvalidOperationException | Thrown when the create GATT client fails. |
Declaration
C#Copy[Obsolete("Deprecated since API level 6. Please use Dispose() method on BluetoothGattClient.")] public void DestroyClient()
Declaration
C#Copypublic Task DisconnectAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task | A task indicating whether the method is done or not. |
Exceptions
| Type | Condition |
|---|---|
| System.NotSupportedException | Thrown when the BT/BTLE is not supported. |
| System.InvalidOperationException | Thrown when the create GATT client fails. |
Declaration
C#Copypublic void Dispose()
Declaration
C#Copyprotected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | true if the managed resources should be disposed, otherwise false. |
Declaration
C#Copyprotected ~BluetoothGattClient()
GetService(string)
Gets the service with the given UUID that belongs to the remote device.
Declaration
C#Copypublic BluetoothGattService GetService(string uuid)
Parameters
| Type | Name | Description |
|---|---|---|
| string | uuid | The UUID for the service to get. |
Returns
| Type | Description |
|---|---|
| BluetoothGattService | The service with the given UUID if it exists, null otherwise. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when the BT/BTLE is not enabled or when the remote device is disconnected, or when the get service fails. |
Declaration
C#Copypublic IEnumerable<BluetoothGattService> GetServices()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T><BluetoothGattService> | The list of services that belongs to the remote device. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when the BT/BTLE is not enabled or when the remote device is disconnected, or when the get service fails. |
ReadValueAsync(BluetoothGattCharacteristic)
Reads the value of a given characteristic from the remote device asynchronously.
Declaration
C#Copypublic Task<bool> ReadValueAsync(BluetoothGattCharacteristic characteristic)
Parameters
| Type | Name | Description |
|---|---|---|
| BluetoothGattCharacteristic | characteristic | The characteristic to be read. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><bool> | true on success, false otherwise. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when the BT/BTLE is not enabled or when the remote device is disconnected, or when the read attribute value fails. |
ReadValueAsync(BluetoothGattDescriptor)
Reads the value of the given descriptor from the remote device asynchronously.
Declaration
C#Copypublic Task<bool> ReadValueAsync(BluetoothGattDescriptor descriptor)
Parameters
| Type | Name | Description |
|---|---|---|
| BluetoothGattDescriptor | descriptor | The descriptor to be read. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><bool> | true on success, false otherwise. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when the BT/BTLE is not enabled or when the remote device is disconnected, or when the read attribute value fails. |
WriteValueAsync(BluetoothGattCharacteristic)
Writes the value of a given characteristic to the remote device asynchronously.
Declaration
C#Copypublic Task<bool> WriteValueAsync(BluetoothGattCharacteristic characteristic)
Parameters
| Type | Name | Description |
|---|---|---|
| BluetoothGattCharacteristic | characteristic | The characteristic to be written. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><bool> | true on success, false otherwise. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when the BT/BTLE is not enabled or when the remote device is disconnected or when the write attribute value fails. |
WriteValueAsync(BluetoothGattDescriptor)
Writes the value of the given descriptor to the remote device asynchronously.
Declaration
C#Copypublic Task<bool> WriteValueAsync(BluetoothGattDescriptor descriptor)
Parameters
| Type | Name | Description |
|---|---|---|
| BluetoothGattDescriptor | descriptor | The descriptor to be written. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<TResult><bool> | true on success, false otherwise. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown when the BT/BTLE is not enabled or when the remote device is disconnected, or when the write attribute value fails. |
Events
ConnectionStateChanged
The ConnectionStateChanged event is raised when the gatt connection state is changed.
Declaration
C#Copypublic event EventHandler<GattConnectionStateChangedEventArgs> ConnectionStateChanged
Event Type
| Type | Description |
|---|---|
| System.EventHandler<TEventArgs><GattConnectionStateChangedEventArgs> |