GattServerSessionScope


public interface GattServerSessionScope


A scope for operations as a GATT server role.

A scope is created for each remote device.

Collect requests to respond with requests from the client.

See also
GattServerConnectRequest

#accept()

Summary

Public methods

abstract @NonNull BluetoothDevice

A client device connected to the server.

abstract @NonNull Flow<@NonNull GattServerRequest>

A hot Flow of incoming requests from the client.

abstract @NonNull StateFlow<@NonNull Set<@NonNull GattCharacteristic>>

A StateFlow of the set of characteristics that the client has requested to be notified of.

abstract void
notify(@NonNull GattCharacteristic characteristic, @NonNull byte[] value)

Notifies a client of a characteristic value change.

Public methods

getDevice

Added in 1.0.0-alpha02
abstract @NonNull BluetoothDevice getDevice()

A client device connected to the server.

getRequests

Added in 1.0.0-alpha02
abstract @NonNull Flow<@NonNull GattServerRequestgetRequests()

A hot Flow of incoming requests from the client.

A request is either GattServerRequest.ReadCharacteristic or GattServerRequest.WriteCharacteristics

getSubscribedCharacteristics

Added in 1.0.0-alpha02
abstract @NonNull StateFlow<@NonNull Set<@NonNull GattCharacteristic>> getSubscribedCharacteristics()

A StateFlow of the set of characteristics that the client has requested to be notified of.

The set will be updated whenever the client subscribes to or unsubscribes a characteristic.

See also
notify

notify

Added in 1.0.0-alpha02
abstract void notify(@NonNull GattCharacteristic characteristic, @NonNull byte[] value)

Notifies a client of a characteristic value change.

Parameters
@NonNull GattCharacteristic characteristic

the updated characteristic

@NonNull byte[] value

the new value of the characteristic

Throws
kotlinx.coroutines.CancellationException

if it failed to notify

kotlin.IllegalArgumentException

if the length of the value is greater than the maximum attribute length (512)