Class BluetoothGattServer

    Definition

    Namespace:
    Tizen.Network.Bluetooth
    Assembly:
    Tizen.Network.Bluetooth.dll

    The Bluetooth GATT server.

    public class BluetoothGattServer : IDisposable
    Inheritance
    object
    BluetoothGattServer
    Implements
    System.IDisposable

    Methods

    View Source

    CreateServer()

    Creates the Bluetooth GATT server.

    Declaration
    public static BluetoothGattServer CreateServer()
    Returns
    Type Description
    BluetoothGattServer

    The BluetoothGattServer instance.

    Exceptions
    Type Condition
    System.NotSupportedException

    Thrown when the BT/BTLE is not supported.

    System.InvalidOperationException

    Thrown when the create GATT server fails.

    View Source

    Dispose()

    Destroys the current object.

    Declaration
    public void Dispose()
    View Source

    Dispose(bool)

    Releases all the resources currently used by this instance.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    true if the managed resources should be disposed, otherwise false.

    View Source

    ~BluetoothGattServer()

    Destroys the current object.

    Declaration
    protected ~BluetoothGattServer()
    View Source

    GetAttMtu(string)

    Gets the value of the ATT MTU(Maximum Transmission Unit) for the connection.

    Declaration
    public int GetAttMtu(string clientAddress)
    Parameters
    Type Name Description
    string clientAddress

    The remote device address.

    Returns
    Type Description
    int

    The MTU value

    Exceptions
    Type Condition
    System.NotSupportedException

    Thrown when the BT/BLE is not supported.

    System.InvalidOperationException

    Thrown when the BT/BLE is not enabled or when the remote device is disconnected, or when other specific error occurs.

    View Source

    GetService(string)

    Gets service with given UUID that belongs to this server.

    Declaration
    public 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.NotSupportedException

    Thrown when the BT/BTLE is not supported.

    System.InvalidOperationException

    Thrown when the service is not registered.

    View Source

    GetServices()

    Gets the list of services that belongs to this server.

    Declaration
    public IEnumerable<BluetoothGattService> GetServices()
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<T><BluetoothGattService>

    The list of services that belongs to this server.

    Exceptions
    Type Condition
    System.NotSupportedException

    Thrown when the BT/BTLE is not supported.

    System.InvalidOperationException

    Thrown when the service is not registered.

    View Source

    RegisterGattService(BluetoothGattService)

    Registers a specified service to this server.

    Declaration
    public void RegisterGattService(BluetoothGattService service)
    Parameters
    Type Name Description
    BluetoothGattService service

    The service, which needs to be registered with this server.

    Exceptions
    Type Condition
    System.NotSupportedException

    Thrown when the BT/BTLE is not supported.

    System.InvalidOperationException

    Thrown when the register service fails.

    View Source

    SendIndicationAsync(BluetoothGattCharacteristic, string)

    Sends indication for the value change of the characteristic to the remote devices.

    Declaration
    public Task<bool> SendIndicationAsync(BluetoothGattCharacteristic characteristic, string clientAddress)
    Parameters
    Type Name Description
    BluetoothGattCharacteristic characteristic

    The characteristic whose the value is changed.

    string clientAddress

    The remote device address to send, notify, or indicate and if set to NULL, then notify/indicate all is enabled.

    Returns
    Type Description
    System.Threading.Tasks.Task<TResult><bool>

    true on success, false otherwise.

    Exceptions
    Type Condition
    System.NotSupportedException

    Thrown when the BT/BTLE is not supported.

    System.InvalidOperationException

    Thrown when the BT/BTLE is not enabled or when the remote device is disconnected, or when service is not registered, or when the CCCD is not enabled.

    View Source

    SendNotification(BluetoothGattCharacteristic, string)

    Sends the notification for the value change of the characteristic to the remote devices.

    Declaration
    public void SendNotification(BluetoothGattCharacteristic characteristic, string clientAddress)
    Parameters
    Type Name Description
    BluetoothGattCharacteristic characteristic

    The characteristic, which has a changed value.

    string clientAddress

    The remote device address to send, notify, or indicate and if set to NULL, then notify/indicate all is enabled.

    Exceptions
    Type Condition
    System.NotSupportedException

    Thrown when the BT/BTLE is not supported.

    System.InvalidOperationException

    Thrown when the BT/BTLE is not enabled or when the remote device is disconnected, or when service is not registered, or when the CCCD is not enabled.

    View Source

    SendResponse(int, BluetoothGattRequestType, int, byte[], int)

    Sends a response to the remote device as a result of a read/write request.

    Declaration
    public void SendResponse(int requestId, BluetoothGattRequestType type, int status, byte[] value, int offset)
    Parameters
    Type Name Description
    int requestId

    The identification of a read/write request.

    BluetoothGattRequestType type

    The request type for read/write.

    int status

    The error value in case of failure, 0 for success.

    byte[] value

    The value to be sent.

    int offset

    The offset from where the value is read.

    Exceptions
    Type Condition
    System.NotSupportedException

    Thrown when the BT/BTLE is not supported.

    System.InvalidOperationException

    Thrown when the BT/BTLE is not enabled or when the remote device is disconnected, or the send response procedure fails.

    View Source

    Start()

    Registers the server along with the GATT services of the application it is hosting.

    Declaration
    public void Start()
    Exceptions
    Type Condition
    System.NotSupportedException

    Thrown when the BT/BTLE is not supported.

    System.InvalidOperationException

    Thrown when the register server application fails.

    View Source

    UnregisterGattService(BluetoothGattService)

    Unregisters a specified service from this server.

    Declaration
    public void UnregisterGattService(BluetoothGattService service)
    Parameters
    Type Name Description
    BluetoothGattService service

    The service, which needs to be unregistered from this server.

    Remarks

    Once unregistered, the service object will become invalid and should not be used to access sevices or any children attribute's methods/members.

    Exceptions
    Type Condition
    System.NotSupportedException

    Thrown when the BT/BTLE is not supported.

    System.InvalidOperationException

    Thrown when the unregister service fails.

    View Source

    UnregisterGattServices()

    Unregisters all services from this server.

    Declaration
    public void UnregisterGattServices()
    Remarks

    Once unregistered, servicees will become invalid and should not be used to access sevices or any children attribute's methods/members.

    Exceptions
    Type Condition
    System.NotSupportedException

    Thrown when the BT/BTLE is not supported.

    System.InvalidOperationException

    Thrown when the unregister all services fail.

    Events

    View Source

    NotificationSent

    (event) This event is called when the indication acknowledgement is received for each notified client.

    Declaration
    public event EventHandler<NotificationSentEventArg> NotificationSent
    Event Type
    Type Description
    System.EventHandler<TEventArgs><NotificationSentEventArg>

    Implements

    System.IDisposable
    • View Source
    Back to top Copyright © 2016-2024 Samsung
    Generated by DocFX